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 7948f79dbf7c..53c8ad62704c 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
@@ -455,11 +455,11 @@
{{#allVars}}
{{^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)
- throw new ArgumentNullException(nameof({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}), "Property is required for class {{classname}}.");
+ {{^required}}
+ 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 JsonException("Cannot write null property {{classname}}.{{name}} to non-nullable JSON property '{{baseName}}'.");
- {{/vendorExtensions.x-is-reference-type}}
+ {{/required}}
{{/isNullable}}
{{/isDiscriminator}}
{{/allVars}}
diff --git a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef.cs b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef.cs
index 2c365d4b4b3b..afc16caa901c 100644
--- a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef.cs
+++ b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef.cs
@@ -168,6 +168,9 @@ public override void Write(Utf8JsonWriter writer, OneOfNullAndRef oneOfNullAndRe
///
public void WriteProperties(Utf8JsonWriter writer, OneOfNullAndRef oneOfNullAndRef, JsonSerializerOptions jsonSerializerOptions)
{
+ if (oneOfNullAndRef.NumberOption.IsSet && oneOfNullAndRef.Number == null)
+ throw new JsonException("Cannot write null property OneOfNullAndRef.Number to non-nullable JSON property 'number'.");
+
if (oneOfNullAndRef.NumberOption.IsSet)
{
var numberRawValue = NumberValueConverter.ToJsonValue(oneOfNullAndRef.Number!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef2.cs b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef2.cs
index 305d1256e5aa..b93625d3a510 100644
--- a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef2.cs
+++ b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef2.cs
@@ -168,6 +168,9 @@ public override void Write(Utf8JsonWriter writer, OneOfNullAndRef2 oneOfNullAndR
///
public void WriteProperties(Utf8JsonWriter writer, OneOfNullAndRef2 oneOfNullAndRef2, JsonSerializerOptions jsonSerializerOptions)
{
+ if (oneOfNullAndRef2.NumberOption.IsSet && oneOfNullAndRef2.Number == null)
+ throw new JsonException("Cannot write null property OneOfNullAndRef2.Number to non-nullable JSON property 'number'.");
+
if (oneOfNullAndRef2.NumberOption.IsSet)
{
var numberRawValue = NumberValueConverter.ToJsonValue(oneOfNullAndRef2.Number!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef3.cs b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef3.cs
index 3eee3a0cc0a3..9ade8f157f5a 100644
--- a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef3.cs
+++ b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/OneOfNullAndRef3.cs
@@ -168,6 +168,9 @@ public override void Write(Utf8JsonWriter writer, OneOfNullAndRef3 oneOfNullAndR
///
public void WriteProperties(Utf8JsonWriter writer, OneOfNullAndRef3 oneOfNullAndRef3, JsonSerializerOptions jsonSerializerOptions)
{
+ if (oneOfNullAndRef3.NumberOption.IsSet && oneOfNullAndRef3.Number == null)
+ throw new JsonException("Cannot write null property OneOfNullAndRef3.Number to non-nullable JSON property 'number'.");
+
if (oneOfNullAndRef3.NumberOption.IsSet)
{
var numberRawValue = NumberValueConverter.ToJsonValue(oneOfNullAndRef3.Number!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/Parent.cs b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/Parent.cs
index d80195837703..d2fd6566d8f4 100644
--- a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/Parent.cs
+++ b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/Parent.cs
@@ -168,6 +168,9 @@ public override void Write(Utf8JsonWriter writer, Parent parent, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Parent parent, JsonSerializerOptions jsonSerializerOptions)
{
+ if (parent.NumberOption.IsSet && parent.Number == null)
+ throw new JsonException("Cannot write null property Parent.Number to non-nullable JSON property 'number'.");
+
if (parent.NumberOption.IsSet)
{
var numberRawValue = NumberValueConverter.ToJsonValue(parent.Number!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/ParentWithOneOfProperty.cs b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/ParentWithOneOfProperty.cs
index 01da36ff5bb5..af064bac4e56 100644
--- a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/ParentWithOneOfProperty.cs
+++ b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/ParentWithOneOfProperty.cs
@@ -168,6 +168,9 @@ public override void Write(Utf8JsonWriter writer, ParentWithOneOfProperty parent
///
public void WriteProperties(Utf8JsonWriter writer, ParentWithOneOfProperty parentWithOneOfProperty, JsonSerializerOptions jsonSerializerOptions)
{
+ if (parentWithOneOfProperty.NumberOption.IsSet && parentWithOneOfProperty.Number == null)
+ throw new JsonException("Cannot write null property ParentWithOneOfProperty.Number to non-nullable JSON property 'number'.");
+
if (parentWithOneOfProperty.NumberOption.IsSet)
{
var numberRawValue = NumberValueConverter.ToJsonValue(parentWithOneOfProperty.Number!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/ParentWithPluralOneOfProperty.cs b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/ParentWithPluralOneOfProperty.cs
index 2f55ea9f5d23..5dfece8a6d02 100644
--- a/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/ParentWithPluralOneOfProperty.cs
+++ b/samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/ParentWithPluralOneOfProperty.cs
@@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, ParentWithPluralOneOfProperty
public void WriteProperties(Utf8JsonWriter writer, ParentWithPluralOneOfProperty parentWithPluralOneOfProperty, JsonSerializerOptions jsonSerializerOptions)
{
if (parentWithPluralOneOfProperty.NumberOption.IsSet && parentWithPluralOneOfProperty.Number == null)
- throw new ArgumentNullException(nameof(parentWithPluralOneOfProperty.Number), "Property is required for class ParentWithPluralOneOfProperty.");
+ throw new JsonException("Cannot write null property ParentWithPluralOneOfProperty.Number to non-nullable JSON property 'number'.");
if (parentWithPluralOneOfProperty.NumberOption.IsSet)
{
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 ec7288f8f566..83136644b5e5 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
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property HelloWorldPostRequest.Message to non-nullable JSON property 'message'.");
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 e921fe3416c3..f584d270555a 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
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
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 af4a73936b1e..46fd8d0a3dd3 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
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property IconsDefaultResponse.String to non-nullable JSON property 'string'.");
if (iconsDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Color.cs b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Color.cs
index 43acd7237bd3..392bf310549c 100644
--- a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Color.cs
+++ b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Color.cs
@@ -250,6 +250,15 @@ public override void Write(Utf8JsonWriter writer, Color color, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Color color, JsonSerializerOptions jsonSerializerOptions)
{
+ if (color.BOption.IsSet && color.B == null)
+ throw new JsonException("Cannot write null property Color.B to non-nullable JSON property 'b'.");
+
+ if (color.GOption.IsSet && color.G == null)
+ throw new JsonException("Cannot write null property Color.G to non-nullable JSON property 'g'.");
+
+ if (color.ROption.IsSet && color.R == null)
+ throw new JsonException("Cannot write null property Color.R to non-nullable JSON property 'r'.");
+
if (color.BOption.IsSet)
writer.WriteNumber("b", color.BOption.Value!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/NullTypeDirect.cs b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/NullTypeDirect.cs
index 0d1f337a2103..cb668927b471 100644
--- a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/NullTypeDirect.cs
+++ b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/NullTypeDirect.cs
@@ -189,6 +189,9 @@ public override void Write(Utf8JsonWriter writer, NullTypeDirect nullTypeDirect,
///
public void WriteProperties(Utf8JsonWriter writer, NullTypeDirect nullTypeDirect, JsonSerializerOptions jsonSerializerOptions)
{
+ if (nullTypeDirect.IdOption.IsSet && nullTypeDirect.Id == null)
+ throw new JsonException("Cannot write null property NullTypeDirect.Id to non-nullable JSON property 'id'.");
+
if (nullTypeDirect.AlwaysNullOption.IsSet)
if (nullTypeDirect.AlwaysNullOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Shape.cs
index ca85052009df..877158311288 100644
--- a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Shape.cs
+++ b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Shape.cs
@@ -189,8 +189,8 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions)
{
- if (shape.ShapeType == null)
- throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape.");
+ if (shape.AreaOption.IsSet && shape.Area == null)
+ throw new JsonException("Cannot write null property Shape.Area to non-nullable JSON property 'area'.");
writer.WriteString("shapeType", shape.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs
index 73973f2d1427..9fc58e50b835 100644
--- a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs
+++ b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs
@@ -189,8 +189,8 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeOrNull.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull.");
+ if (shapeOrNull.AreaOption.IsSet && shapeOrNull.Area == null)
+ throw new JsonException("Cannot write null property ShapeOrNull.Area to non-nullable JSON property 'area'.");
writer.WriteString("shapeType", shapeOrNull.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Widget.cs b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Widget.cs
index df6723c9cd6b..d212692286b3 100644
--- a/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Widget.cs
+++ b/samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/Widget.cs
@@ -248,9 +248,6 @@ public override void Write(Utf8JsonWriter writer, Widget widget, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Widget widget, JsonSerializerOptions jsonSerializerOptions)
{
- if (widget.Name == null)
- throw new ArgumentNullException(nameof(widget.Name), "Property is required for class Widget.");
-
writer.WriteNumber("id", widget.Id);
writer.WriteString("name", widget.Name);
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 481d615acef8..49c748d7fb39 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
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestObject.Name to non-nullable JSON property 'name'.");
if (testObject.NameOption.IsSet)
writer.WriteString("name", testObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Activity.cs
index 29826c4d7073..27267a89b539 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Activity.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 05098c80f7fb..003514970fcc 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -192,10 +192,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index c70f1ba05afb..03a63cf9238e 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -328,25 +328,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Animal.cs
index 432daa82dad9..e9fd3ed17925 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Animal.cs
@@ -215,7 +215,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ApiResponse.cs
index 1d6c89d36d8e..2d955bed2864 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -214,11 +214,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Apple.cs
index 9d1295109b0e..8aba169c7737 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Apple.cs
@@ -245,13 +245,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/AppleReq.cs
index e0e6f35b1611..7ede1db8aae9 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -187,8 +187,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 52f3744aa5ea..c5d0c0120cb6 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 62378f267b61..37e33d235abf 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayTest.cs
index 7974f4efff16..d28d7086029c 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -215,13 +215,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Banana.cs
index b4f9eb670952..ee06386ed18c 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Banana.cs
@@ -168,6 +168,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/BananaReq.cs
index 458545e6f8e6..94e303e4efb5 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -187,6 +187,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/BasquePig.cs
index 033cba8ed79c..abd455115d64 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -164,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Capitalization.cs
index 862fe329b41b..41f67b976b5f 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -285,22 +285,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Cat.cs
index 5fbb545e21b8..274069876c4a 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Cat.cs
@@ -178,7 +178,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Category.cs
index 451478c2ed84..ef51987c7c78 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Category.cs
@@ -187,8 +187,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ChildCat.cs
index a5b6a1a361ae..aef73addc4cb 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -237,7 +237,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ClassModel.cs
index 0c3424c441c1..f87938353430 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index c97bad4c55da..9afab7e4e027 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -183,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/CopyActivity.cs
index 9b1c9ee1e369..69523975f71e 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -232,9 +232,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DanishPig.cs
index 3363805c59d8..ffcd3973301e 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -164,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index efd5329632ab..e40843855a80 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index 04c3dda88f82..f2fa0117113b 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Descendant1.cs
index 76c710dacb68..3113069aea3a 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -183,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Descendant2.cs
index e8a0952a86b0..62f9a8ffa5e0 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -183,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Dog.cs
index c63877fbf113..4fa08c7e3d5e 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Dog.cs
@@ -178,10 +178,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Drawing.cs
index 63a87e544f2f..450a44bf35b2 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Drawing.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EnumArrays.cs
index f1d4a0e2bfb4..496fd8e72f03 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -331,7 +331,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EnumTest.cs
index 03b929699774..52b718fd0fcb 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -869,6 +869,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index 85a3403c71ac..7291b85426f3 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -183,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/File.cs
index 1ee7b71a9890..09cd9b5bf640 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/File.cs
@@ -170,7 +170,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 77293c60ec4b..87b218a512cc 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -192,10 +192,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Foo.cs
index e921fe3416c3..f584d270555a 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Foo.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index a12c72466ae3..a232f90cafd4 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FormatTest.cs
index e3596c5a4092..899c764ca96f 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -945,32 +945,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Fruit.cs
index f6b30057b6ca..89a1ee84e622 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Fruit.cs
@@ -220,7 +220,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/GmFruit.cs
index b33fb75226b5..ab33328b55dd 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -237,7 +237,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index 00aca88d3a1c..b10b320ea8e0 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -192,10 +192,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 857b6fb30f3e..9cde7d5b8f89 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -284,22 +284,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index 588757bf5fd4..80aef9813347 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -183,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/List.cs
index 200394e4d2eb..9e7b530c64a1 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/List.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 319ae3d0abc6..760943a4edef 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -192,10 +192,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MapTest.cs
index 41fb19a2a48d..ccbba4ceeae3 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MapTest.cs
@@ -304,16 +304,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 4009477278c7..5eb5ee1c3d2d 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedOneOf.cs
index eb8e45550813..7d90d152a794 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3497b5c2bb84..68918f31043d 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -249,8 +249,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedSubId.cs
index 6e37f0cfeede..7b00310a46f1 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Model200Response.cs
index bbe7792780ea..ddb067055bee 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -192,7 +192,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ModelClient.cs
index 4d85d9782f32..aa47d610cb2c 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Name.cs
index 288b16affea6..b597041faf5f 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Name.cs
@@ -234,7 +234,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 7bd2e1331c47..968636eb694f 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -183,9 +183,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NullableClass.cs
index 272df03fc809..c9631230e6ac 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -409,10 +409,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NumberOnly.cs
index d672c4557978..2d5b1da808c7 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -168,6 +168,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index eaee8ff08ff9..d12f94ab19b1 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -241,13 +241,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Order.cs
index d912397ce446..0c163e7f8f9a 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Order.cs
@@ -378,6 +378,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/OuterComposite.cs
index fb3180ab6323..29073f0450ad 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -214,8 +214,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Pet.cs
index 5a9db85b6482..6f040eb931cd 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Pet.cs
@@ -365,17 +365,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index bdf77ab1396f..4aaf0d1665fb 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -164,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index cf5fd20b3b56..d6a361257e44 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -192,10 +192,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RequiredClass.cs
index 2b605afe9f2f..e5db62fc1ee8 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2229,17 +2229,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Result.cs
index 7f3bb40950bd..c766fe3ca280 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Result.cs
@@ -218,13 +218,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Return.cs
index 260a7a262926..464879e9f26c 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Return.cs
@@ -226,11 +226,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index 117691977974..469134c26bde 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -192,7 +192,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 4706ca62bf0e..a906d0f6d0dd 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 19645ef302f1..c732bc01a5ad 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -183,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ShapeInterface.cs
index 39bfe84b80f8..f9441871bb4f 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -164,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index db0c148fc847..d3bc2dfb85b3 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -183,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/SpecialModelName.cs
index fe691a044fe6..98289ad7a6e6 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -192,7 +192,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Tag.cs
index b4884d224bcc..34992e8815bb 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Tag.cs
@@ -191,8 +191,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value!.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 7a1eaf17a23b..c6dd3fd660ca 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index 778000c56eb0..a6979a10b1c9 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -169,7 +169,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestDescendants.cs
index d91d79f57fa7..4da09fa5643c 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -283,9 +283,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index 1d82f412eb89..7d85da50aa83 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestResult.cs
index dd2152fe0362..b89dacf27aa0 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TestResult.cs
@@ -216,11 +216,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 65f9c875351a..5ba7f95069db 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -164,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/User.cs
index 08d85778dc61..b3c25d6eae7d 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/User.cs
@@ -418,25 +418,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Whale.cs
index c0813e422cf9..c4e8f3daa18d 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Whale.cs
@@ -210,8 +210,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Zebra.cs
index 9562526e8238..3c1a11d437d7 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/Zebra.cs
@@ -281,8 +281,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 21a8e68af61f..a81ccef21b06 100644
--- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -241,6 +241,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 eb8cbd0b3bc5..4213420714a8 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
@@ -184,13 +184,13 @@ 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.");
+ throw new JsonException("Cannot write null property Adult.Children to non-nullable JSON property 'children'.");
if (adult.FirstNameOption.IsSet && adult.FirstName == null)
- throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.FirstName to non-nullable JSON property 'firstName'.");
if (adult.LastNameOption.IsSet && adult.LastName == null)
- throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.LastName to non-nullable JSON property 'lastName'.");
if (adult.ChildrenOption.IsSet)
{
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 cc9001600c71..f71f244652dc 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
@@ -206,11 +206,17 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
+ if (child.AgeOption.IsSet && child.Age == null)
+ throw new JsonException("Cannot write null property Child.Age to non-nullable JSON property 'age'.");
+
+ if (child.BoosterSeatOption.IsSet && child.BoosterSeat == null)
+ throw new JsonException("Cannot write null property Child.BoosterSeat to non-nullable JSON property 'boosterSeat'.");
+
if (child.FirstNameOption.IsSet && child.FirstName == null)
- throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.FirstName to non-nullable JSON property 'firstName'.");
if (child.LastNameOption.IsSet && child.LastName == null)
- throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.LastName to non-nullable JSON property 'lastName'.");
if (child.AgeOption.IsSet)
writer.WriteNumber("age", child.AgeOption.Value!.Value);
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 e5e63ec9c2a5..e65419a3b600 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
@@ -243,10 +243,10 @@ 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.");
+ throw new JsonException("Cannot write null property Person.FirstName to non-nullable JSON property 'firstName'.");
if (person.LastNameOption.IsSet && person.LastName == null)
- throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
+ throw new JsonException("Cannot write null property Person.LastName to non-nullable JSON property 'lastName'.");
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 ba3ebde0806b..e6e5bf9b1853 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 ddd75420f237..65dc4a02463e 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 a552837a0067..9ccac387b196 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
@@ -245,7 +245,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 6d957f4666fe..ba2d70c2fab5 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
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 b31f8fe51330..7b0cc8bc8756 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
@@ -175,6 +175,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 b23a45484ba3..c7ad4a614836 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
@@ -244,7 +244,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Activity.cs
index 8883f1323639..2fb20fd76ba8 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index a7ae93ee504a..a7c053f968ff 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 4c9fc1cad5f2..2d355959392c 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Animal.cs
index 117be25b4c3f..90faf3ed2ad0 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
index 5a61538e1f17..332e1e100ce2 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Apple.cs
index ead5728d626b..8559896f3b99 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
index bd8cd61c4221..cc81766fcebe 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 850a9c376b5a..9a6a9cb6326c 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 2e5eb229f1c3..1b911bc1d6c0 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
index 2b63506f4b44..e42133d4a724 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Banana.cs
index 40d370fd1cdb..d887a45c931e 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
index 0673de456831..db3b3f2aabd1 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
index ea23cb6d7166..57decedb097c 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Cat.cs
index 9ff7be2175c6..f3f27956ed3b 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Category.cs
index b977a0ca50b9..d78edc3ee72c 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
index db3c3064f4e2..46fc753b3481 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
writer.WriteString("pet_type", ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType));
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
index 4d1213df9a8d..012fb4ea1848 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
index 2a75237fd09f..8d25c498e494 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 2b1f5670dec1..72a7565ec3c6 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index a0a059430fbf..4e0d1370cc9a 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
index 4386ed6689ff..5b8587c218e1 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
index d0974d2d3ae9..82cc312ea062 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Dog.cs
index e4066eb72582..5d01cd38ebbe 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
index fce60664f896..b1c4e76fe748 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
index a954055cecef..ee70392a1686 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
index cab43b30299d..780950460e89 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -351,6 +351,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/File.cs
index e6c3a7cd844f..598363737a5e 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 433035256031..74bfbfa1b1ec 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Foo.cs
index 9da199ab2477..ab3a41f87790 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 8e9bba64db14..5d64e47dc7f5 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
index 7c655b0827f2..b489e77a1e15 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
index ca703d27f96c..a73048ec0ad1 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
index c3c2a4e247ab..7071fe00f86d 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index fbd98eae40a9..2f37dd2a61d9 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/List.cs
index d6ac694585ca..b65cac7456c4 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e0e39a3acce3..4b1007e9aaf5 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
index a416718859af..463b714170dd 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
@@ -244,16 +244,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 42247df00c07..57207f29ddb1 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a8f039e97905..c3a43f3fc745 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index c54becfdc303..1d5a4defe637 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
index ec25fab92034..c1fbf300b336 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
index a78b4b9ae3a8..bb2913f5df66 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
index 9135c0e022ad..f4acaf49d8f1 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Name.cs
index e3a0ef4d62fc..19757fa1c327 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
index b83140b058a7..0c4818c0bff4 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
index 21b40632deb7..428f234deaeb 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index a6be5066e8cd..d8bd9f36ea39 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Order.cs
index 79cfaaf0e5bf..66edef8216f7 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Order.cs
@@ -295,6 +295,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
index 994ccd227bef..93be59d99690 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Pet.cs
index b94bf16627ff..f60a0987b590 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Pet.cs
@@ -282,17 +282,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 495b0d273f6a..ddd15217fc1f 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
index b84dae9064af..eeda5ef0fcc7 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -1053,17 +1053,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Result.cs
index 3d22bb06491f..b57d0b4c7e8e 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Return.cs
index 184ad3ab12c4..c4b5b9636bb3 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index d67bf5ddc948..9b73fae206ff 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 27c3871866be..22702cfaa178 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
index a24895d6f930..9b3bfdab8bcf 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Tag.cs
index ce29344d2cdf..9ac1082f742a 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 764f36716e27..b48698e26e70 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index d6de3eb2c298..4d1c9e06a24f 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
index e77c43ecd5d4..c5b9db5913dd 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -216,9 +216,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendantsObjectTypeValueConverter.ToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a09ec60e3535..5bd2ec9a6bba 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
index e023fb8f77fc..5abf98b1e65b 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/User.cs
index dc078c480cbc..90deb77dbaaa 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Whale.cs
index 02655307d760..1cdb5bad9dd1 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
index 449736faed56..67b6d90eb1d7 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 9add0a06d4cc..ad7eadb1b479 100644
--- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClassZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnumClass.ZeroBasedEnum.Value);
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 4103a73cd4f0..d43c6780ca28 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
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 adf86a28dcd0..23f5c4b3a85d 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
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 2c52c15ccdcc..ad641f68f2e9 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
@@ -336,25 +336,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
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 b5e2ed9ae27f..6344d530cd6e 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
@@ -223,7 +223,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
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 ffbd21ce4a6a..70585c8acf5b 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
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
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 0f80dc0d9c03..edd6e65f1f41 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
@@ -253,13 +253,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
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 a43c764f8240..a98f5bd8787f 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
@@ -188,8 +188,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
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 aef7d7e481d8..509645c3f350 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
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 93684cf9efc6..9d5c27336962 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
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 0b5b6d24743d..14d7950c4b6f 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
@@ -223,13 +223,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
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 fab250f7b537..0a7d794e23fc 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
}
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 42e9d1890af1..1973db4c4bed 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
@@ -188,6 +188,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
index a19a8488e044..8dbfb7552b5f 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
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 eb14befa97d3..68e8220438eb 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
@@ -293,22 +293,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
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 b1fedb233db5..0f47bd35e784 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
@@ -179,7 +179,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
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 97e28530372b..d411efbb83bd 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
@@ -195,8 +195,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value!.Value);
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 d99184db6550..d7c5a4cd96ec 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
@@ -238,7 +238,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
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 a7666cfb698a..16551511b256 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index cbc3e80b4a27..e1e504b538e1 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
index 77fc65981096..260d78873e2e 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -233,9 +233,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
index 6ee21a0298c9..ed6bc6534338 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
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 c04c4f439bdf..f39aa601716f 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
@@ -182,6 +182,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
}
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 0490d964f022..5e4782e9741b 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
index b78ed38fc503..68a2f65c9aff 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
index d4c4e6c2273c..5a130166a0b1 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
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 6908fb106b63..b8435f95759c 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
@@ -179,10 +179,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
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 74c2e0ae5d4b..cce96329e588 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
@@ -240,10 +240,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
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 3bcb6d9b4888..05f5e7db1d24 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
@@ -339,7 +339,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
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 647002803b89..62c8f51ce807 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
@@ -877,6 +877,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index bf25136ce8d5..407e33a7b6f5 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
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 668ebfa6c77c..6608c8f2c0e0 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
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 b29be867e838..d8837421dcac 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
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 98e50928aae1..4b75918a83d5 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
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 763577d494c8..baa4b149818a 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
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 d7ca66d7495a..1badd1c0d948 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
@@ -953,32 +953,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
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 ec0062ba20d3..f902f78034c4 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
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 039f5faedfc4..1eccb13e9003 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
@@ -238,7 +238,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
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 6fa1889a08bd..1a446ca46e5a 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
@@ -241,10 +241,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 962e2a3c1294..82b78a3e00f9 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -339,22 +339,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index fac6f52f2522..b211cf0586b1 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
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 aac40319978e..b8a8a257d0d2 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-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 027d4fde6be0..70963bef2fc5 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
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 3c7e075d574e..64474ff0d16d 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
@@ -312,16 +312,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
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 71af55e64992..48eca2b1e0b8 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
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 1536ccf00030..e5c9f6f2f2f7 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
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 d7d6068bcd10..1cef2917ba78 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
@@ -257,8 +257,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
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 7f178b026301..77c1611f8f80 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
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 2d6852d12c7e..ff4080153aea 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
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 0e9021c907a6..b32d7f964146 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
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 d54d7b7d29b5..8fd568be1a6b 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
@@ -283,7 +283,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 2e206a226911..10c8125b1068 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -191,9 +191,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
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 ea88ed18b540..d1327d7b480f 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
@@ -410,10 +410,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
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 fa2f63c11abf..a463ed4572d3 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
}
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 c858d1b3727b..03727598207c 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
@@ -249,13 +249,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
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 ac6f4585d259..ee4d0c85d40a 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
@@ -386,6 +386,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
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 6ed3bf816867..686aa2d77797 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
@@ -222,8 +222,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
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 6cd3a02b4296..5c16160c5db9 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
@@ -373,17 +373,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 33061272899b..bbd3a56b31ed 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
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 bb29062628a7..3b1999efb42d 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
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
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 d1f6c6f40209..1912f3c24ebf 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
@@ -2237,17 +2237,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
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 17f97f2387a3..a6bef2efe103 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
@@ -226,13 +226,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
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 02b3fdc639e2..fd9446247331 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
@@ -234,11 +234,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
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 affe88bd8aea..ac6dd43ef0b2 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
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 ed0af26e87fb..55d774689f49 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index ada72abaf3ad..f1779050584b 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
index 7d55af95627a..cb375197e488 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 48481ee56dfe..0034604725d0 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
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 7af87418b89f..81c58c98aa68 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
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 fbc5d4a9829e..a16ea726bfff 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
@@ -199,8 +199,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value!.Value);
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 dc66551a230d..182412d38e32 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
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 f297317601df..97b4b270f1c9 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
index c9e049a3db72..5b568b36e9ec 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -291,9 +291,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
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 32e069929830..07d98ed51393 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
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 1edb92ec63a9..d168aff8b9c2 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
@@ -224,11 +224,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 9fbc6b8085b5..c97244ab95ff 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
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 50de52ddebec..c6a4d2cddb86 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
@@ -426,25 +426,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
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 00e53f6dc690..74e3afd8dbf8 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
@@ -218,8 +218,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
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 a871ad34d76d..f6faea2fd5ed 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
@@ -282,8 +282,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
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 5e17279cd925..796310e1783f 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
@@ -249,6 +249,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 ba3ebde0806b..e6e5bf9b1853 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 ddd75420f237..65dc4a02463e 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 1a4743015087..af45459bafc7 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
@@ -252,7 +252,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 02e5aab13a27..793f5553239f 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
+ if (orange.SweetOption.IsSet && orange.Sweet == null)
+ throw new JsonException("Cannot write null property Orange.Sweet to non-nullable JSON property 'sweet'.");
+
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Activity.cs
index 8883f1323639..2fb20fd76ba8 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index a7ae93ee504a..a7c053f968ff 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 4c9fc1cad5f2..2d355959392c 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Animal.cs
index 117be25b4c3f..90faf3ed2ad0 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
index 5a61538e1f17..332e1e100ce2 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Apple.cs
index ead5728d626b..8559896f3b99 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
index bd8cd61c4221..cc81766fcebe 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 850a9c376b5a..9a6a9cb6326c 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 2e5eb229f1c3..1b911bc1d6c0 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
index 2b63506f4b44..e42133d4a724 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Banana.cs
index 40d370fd1cdb..d887a45c931e 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
index 0673de456831..db3b3f2aabd1 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
index ea23cb6d7166..57decedb097c 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Cat.cs
index 9ff7be2175c6..f3f27956ed3b 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Category.cs
index b977a0ca50b9..d78edc3ee72c 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
index aad251c4d9e7..d5e2a907d867 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
index 4d1213df9a8d..012fb4ea1848 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
index 73f65a894734..790b30d0598c 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -231,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 2b1f5670dec1..72a7565ec3c6 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index a0a059430fbf..4e0d1370cc9a 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
index 8abf3f5844d0..00e11bca0df2 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
index 5484c2ec84ad..3ad11787dcb3 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Dog.cs
index e4066eb72582..5d01cd38ebbe 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
index fce60664f896..b1c4e76fe748 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
index 45da2f7dc94c..231e6fbbf6bc 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -337,7 +337,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
index 62d913a7c0d7..0aaa3e6fe0aa 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -875,6 +875,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/File.cs
index e6c3a7cd844f..598363737a5e 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 433035256031..74bfbfa1b1ec 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Foo.cs
index 9da199ab2477..ab3a41f87790 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 8e9bba64db14..5d64e47dc7f5 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
index 7c655b0827f2..b489e77a1e15 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
index ca703d27f96c..a73048ec0ad1 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
index c3c2a4e247ab..7071fe00f86d 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index f8b20bd77658..4703397c61b3 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/List.cs
index d6ac694585ca..b65cac7456c4 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e0e39a3acce3..4b1007e9aaf5 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
index 41b65bf5bc38..b5cdc783088c 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
@@ -310,16 +310,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 42247df00c07..57207f29ddb1 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a8f039e97905..c3a43f3fc745 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index c54becfdc303..1d5a4defe637 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
index ec25fab92034..c1fbf300b336 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
index a78b4b9ae3a8..bb2913f5df66 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
index 9135c0e022ad..f4acaf49d8f1 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Name.cs
index e3a0ef4d62fc..19757fa1c327 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
index b83140b058a7..0c4818c0bff4 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
index 21b40632deb7..428f234deaeb 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index a6be5066e8cd..d8bd9f36ea39 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Order.cs
index 43827461cc02..d3f99122b153 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Order.cs
@@ -384,6 +384,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
index 994ccd227bef..93be59d99690 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Pet.cs
index 41de214278b4..6d3d8121e68c 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Pet.cs
@@ -371,17 +371,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 495b0d273f6a..ddd15217fc1f 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
index bda0936c7e46..50d69fccab91 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2235,17 +2235,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Result.cs
index 3d22bb06491f..b57d0b4c7e8e 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Return.cs
index 184ad3ab12c4..c4b5b9636bb3 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index d67bf5ddc948..9b73fae206ff 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 27c3871866be..22702cfaa178 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
index a24895d6f930..9b3bfdab8bcf 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Tag.cs
index ce29344d2cdf..9ac1082f742a 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 764f36716e27..b48698e26e70 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index d6de3eb2c298..4d1c9e06a24f 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
index 3b7c69765ecd..a28ece650979 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -289,9 +289,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a09ec60e3535..5bd2ec9a6bba 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
index e023fb8f77fc..5abf98b1e65b 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/User.cs
index dc078c480cbc..90deb77dbaaa 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Whale.cs
index 02655307d760..1cdb5bad9dd1 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
index 26ed2ec21c31..8bd6f70f0a95 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
@@ -280,8 +280,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 18dfbaafaf8c..0f0d25e333db 100644
--- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -247,6 +247,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 80dce6546255..14a5655c8023 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
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 b609046e8738..06c18ced2a1c 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
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 cd282ab084bb..d4e0bd11b830 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
@@ -337,25 +337,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
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 2fa4fe8d9972..6861539d48cb 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
@@ -224,7 +224,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
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 f0ae4ef850cb..6895b23c9654 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
@@ -223,11 +223,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
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 edbe669c8994..ed26f278fc46 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
@@ -254,13 +254,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
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 0b270e3d4ebb..95c14d25d542 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
@@ -189,8 +189,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
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 6351ae775d17..270d77309df1 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
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 f1d13b9ea264..c2fbcd6a7e57 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
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 6fe159c3a522..877795d5cfd4 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
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
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 c35241ce3891..fd95bd629bbe 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
@@ -177,6 +177,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
}
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 5639dd362d9b..afdff1b19be1 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
@@ -189,6 +189,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
index 04f114d2c52d..d2b0f9fc8e45 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
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 b1ad2e90a31e..26ea3730fba7 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
@@ -294,22 +294,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
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 306e5e5f4010..c44fc9083169 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
@@ -180,7 +180,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
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 60daf384a42b..9795a7beec1b 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
@@ -196,8 +196,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value!.Value);
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 61e9f0c189bc..77c923435187 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
@@ -239,7 +239,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
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 187afe4824bb..90236769cb4a 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index a7184463a89b..d1828daed8ba 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
index b5df3dc0625e..7c1c3f7fe287 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -234,9 +234,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
index 130e644a578d..94e9213fe899 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
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 38bca8c661f8..60ef9165d975 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
@@ -183,6 +183,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
}
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 06763ca2d13c..4b96563e3461 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
index 4547aa00e1c6..48aba268c5b9 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
index 5c2a73bce3fd..aae60577a78f 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
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 ad6546f5ed2e..f43fe465b65a 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
@@ -180,10 +180,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
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 c842739103d3..d26192a1adba 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
@@ -241,10 +241,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
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 ec67776ec0a4..5c6eccf09721 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
@@ -340,7 +340,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
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 534039c94588..57e8cd61d373 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
@@ -878,6 +878,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index c10e5ccee004..a4d6ad4c2f68 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
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 ddeebaa52e17..c26fe4f172ce 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
@@ -179,7 +179,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
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 d90772377b69..77eeacd1bfce 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
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 c0fff6bbf2db..a26bca0b15d4 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
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 b0493a92bcf0..23d6edaccb8c 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
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 a2a69a9962fb..bc64a259b1eb 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
@@ -954,32 +954,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
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 9bad6c70417c..b9adf9d71cc8 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
@@ -222,7 +222,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 2dff0e74d24c..a2198a7ec32a 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
@@ -239,7 +239,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
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 716fb2ec240c..098874540247 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
@@ -242,10 +242,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 4682d88e6894..f14013f65705 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -340,22 +340,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index d936a509fa55..261267b6c02f 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
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 0af9622c0f0c..d6cd61b8668e 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-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 0b811f15795c..3de1c9b7ebc5 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
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 57ff0614c54e..a8ff51c976de 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
@@ -313,16 +313,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
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 93d9cddbe354..93b19a688f74 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
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 2f853d145282..f79216144534 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
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 da7a9e873433..2a2d05afb5bf 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
@@ -258,8 +258,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
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 3ee3e91634c4..e9036f7546d3 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
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 8ed7851b3215..4538cb6884df 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
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 bac5b01c0825..357ce5b2d143 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
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 56ab59544304..37f41d119044 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
@@ -284,7 +284,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 8f71e4492518..358f13e8de5f 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -192,9 +192,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
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 b24440849590..5bf7c08c2823 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
@@ -411,10 +411,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
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 46933a2fbf95..b051d11b1761 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
@@ -177,6 +177,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
}
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 3602dfda1310..e041d875bc51 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
@@ -250,13 +250,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
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 c4a7ebd764c5..5a9d1362547d 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
@@ -387,6 +387,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
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 0c0d0abd343f..4a94f026f474 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
@@ -223,8 +223,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
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 ad57645de2f5..4e7c71f8a59d 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
@@ -374,17 +374,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 63195ad709ae..ac2b8e61cd67 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
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 b411dc6e9d33..8a93f3022a91 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
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
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 41a2c79c34d6..599aa94d5e5e 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
@@ -2238,17 +2238,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
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 02d0d8c34c20..5e2d71377d97 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
@@ -227,13 +227,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
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 6ac928d7c6b8..36c27ec413ed 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
@@ -235,11 +235,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
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 9c544ea876ee..bbaefb23e8b7 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
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 b1122b96b779..e292a138c48e 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 6e5cff7d75a8..9e866915b32f 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
index 94079e588b26..5aedd501c226 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 794c35454611..e7ed21a8c3ca 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
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 1e1b860dedd7..edf8a9edcacf 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
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 df7dabd4bbb6..a5f86d17a002 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
@@ -200,8 +200,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value!.Value);
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 b42fcd243ecc..508388831ad1 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
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 5e985a42157a..cdd78842b091 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
index 6b0ee1bbe913..7410185d15aa 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -292,9 +292,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
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 9c65047ab818..41fcb61c7c76 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
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 d935ee12b186..eee7fb7736e2 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
@@ -225,11 +225,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 78caa9c95ad1..20b576d5efbd 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
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 01aeeb13e1de..2589af030b24 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
@@ -427,25 +427,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
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 89658a5314c9..a55ad54be20d 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
@@ -219,8 +219,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
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 3d814ffc0b00..143976f6b272 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
@@ -283,8 +283,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
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 98e4d7afdbfd..733adac3c5c4 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
@@ -250,6 +250,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 7027a58c996a..f8d7a66197ae 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
@@ -201,6 +201,12 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res
///
public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions)
{
+ if (nowGet200Response.NowOption.IsSet && nowGet200Response.Now == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Now to non-nullable JSON property 'now'.");
+
+ if (nowGet200Response.TodayOption.IsSet && nowGet200Response.Today == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Today to non-nullable JSON property 'today'.");
+
if (nowGet200Response.NowOption.IsSet)
writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs
index 199c6bc71de3..7c252ba330b0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs
@@ -182,13 +182,13 @@ 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.");
+ throw new JsonException("Cannot write null property Adult.Children to non-nullable JSON property 'children'.");
if (adult.FirstNameOption.IsSet && adult.FirstName == null)
- throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.FirstName to non-nullable JSON property 'firstName'.");
if (adult.LastNameOption.IsSet && adult.LastName == null)
- throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.LastName to non-nullable JSON property 'lastName'.");
if (adult.ChildrenOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Child.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Child.cs
index ce3a88b9d5b7..3724280d3572 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Child.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Child.cs
@@ -204,11 +204,17 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
+ if (child.AgeOption.IsSet && child.Age == null)
+ throw new JsonException("Cannot write null property Child.Age to non-nullable JSON property 'age'.");
+
+ if (child.BoosterSeatOption.IsSet && child.BoosterSeat == null)
+ throw new JsonException("Cannot write null property Child.BoosterSeat to non-nullable JSON property 'boosterSeat'.");
+
if (child.FirstNameOption.IsSet && child.FirstName == null)
- throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.FirstName to non-nullable JSON property 'firstName'.");
if (child.LastNameOption.IsSet && child.LastName == null)
- throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.LastName to non-nullable JSON property 'lastName'.");
if (child.AgeOption.IsSet)
writer.WriteNumber("age", child.AgeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Person.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Person.cs
index 55e576ab5dab..fea620444347 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Person.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Person.cs
@@ -241,10 +241,10 @@ 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.");
+ throw new JsonException("Cannot write null property Person.FirstName to non-nullable JSON property 'firstName'.");
if (person.LastNameOption.IsSet && person.LastName == null)
- throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
+ throw new JsonException("Cannot write null property Person.LastName to non-nullable JSON property 'lastName'.");
if (person.FirstNameOption.IsSet)
writer.WriteString("firstName", person.FirstName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
index a515b6a46baf..20d70a152cc9 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
index bd5cbb6316bb..146ac2da958d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
index 0b53a273b3d9..5ccdcf14a13d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -243,7 +243,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
index cc733fa3ac1b..136b36a89958 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
@@ -174,7 +174,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
index 9bb8141992a2..4e5dcd6f057e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
@@ -173,6 +173,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
index ea61a294a465..6d5e8f1779c9 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
@@ -242,7 +242,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Activity.cs
index bf0ea857b8b2..6ef65dc03490 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 3eaef3fdb68a..0900bb21d987 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index e2bc7e5c95e3..1ea3cc6d6d13 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Animal.cs
index 6b2c354e9d0c..af30b50b1efd 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
index a3bb92ba8e56..891117de444d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Apple.cs
index c0b3b74eccb6..415d977cb273 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
index b1a035bf1427..a8bb9970d266 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 8d4e9cf9a280..cf982fbeaccc 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 61678ca8a262..9a0450a54939 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
index 5ca882e055d9..946aa81707b4 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Banana.cs
index 6e96c0db4a48..1963adefce90 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
index 6e639dde3a6c..d88783cbab2d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
index 1734a7d71bbe..35fa5c799fe0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Cat.cs
index 07d7a0a7ce17..dbf7d5878726 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Category.cs
index ee17225920da..c33db720faab 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
index 1c2be23372b9..fffbe391d3d5 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
writer.WriteString("pet_type", ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
index 55e14e4e7e7d..2cec4e3ee767 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
index 2a75237fd09f..8d25c498e494 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 12f63bed52c3..f272f800a65b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index cea3eed9a750..5b795e143682 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
index 4386ed6689ff..5b8587c218e1 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
index d0974d2d3ae9..82cc312ea062 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Dog.cs
index ea0b4d3071f1..8f43963d5b4f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
index 0c6925ca0e37..2bf745f2f7d4 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
index ce7fece13a24..96c5f9bbb699 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
index 3369cd18ea98..3ed05af68273 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -351,6 +351,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/File.cs
index ee5463fb46f9..f3b89016ca8c 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index e129b109115f..70c50972598e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Foo.cs
index 77a9cd5f82b8..0bde70e7d10c 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 73a4dbbcaf22..6f6db2d948a2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
index 3156ed4239ce..b16df5f518e0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
index ba5d85932b34..e6781b1c920b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
index 6d9269ff3873..2df46dde14c4 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 62dc7cbf449c..4655c9cbb01e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/List.cs
index 43d2716ec68c..0ba836f7be5f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 8be2841ce1c9..4e22fe711e2a 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
index b49dc01adc4b..3b1494e797da 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
@@ -244,16 +244,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 0c8cceae99d0..90526549ac2b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a9e0341e6431..2376786bd50e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3229c397c986..d406287f4039 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
index d89d53fe55c9..2220371abceb 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
index aac8654e884b..09990a706a8c 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
index 90ac80d193a6..64b5da999734 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Name.cs
index b487237e70e3..f657f42be0ab 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
index 1e08ccc57034..ba9cfa507092 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
index 1a88e07e0def..209be6be1047 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index 047b1dcde4d2..7881bc48f66e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Order.cs
index b473008f6282..5db132a9cff4 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Order.cs
@@ -295,6 +295,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
index 686d151558e0..448c538f19d8 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pet.cs
index 4ec1f5d1af2e..de88b51a5ecf 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pet.cs
@@ -282,17 +282,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 42af39d72901..6c679f4eadf0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
index 696f05a1a694..d756563bf256 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -1053,17 +1053,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Result.cs
index dd616a09ce41..7ed1ea210629 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Return.cs
index cabc503d20d8..6870e58a4e5b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index b074a36ee24f..88ac872eba81 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 3018f5c27f8f..7ac7e71cbc15 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 07924a0aa49a..b6bcd6886413 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Tag.cs
index 9512c15160f5..d0d4298cab55 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 3a19c8ecaffb..db057bf9b74f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index a5b3a7caf550..e7b97dd14788 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
index e77c43ecd5d4..c5b9db5913dd 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -216,9 +216,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendantsObjectTypeValueConverter.ToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a8630ed8db3c..b2ef6e096109 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
index 15113add0df2..e367448c907f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/User.cs
index f3ea6b22b2af..dd4db4f456f1 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Whale.cs
index 08d6186ad435..c1abfbfd12c0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
index 6741e280d536..6ee3d041ef55 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 41660a9d61d1..3ad9a7fbd48a 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClassZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnumClass.ZeroBasedEnum.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Apple.cs
index a515b6a46baf..20d70a152cc9 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Banana.cs
index bd5cbb6316bb..146ac2da958d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
index e2e2f33c524d..bf55b771e444 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -250,7 +250,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Orange.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Orange.cs
index 938469b8ca38..ea6d4f8d915d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Orange.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Orange.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
+ if (orange.SweetOption.IsSet && orange.Sweet == null)
+ throw new JsonException("Cannot write null property Orange.Sweet to non-nullable JSON property 'sweet'.");
+
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Activity.cs
index bf0ea857b8b2..6ef65dc03490 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 3eaef3fdb68a..0900bb21d987 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index e2bc7e5c95e3..1ea3cc6d6d13 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Animal.cs
index 6b2c354e9d0c..af30b50b1efd 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
index a3bb92ba8e56..891117de444d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Apple.cs
index c0b3b74eccb6..415d977cb273 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
index b1a035bf1427..a8bb9970d266 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 8d4e9cf9a280..cf982fbeaccc 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 61678ca8a262..9a0450a54939 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
index 5ca882e055d9..946aa81707b4 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Banana.cs
index 6e96c0db4a48..1963adefce90 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
index 6e639dde3a6c..d88783cbab2d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
index 1734a7d71bbe..35fa5c799fe0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Cat.cs
index 07d7a0a7ce17..dbf7d5878726 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Category.cs
index ee17225920da..c33db720faab 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
index 711470ca3a83..0df505327662 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
index 55e14e4e7e7d..2cec4e3ee767 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
index 73f65a894734..790b30d0598c 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -231,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 12f63bed52c3..f272f800a65b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index cea3eed9a750..5b795e143682 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
index 8abf3f5844d0..00e11bca0df2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
index 5484c2ec84ad..3ad11787dcb3 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Dog.cs
index ea0b4d3071f1..8f43963d5b4f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
index 0c6925ca0e37..2bf745f2f7d4 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
index e04f4f594f2b..75fc3819ecf1 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -337,7 +337,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
index 4f4100fc359e..bd1502d4326b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -875,6 +875,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/File.cs
index ee5463fb46f9..f3b89016ca8c 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index e129b109115f..70c50972598e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Foo.cs
index 77a9cd5f82b8..0bde70e7d10c 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 73a4dbbcaf22..6f6db2d948a2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
index 3156ed4239ce..b16df5f518e0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
index ba5d85932b34..e6781b1c920b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
index 6d9269ff3873..2df46dde14c4 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 62dc7cbf449c..4655c9cbb01e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/List.cs
index 43d2716ec68c..0ba836f7be5f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 8be2841ce1c9..4e22fe711e2a 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
index 21cad314eb1d..c216c04d6468 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
@@ -310,16 +310,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 0c8cceae99d0..90526549ac2b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a9e0341e6431..2376786bd50e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3229c397c986..d406287f4039 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
index d89d53fe55c9..2220371abceb 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
index aac8654e884b..09990a706a8c 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
index 90ac80d193a6..64b5da999734 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Name.cs
index b487237e70e3..f657f42be0ab 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
index 1e08ccc57034..ba9cfa507092 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
index 1a88e07e0def..209be6be1047 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index 047b1dcde4d2..7881bc48f66e 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Order.cs
index 76ffea5c5ab4..4d4a6167efc2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Order.cs
@@ -384,6 +384,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
index 686d151558e0..448c538f19d8 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pet.cs
index cab3ba9dbf6e..d8bb45eae944 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pet.cs
@@ -371,17 +371,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 42af39d72901..6c679f4eadf0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
index 01ceaaae2c51..a5e6b6f451b2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2235,17 +2235,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Result.cs
index dd616a09ce41..7ed1ea210629 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Return.cs
index cabc503d20d8..6870e58a4e5b 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index b074a36ee24f..88ac872eba81 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 3018f5c27f8f..7ac7e71cbc15 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 07924a0aa49a..b6bcd6886413 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Tag.cs
index 9512c15160f5..d0d4298cab55 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 3a19c8ecaffb..db057bf9b74f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index a5b3a7caf550..e7b97dd14788 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
index 3b7c69765ecd..a28ece650979 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -289,9 +289,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a8630ed8db3c..b2ef6e096109 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
index 15113add0df2..e367448c907f 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/User.cs
index f3ea6b22b2af..dd4db4f456f1 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Whale.cs
index 08d6186ad435..c1abfbfd12c0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
index bc1f99da6d94..c6144e93c73d 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
@@ -280,8 +280,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index e8cf530a9235..4ce3561c85ec 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -247,6 +247,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
index c5c17f671b68..1fbff79470fe 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
@@ -199,6 +199,12 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res
///
public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions)
{
+ if (nowGet200Response.NowOption.IsSet && nowGet200Response.Now == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Now to non-nullable JSON property 'now'.");
+
+ if (nowGet200Response.TodayOption.IsSet && nowGet200Response.Today == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Today to non-nullable JSON property 'today'.");
+
if (nowGet200Response.NowOption.IsSet)
writer.WriteString("now", nowGet200Response.NowOption.Value.Value.ToString(NowFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Adult.cs b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Adult.cs
index 199c6bc71de3..7c252ba330b0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Adult.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Adult.cs
@@ -182,13 +182,13 @@ 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.");
+ throw new JsonException("Cannot write null property Adult.Children to non-nullable JSON property 'children'.");
if (adult.FirstNameOption.IsSet && adult.FirstName == null)
- throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.FirstName to non-nullable JSON property 'firstName'.");
if (adult.LastNameOption.IsSet && adult.LastName == null)
- throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.LastName to non-nullable JSON property 'lastName'.");
if (adult.ChildrenOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Child.cs b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Child.cs
index ce3a88b9d5b7..3724280d3572 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Child.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Child.cs
@@ -204,11 +204,17 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
+ if (child.AgeOption.IsSet && child.Age == null)
+ throw new JsonException("Cannot write null property Child.Age to non-nullable JSON property 'age'.");
+
+ if (child.BoosterSeatOption.IsSet && child.BoosterSeat == null)
+ throw new JsonException("Cannot write null property Child.BoosterSeat to non-nullable JSON property 'boosterSeat'.");
+
if (child.FirstNameOption.IsSet && child.FirstName == null)
- throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.FirstName to non-nullable JSON property 'firstName'.");
if (child.LastNameOption.IsSet && child.LastName == null)
- throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.LastName to non-nullable JSON property 'lastName'.");
if (child.AgeOption.IsSet)
writer.WriteNumber("age", child.AgeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Person.cs b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Person.cs
index 55e576ab5dab..fea620444347 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Person.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AllOf/src/Org.OpenAPITools/Model/Person.cs
@@ -241,10 +241,10 @@ 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.");
+ throw new JsonException("Cannot write null property Person.FirstName to non-nullable JSON property 'firstName'.");
if (person.LastNameOption.IsSet && person.LastName == null)
- throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
+ throw new JsonException("Cannot write null property Person.LastName to non-nullable JSON property 'lastName'.");
if (person.FirstNameOption.IsSet)
writer.WriteString("firstName", person.FirstName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
index a515b6a46baf..20d70a152cc9 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
index bd5cbb6316bb..146ac2da958d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
index 0b53a273b3d9..5ccdcf14a13d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -243,7 +243,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
index cc733fa3ac1b..136b36a89958 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
@@ -174,7 +174,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
index 9bb8141992a2..4e5dcd6f057e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
@@ -173,6 +173,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
index ea61a294a465..6d5e8f1779c9 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
@@ -242,7 +242,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Activity.cs
index bf0ea857b8b2..6ef65dc03490 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 3eaef3fdb68a..0900bb21d987 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index e2bc7e5c95e3..1ea3cc6d6d13 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Animal.cs
index 6b2c354e9d0c..af30b50b1efd 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
index a3bb92ba8e56..891117de444d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Apple.cs
index c0b3b74eccb6..415d977cb273 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
index b1a035bf1427..a8bb9970d266 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 8d4e9cf9a280..cf982fbeaccc 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 61678ca8a262..9a0450a54939 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
index 5ca882e055d9..946aa81707b4 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Banana.cs
index 6e96c0db4a48..1963adefce90 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
index 6e639dde3a6c..d88783cbab2d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
index 1734a7d71bbe..35fa5c799fe0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Cat.cs
index 07d7a0a7ce17..dbf7d5878726 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Category.cs
index ee17225920da..c33db720faab 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
index 1c2be23372b9..fffbe391d3d5 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
writer.WriteString("pet_type", ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
index 55e14e4e7e7d..2cec4e3ee767 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
index 2a75237fd09f..8d25c498e494 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 12f63bed52c3..f272f800a65b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index cea3eed9a750..5b795e143682 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
index 4386ed6689ff..5b8587c218e1 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
index d0974d2d3ae9..82cc312ea062 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Dog.cs
index ea0b4d3071f1..8f43963d5b4f 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
index 0c6925ca0e37..2bf745f2f7d4 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
index ce7fece13a24..96c5f9bbb699 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
index 3369cd18ea98..3ed05af68273 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -351,6 +351,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/File.cs
index ee5463fb46f9..f3b89016ca8c 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index e129b109115f..70c50972598e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Foo.cs
index 77a9cd5f82b8..0bde70e7d10c 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 73a4dbbcaf22..6f6db2d948a2 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
index 3156ed4239ce..b16df5f518e0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
index ba5d85932b34..e6781b1c920b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
index 6d9269ff3873..2df46dde14c4 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 62dc7cbf449c..4655c9cbb01e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/List.cs
index 43d2716ec68c..0ba836f7be5f 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 8be2841ce1c9..4e22fe711e2a 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
index b49dc01adc4b..3b1494e797da 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
@@ -244,16 +244,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 0c8cceae99d0..90526549ac2b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a9e0341e6431..2376786bd50e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3229c397c986..d406287f4039 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
index d89d53fe55c9..2220371abceb 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
index aac8654e884b..09990a706a8c 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
index 90ac80d193a6..64b5da999734 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Name.cs
index b487237e70e3..f657f42be0ab 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
index 1e08ccc57034..ba9cfa507092 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
index 1a88e07e0def..209be6be1047 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index 047b1dcde4d2..7881bc48f66e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Order.cs
index b473008f6282..5db132a9cff4 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Order.cs
@@ -295,6 +295,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
index 686d151558e0..448c538f19d8 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Pet.cs
index 4ec1f5d1af2e..de88b51a5ecf 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Pet.cs
@@ -282,17 +282,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 42af39d72901..6c679f4eadf0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
index 696f05a1a694..d756563bf256 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -1053,17 +1053,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Result.cs
index dd616a09ce41..7ed1ea210629 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Return.cs
index cabc503d20d8..6870e58a4e5b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index b074a36ee24f..88ac872eba81 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 3018f5c27f8f..7ac7e71cbc15 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 07924a0aa49a..b6bcd6886413 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Tag.cs
index 9512c15160f5..d0d4298cab55 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 3a19c8ecaffb..db057bf9b74f 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index a5b3a7caf550..e7b97dd14788 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
index e77c43ecd5d4..c5b9db5913dd 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -216,9 +216,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendantsObjectTypeValueConverter.ToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a8630ed8db3c..b2ef6e096109 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
index 15113add0df2..e367448c907f 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/User.cs
index f3ea6b22b2af..dd4db4f456f1 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Whale.cs
index 08d6186ad435..c1abfbfd12c0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
index 6741e280d536..6ee3d041ef55 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 41660a9d61d1..3ad9a7fbd48a 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClassZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnumClass.ZeroBasedEnum.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Apple.cs
index a515b6a46baf..20d70a152cc9 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Banana.cs
index bd5cbb6316bb..146ac2da958d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
index e2e2f33c524d..bf55b771e444 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -250,7 +250,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Orange.cs b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Orange.cs
index 938469b8ca38..ea6d4f8d915d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Orange.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/OneOf/src/Org.OpenAPITools/Model/Orange.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
+ if (orange.SweetOption.IsSet && orange.Sweet == null)
+ throw new JsonException("Cannot write null property Orange.Sweet to non-nullable JSON property 'sweet'.");
+
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Activity.cs
index bf0ea857b8b2..6ef65dc03490 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 3eaef3fdb68a..0900bb21d987 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index e2bc7e5c95e3..1ea3cc6d6d13 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Animal.cs
index 6b2c354e9d0c..af30b50b1efd 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
index a3bb92ba8e56..891117de444d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Apple.cs
index c0b3b74eccb6..415d977cb273 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
index b1a035bf1427..a8bb9970d266 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 8d4e9cf9a280..cf982fbeaccc 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 61678ca8a262..9a0450a54939 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
index 5ca882e055d9..946aa81707b4 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Banana.cs
index 6e96c0db4a48..1963adefce90 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
index 6e639dde3a6c..d88783cbab2d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
index 1734a7d71bbe..35fa5c799fe0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Cat.cs
index 07d7a0a7ce17..dbf7d5878726 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Category.cs
index ee17225920da..c33db720faab 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
index 711470ca3a83..0df505327662 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
index 55e14e4e7e7d..2cec4e3ee767 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
index 73f65a894734..790b30d0598c 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -231,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 12f63bed52c3..f272f800a65b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index cea3eed9a750..5b795e143682 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
index 8abf3f5844d0..00e11bca0df2 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
index 5484c2ec84ad..3ad11787dcb3 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Dog.cs
index ea0b4d3071f1..8f43963d5b4f 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
index 0c6925ca0e37..2bf745f2f7d4 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
index e04f4f594f2b..75fc3819ecf1 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -337,7 +337,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
index 4f4100fc359e..bd1502d4326b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -875,6 +875,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/File.cs
index ee5463fb46f9..f3b89016ca8c 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index e129b109115f..70c50972598e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Foo.cs
index 77a9cd5f82b8..0bde70e7d10c 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 73a4dbbcaf22..6f6db2d948a2 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
index 3156ed4239ce..b16df5f518e0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
index ba5d85932b34..e6781b1c920b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
index 6d9269ff3873..2df46dde14c4 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 62dc7cbf449c..4655c9cbb01e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/List.cs
index 43d2716ec68c..0ba836f7be5f 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 8be2841ce1c9..4e22fe711e2a 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
index 21cad314eb1d..c216c04d6468 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
@@ -310,16 +310,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 0c8cceae99d0..90526549ac2b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a9e0341e6431..2376786bd50e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3229c397c986..d406287f4039 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
index d89d53fe55c9..2220371abceb 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
index aac8654e884b..09990a706a8c 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
index 90ac80d193a6..64b5da999734 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Name.cs
index b487237e70e3..f657f42be0ab 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
index 1e08ccc57034..ba9cfa507092 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
index 1a88e07e0def..209be6be1047 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index 047b1dcde4d2..7881bc48f66e 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Order.cs
index 76ffea5c5ab4..4d4a6167efc2 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Order.cs
@@ -384,6 +384,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
index 686d151558e0..448c538f19d8 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Pet.cs
index cab3ba9dbf6e..d8bb45eae944 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Pet.cs
@@ -371,17 +371,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 42af39d72901..6c679f4eadf0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
index 01ceaaae2c51..a5e6b6f451b2 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2235,17 +2235,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Result.cs
index dd616a09ce41..7ed1ea210629 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Return.cs
index cabc503d20d8..6870e58a4e5b 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index b074a36ee24f..88ac872eba81 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 3018f5c27f8f..7ac7e71cbc15 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 07924a0aa49a..b6bcd6886413 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Tag.cs
index 9512c15160f5..d0d4298cab55 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 3a19c8ecaffb..db057bf9b74f 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index a5b3a7caf550..e7b97dd14788 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
index 3b7c69765ecd..a28ece650979 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -289,9 +289,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a8630ed8db3c..b2ef6e096109 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
index 15113add0df2..e367448c907f 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/User.cs
index f3ea6b22b2af..dd4db4f456f1 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Whale.cs
index 08d6186ad435..c1abfbfd12c0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
index bc1f99da6d94..c6144e93c73d 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
@@ -280,8 +280,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index e8cf530a9235..4ce3561c85ec 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -247,6 +247,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
diff --git a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
index c5c17f671b68..1fbff79470fe 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
@@ -199,6 +199,12 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res
///
public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions)
{
+ if (nowGet200Response.NowOption.IsSet && nowGet200Response.Now == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Now to non-nullable JSON property 'now'.");
+
+ if (nowGet200Response.TodayOption.IsSet && nowGet200Response.Today == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Today to non-nullable JSON property 'today'.");
+
if (nowGet200Response.NowOption.IsSet)
writer.WriteString("now", nowGet200Response.NowOption.Value.Value.ToString(NowFormat));
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 eb8cbd0b3bc5..4213420714a8 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
@@ -184,13 +184,13 @@ 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.");
+ throw new JsonException("Cannot write null property Adult.Children to non-nullable JSON property 'children'.");
if (adult.FirstNameOption.IsSet && adult.FirstName == null)
- throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.FirstName to non-nullable JSON property 'firstName'.");
if (adult.LastNameOption.IsSet && adult.LastName == null)
- throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.LastName to non-nullable JSON property 'lastName'.");
if (adult.ChildrenOption.IsSet)
{
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 cc9001600c71..f71f244652dc 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
@@ -206,11 +206,17 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
+ if (child.AgeOption.IsSet && child.Age == null)
+ throw new JsonException("Cannot write null property Child.Age to non-nullable JSON property 'age'.");
+
+ if (child.BoosterSeatOption.IsSet && child.BoosterSeat == null)
+ throw new JsonException("Cannot write null property Child.BoosterSeat to non-nullable JSON property 'boosterSeat'.");
+
if (child.FirstNameOption.IsSet && child.FirstName == null)
- throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.FirstName to non-nullable JSON property 'firstName'.");
if (child.LastNameOption.IsSet && child.LastName == null)
- throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.LastName to non-nullable JSON property 'lastName'.");
if (child.AgeOption.IsSet)
writer.WriteNumber("age", child.AgeOption.Value!.Value);
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 e5e63ec9c2a5..e65419a3b600 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
@@ -243,10 +243,10 @@ 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.");
+ throw new JsonException("Cannot write null property Person.FirstName to non-nullable JSON property 'firstName'.");
if (person.LastNameOption.IsSet && person.LastName == null)
- throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
+ throw new JsonException("Cannot write null property Person.LastName to non-nullable JSON property 'lastName'.");
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 ba3ebde0806b..e6e5bf9b1853 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 ddd75420f237..65dc4a02463e 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 a552837a0067..9ccac387b196 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
@@ -245,7 +245,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 6d957f4666fe..ba2d70c2fab5 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
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 b31f8fe51330..7b0cc8bc8756 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
@@ -175,6 +175,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 b23a45484ba3..c7ad4a614836 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
@@ -244,7 +244,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Activity.cs
index 8883f1323639..2fb20fd76ba8 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index a7ae93ee504a..a7c053f968ff 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 4c9fc1cad5f2..2d355959392c 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Animal.cs
index 117be25b4c3f..90faf3ed2ad0 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
index 5a61538e1f17..332e1e100ce2 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Apple.cs
index ead5728d626b..8559896f3b99 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
index bd8cd61c4221..cc81766fcebe 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 850a9c376b5a..9a6a9cb6326c 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 2e5eb229f1c3..1b911bc1d6c0 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
index 2b63506f4b44..e42133d4a724 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Banana.cs
index 40d370fd1cdb..d887a45c931e 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
index 0673de456831..db3b3f2aabd1 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
index ea23cb6d7166..57decedb097c 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Cat.cs
index 9ff7be2175c6..f3f27956ed3b 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Category.cs
index b977a0ca50b9..d78edc3ee72c 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
index db3c3064f4e2..46fc753b3481 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
writer.WriteString("pet_type", ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType));
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
index 4d1213df9a8d..012fb4ea1848 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
index 2a75237fd09f..8d25c498e494 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 2b1f5670dec1..72a7565ec3c6 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index a0a059430fbf..4e0d1370cc9a 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
index 4386ed6689ff..5b8587c218e1 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
index d0974d2d3ae9..82cc312ea062 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Dog.cs
index e4066eb72582..5d01cd38ebbe 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
index fce60664f896..b1c4e76fe748 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
index a954055cecef..ee70392a1686 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
index cab43b30299d..780950460e89 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -351,6 +351,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/File.cs
index e6c3a7cd844f..598363737a5e 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 433035256031..74bfbfa1b1ec 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Foo.cs
index 9da199ab2477..ab3a41f87790 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 8e9bba64db14..5d64e47dc7f5 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
index 7c655b0827f2..b489e77a1e15 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
index ca703d27f96c..a73048ec0ad1 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
index c3c2a4e247ab..7071fe00f86d 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index fbd98eae40a9..2f37dd2a61d9 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/List.cs
index d6ac694585ca..b65cac7456c4 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e0e39a3acce3..4b1007e9aaf5 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
index a416718859af..463b714170dd 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
@@ -244,16 +244,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 42247df00c07..57207f29ddb1 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a8f039e97905..c3a43f3fc745 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index c54becfdc303..1d5a4defe637 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
index ec25fab92034..c1fbf300b336 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
index a78b4b9ae3a8..bb2913f5df66 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
index 9135c0e022ad..f4acaf49d8f1 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Name.cs
index e3a0ef4d62fc..19757fa1c327 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
index b83140b058a7..0c4818c0bff4 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
index 21b40632deb7..428f234deaeb 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index a6be5066e8cd..d8bd9f36ea39 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Order.cs
index 79cfaaf0e5bf..66edef8216f7 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Order.cs
@@ -295,6 +295,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
index 994ccd227bef..93be59d99690 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pet.cs
index b94bf16627ff..f60a0987b590 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pet.cs
@@ -282,17 +282,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 495b0d273f6a..ddd15217fc1f 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
index b84dae9064af..eeda5ef0fcc7 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -1053,17 +1053,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Result.cs
index 3d22bb06491f..b57d0b4c7e8e 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Return.cs
index 184ad3ab12c4..c4b5b9636bb3 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index d67bf5ddc948..9b73fae206ff 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 27c3871866be..22702cfaa178 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
index a24895d6f930..9b3bfdab8bcf 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Tag.cs
index ce29344d2cdf..9ac1082f742a 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 764f36716e27..b48698e26e70 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index d6de3eb2c298..4d1c9e06a24f 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
index e77c43ecd5d4..c5b9db5913dd 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -216,9 +216,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendantsObjectTypeValueConverter.ToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a09ec60e3535..5bd2ec9a6bba 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
index e023fb8f77fc..5abf98b1e65b 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/User.cs
index dc078c480cbc..90deb77dbaaa 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Whale.cs
index 02655307d760..1cdb5bad9dd1 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
index 449736faed56..67b6d90eb1d7 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 9add0a06d4cc..ad7eadb1b479 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClassZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnumClass.ZeroBasedEnum.Value);
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 4103a73cd4f0..d43c6780ca28 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
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 adf86a28dcd0..23f5c4b3a85d 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
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 2c52c15ccdcc..ad641f68f2e9 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
@@ -336,25 +336,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
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 b5e2ed9ae27f..6344d530cd6e 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
@@ -223,7 +223,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
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 ffbd21ce4a6a..70585c8acf5b 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
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
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 0f80dc0d9c03..edd6e65f1f41 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
@@ -253,13 +253,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
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 a43c764f8240..a98f5bd8787f 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
@@ -188,8 +188,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
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 aef7d7e481d8..509645c3f350 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
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 93684cf9efc6..9d5c27336962 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
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 0b5b6d24743d..14d7950c4b6f 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
@@ -223,13 +223,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
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 fab250f7b537..0a7d794e23fc 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
}
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 42e9d1890af1..1973db4c4bed 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
@@ -188,6 +188,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
index a19a8488e044..8dbfb7552b5f 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
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 eb14befa97d3..68e8220438eb 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
@@ -293,22 +293,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
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 b1fedb233db5..0f47bd35e784 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
@@ -179,7 +179,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
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 97e28530372b..d411efbb83bd 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
@@ -195,8 +195,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value!.Value);
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 d99184db6550..d7c5a4cd96ec 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
@@ -238,7 +238,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
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 a7666cfb698a..16551511b256 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index cbc3e80b4a27..e1e504b538e1 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
index 77fc65981096..260d78873e2e 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -233,9 +233,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
index 6ee21a0298c9..ed6bc6534338 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
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 c04c4f439bdf..f39aa601716f 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
@@ -182,6 +182,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
}
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 0490d964f022..5e4782e9741b 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
index b78ed38fc503..68a2f65c9aff 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
index d4c4e6c2273c..5a130166a0b1 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
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 6908fb106b63..b8435f95759c 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
@@ -179,10 +179,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
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 74c2e0ae5d4b..cce96329e588 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
@@ -240,10 +240,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
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 3bcb6d9b4888..05f5e7db1d24 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
@@ -339,7 +339,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
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 647002803b89..62c8f51ce807 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
@@ -877,6 +877,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index bf25136ce8d5..407e33a7b6f5 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
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 668ebfa6c77c..6608c8f2c0e0 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
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 b29be867e838..d8837421dcac 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
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 98e50928aae1..4b75918a83d5 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
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 763577d494c8..baa4b149818a 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
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 d7ca66d7495a..1badd1c0d948 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
@@ -953,32 +953,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
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 ec0062ba20d3..f902f78034c4 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
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 039f5faedfc4..1eccb13e9003 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
@@ -238,7 +238,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
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 6fa1889a08bd..1a446ca46e5a 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
@@ -241,10 +241,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 962e2a3c1294..82b78a3e00f9 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -339,22 +339,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index fac6f52f2522..b211cf0586b1 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
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 aac40319978e..b8a8a257d0d2 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-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 027d4fde6be0..70963bef2fc5 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
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 3c7e075d574e..64474ff0d16d 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
@@ -312,16 +312,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
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 71af55e64992..48eca2b1e0b8 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
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 1536ccf00030..e5c9f6f2f2f7 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
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 d7d6068bcd10..1cef2917ba78 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
@@ -257,8 +257,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
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 7f178b026301..77c1611f8f80 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
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 2d6852d12c7e..ff4080153aea 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
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 0e9021c907a6..b32d7f964146 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
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 d54d7b7d29b5..8fd568be1a6b 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
@@ -283,7 +283,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 2e206a226911..10c8125b1068 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -191,9 +191,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
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 ea88ed18b540..d1327d7b480f 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
@@ -410,10 +410,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
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 fa2f63c11abf..a463ed4572d3 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
}
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 c858d1b3727b..03727598207c 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
@@ -249,13 +249,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
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 ac6f4585d259..ee4d0c85d40a 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
@@ -386,6 +386,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
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 6ed3bf816867..686aa2d77797 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
@@ -222,8 +222,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
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 6cd3a02b4296..5c16160c5db9 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
@@ -373,17 +373,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 33061272899b..bbd3a56b31ed 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
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 bb29062628a7..3b1999efb42d 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
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
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 d1f6c6f40209..1912f3c24ebf 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
@@ -2237,17 +2237,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
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 17f97f2387a3..a6bef2efe103 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
@@ -226,13 +226,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
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 02b3fdc639e2..fd9446247331 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
@@ -234,11 +234,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
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 affe88bd8aea..ac6dd43ef0b2 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
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 ed0af26e87fb..55d774689f49 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index ada72abaf3ad..f1779050584b 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
index 7d55af95627a..cb375197e488 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 48481ee56dfe..0034604725d0 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
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 7af87418b89f..81c58c98aa68 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
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 fbc5d4a9829e..a16ea726bfff 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
@@ -199,8 +199,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value!.Value);
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 dc66551a230d..182412d38e32 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
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 f297317601df..97b4b270f1c9 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
index c9e049a3db72..5b568b36e9ec 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -291,9 +291,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
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 32e069929830..07d98ed51393 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
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 1edb92ec63a9..d168aff8b9c2 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
@@ -224,11 +224,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 9fbc6b8085b5..c97244ab95ff 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
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 50de52ddebec..c6a4d2cddb86 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
@@ -426,25 +426,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
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 00e53f6dc690..74e3afd8dbf8 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
@@ -218,8 +218,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
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 a871ad34d76d..f6faea2fd5ed 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
@@ -282,8 +282,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
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 5e17279cd925..796310e1783f 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
@@ -249,6 +249,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 ba3ebde0806b..e6e5bf9b1853 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 ddd75420f237..65dc4a02463e 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 1a4743015087..af45459bafc7 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
@@ -252,7 +252,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 02e5aab13a27..793f5553239f 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
+ if (orange.SweetOption.IsSet && orange.Sweet == null)
+ throw new JsonException("Cannot write null property Orange.Sweet to non-nullable JSON property 'sweet'.");
+
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Activity.cs
index 8883f1323639..2fb20fd76ba8 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index a7ae93ee504a..a7c053f968ff 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 4c9fc1cad5f2..2d355959392c 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Animal.cs
index 117be25b4c3f..90faf3ed2ad0 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
index 5a61538e1f17..332e1e100ce2 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Apple.cs
index ead5728d626b..8559896f3b99 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
index bd8cd61c4221..cc81766fcebe 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 850a9c376b5a..9a6a9cb6326c 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 2e5eb229f1c3..1b911bc1d6c0 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
index 2b63506f4b44..e42133d4a724 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Banana.cs
index 40d370fd1cdb..d887a45c931e 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
index 0673de456831..db3b3f2aabd1 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
index ea23cb6d7166..57decedb097c 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Cat.cs
index 9ff7be2175c6..f3f27956ed3b 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Category.cs
index b977a0ca50b9..d78edc3ee72c 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
index aad251c4d9e7..d5e2a907d867 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
index 4d1213df9a8d..012fb4ea1848 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
index 73f65a894734..790b30d0598c 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -231,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 2b1f5670dec1..72a7565ec3c6 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index a0a059430fbf..4e0d1370cc9a 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
index 8abf3f5844d0..00e11bca0df2 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
index 5484c2ec84ad..3ad11787dcb3 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Dog.cs
index e4066eb72582..5d01cd38ebbe 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
index fce60664f896..b1c4e76fe748 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
index 45da2f7dc94c..231e6fbbf6bc 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -337,7 +337,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
index 62d913a7c0d7..0aaa3e6fe0aa 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -875,6 +875,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/File.cs
index e6c3a7cd844f..598363737a5e 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 433035256031..74bfbfa1b1ec 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Foo.cs
index 9da199ab2477..ab3a41f87790 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 8e9bba64db14..5d64e47dc7f5 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
index 7c655b0827f2..b489e77a1e15 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
index ca703d27f96c..a73048ec0ad1 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
index c3c2a4e247ab..7071fe00f86d 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index fbd98eae40a9..2f37dd2a61d9 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/List.cs
index d6ac694585ca..b65cac7456c4 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e0e39a3acce3..4b1007e9aaf5 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
index 41b65bf5bc38..b5cdc783088c 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
@@ -310,16 +310,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 42247df00c07..57207f29ddb1 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a8f039e97905..c3a43f3fc745 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index c54becfdc303..1d5a4defe637 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
index ec25fab92034..c1fbf300b336 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
index a78b4b9ae3a8..bb2913f5df66 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
index 9135c0e022ad..f4acaf49d8f1 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Name.cs
index e3a0ef4d62fc..19757fa1c327 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
index b83140b058a7..0c4818c0bff4 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
index 21b40632deb7..428f234deaeb 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index a6be5066e8cd..d8bd9f36ea39 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Order.cs
index 43827461cc02..d3f99122b153 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Order.cs
@@ -384,6 +384,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
index 994ccd227bef..93be59d99690 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pet.cs
index 41de214278b4..6d3d8121e68c 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pet.cs
@@ -371,17 +371,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 495b0d273f6a..ddd15217fc1f 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
index bda0936c7e46..50d69fccab91 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2235,17 +2235,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs
index 3d22bb06491f..b57d0b4c7e8e 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Return.cs
index 184ad3ab12c4..c4b5b9636bb3 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index d67bf5ddc948..9b73fae206ff 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 27c3871866be..22702cfaa178 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
index a24895d6f930..9b3bfdab8bcf 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Tag.cs
index ce29344d2cdf..9ac1082f742a 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 764f36716e27..b48698e26e70 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index d6de3eb2c298..4d1c9e06a24f 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
index 3b7c69765ecd..a28ece650979 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -289,9 +289,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a09ec60e3535..5bd2ec9a6bba 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
index e023fb8f77fc..5abf98b1e65b 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/User.cs
index dc078c480cbc..90deb77dbaaa 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Whale.cs
index 02655307d760..1cdb5bad9dd1 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
index 26ed2ec21c31..8bd6f70f0a95 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
@@ -280,8 +280,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 18dfbaafaf8c..0f0d25e333db 100644
--- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -247,6 +247,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 80dce6546255..14a5655c8023 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
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 b609046e8738..06c18ced2a1c 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
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 cd282ab084bb..d4e0bd11b830 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
@@ -337,25 +337,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
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 2fa4fe8d9972..6861539d48cb 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
@@ -224,7 +224,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
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 f0ae4ef850cb..6895b23c9654 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
@@ -223,11 +223,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
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 edbe669c8994..ed26f278fc46 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
@@ -254,13 +254,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
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 0b270e3d4ebb..95c14d25d542 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
@@ -189,8 +189,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
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 6351ae775d17..270d77309df1 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
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 f1d13b9ea264..c2fbcd6a7e57 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
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 6fe159c3a522..877795d5cfd4 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
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
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 c35241ce3891..fd95bd629bbe 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
@@ -177,6 +177,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
}
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 5639dd362d9b..afdff1b19be1 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
@@ -189,6 +189,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
index 04f114d2c52d..d2b0f9fc8e45 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
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 b1ad2e90a31e..26ea3730fba7 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
@@ -294,22 +294,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
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 306e5e5f4010..c44fc9083169 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
@@ -180,7 +180,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
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 60daf384a42b..9795a7beec1b 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
@@ -196,8 +196,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value!.Value);
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 61e9f0c189bc..77c923435187 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
@@ -239,7 +239,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
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 187afe4824bb..90236769cb4a 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index a7184463a89b..d1828daed8ba 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
index b5df3dc0625e..7c1c3f7fe287 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -234,9 +234,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
index 130e644a578d..94e9213fe899 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
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 38bca8c661f8..60ef9165d975 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
@@ -183,6 +183,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
}
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 06763ca2d13c..4b96563e3461 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
index 4547aa00e1c6..48aba268c5b9 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
index 5c2a73bce3fd..aae60577a78f 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
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 ad6546f5ed2e..f43fe465b65a 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
@@ -180,10 +180,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
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 c842739103d3..d26192a1adba 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
@@ -241,10 +241,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
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 ec67776ec0a4..5c6eccf09721 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
@@ -340,7 +340,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
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 534039c94588..57e8cd61d373 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
@@ -878,6 +878,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index c10e5ccee004..a4d6ad4c2f68 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
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 ddeebaa52e17..c26fe4f172ce 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
@@ -179,7 +179,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
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 d90772377b69..77eeacd1bfce 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
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 c0fff6bbf2db..a26bca0b15d4 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
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 b0493a92bcf0..23d6edaccb8c 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
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 a2a69a9962fb..bc64a259b1eb 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
@@ -954,32 +954,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
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 9bad6c70417c..b9adf9d71cc8 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
@@ -222,7 +222,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 2dff0e74d24c..a2198a7ec32a 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
@@ -239,7 +239,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
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 716fb2ec240c..098874540247 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
@@ -242,10 +242,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 4682d88e6894..f14013f65705 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -340,22 +340,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index d936a509fa55..261267b6c02f 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
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 0af9622c0f0c..d6cd61b8668e 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-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 0b811f15795c..3de1c9b7ebc5 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
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 57ff0614c54e..a8ff51c976de 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
@@ -313,16 +313,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
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 93d9cddbe354..93b19a688f74 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
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 2f853d145282..f79216144534 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
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 da7a9e873433..2a2d05afb5bf 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
@@ -258,8 +258,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
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 3ee3e91634c4..e9036f7546d3 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
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 8ed7851b3215..4538cb6884df 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
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 bac5b01c0825..357ce5b2d143 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
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 56ab59544304..37f41d119044 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
@@ -284,7 +284,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 8f71e4492518..358f13e8de5f 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -192,9 +192,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
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 b24440849590..5bf7c08c2823 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
@@ -411,10 +411,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
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 46933a2fbf95..b051d11b1761 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
@@ -177,6 +177,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
}
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 3602dfda1310..e041d875bc51 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
@@ -250,13 +250,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
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 c4a7ebd764c5..5a9d1362547d 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
@@ -387,6 +387,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
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 0c0d0abd343f..4a94f026f474 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
@@ -223,8 +223,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
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 ad57645de2f5..4e7c71f8a59d 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
@@ -374,17 +374,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 63195ad709ae..ac2b8e61cd67 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
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 b411dc6e9d33..8a93f3022a91 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
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
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 41a2c79c34d6..599aa94d5e5e 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
@@ -2238,17 +2238,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
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 02d0d8c34c20..5e2d71377d97 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
@@ -227,13 +227,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
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 6ac928d7c6b8..36c27ec413ed 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
@@ -235,11 +235,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
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 9c544ea876ee..bbaefb23e8b7 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
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 b1122b96b779..e292a138c48e 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 6e5cff7d75a8..9e866915b32f 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
index 94079e588b26..5aedd501c226 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 794c35454611..e7ed21a8c3ca 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
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 1e1b860dedd7..edf8a9edcacf 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
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 df7dabd4bbb6..a5f86d17a002 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
@@ -200,8 +200,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value!.Value);
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 b42fcd243ecc..508388831ad1 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
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 5e985a42157a..cdd78842b091 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
index 6b0ee1bbe913..7410185d15aa 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -292,9 +292,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
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 9c65047ab818..41fcb61c7c76 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
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 d935ee12b186..eee7fb7736e2 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
@@ -225,11 +225,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 78caa9c95ad1..20b576d5efbd 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
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 01aeeb13e1de..2589af030b24 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
@@ -427,25 +427,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
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 89658a5314c9..a55ad54be20d 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
@@ -219,8 +219,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
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 3d814ffc0b00..143976f6b272 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
@@ -283,8 +283,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
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 98e4d7afdbfd..733adac3c5c4 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
@@ -250,6 +250,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 7027a58c996a..f8d7a66197ae 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
@@ -201,6 +201,12 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res
///
public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions)
{
+ if (nowGet200Response.NowOption.IsSet && nowGet200Response.Now == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Now to non-nullable JSON property 'now'.");
+
+ if (nowGet200Response.TodayOption.IsSet && nowGet200Response.Today == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Today to non-nullable JSON property 'today'.");
+
if (nowGet200Response.NowOption.IsSet)
writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
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 eb8cbd0b3bc5..4213420714a8 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
@@ -184,13 +184,13 @@ 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.");
+ throw new JsonException("Cannot write null property Adult.Children to non-nullable JSON property 'children'.");
if (adult.FirstNameOption.IsSet && adult.FirstName == null)
- throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.FirstName to non-nullable JSON property 'firstName'.");
if (adult.LastNameOption.IsSet && adult.LastName == null)
- throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
+ throw new JsonException("Cannot write null property Adult.LastName to non-nullable JSON property 'lastName'.");
if (adult.ChildrenOption.IsSet)
{
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 cc9001600c71..f71f244652dc 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
@@ -206,11 +206,17 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
+ if (child.AgeOption.IsSet && child.Age == null)
+ throw new JsonException("Cannot write null property Child.Age to non-nullable JSON property 'age'.");
+
+ if (child.BoosterSeatOption.IsSet && child.BoosterSeat == null)
+ throw new JsonException("Cannot write null property Child.BoosterSeat to non-nullable JSON property 'boosterSeat'.");
+
if (child.FirstNameOption.IsSet && child.FirstName == null)
- throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.FirstName to non-nullable JSON property 'firstName'.");
if (child.LastNameOption.IsSet && child.LastName == null)
- throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
+ throw new JsonException("Cannot write null property Child.LastName to non-nullable JSON property 'lastName'.");
if (child.AgeOption.IsSet)
writer.WriteNumber("age", child.AgeOption.Value!.Value);
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 e5e63ec9c2a5..e65419a3b600 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
@@ -243,10 +243,10 @@ 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.");
+ throw new JsonException("Cannot write null property Person.FirstName to non-nullable JSON property 'firstName'.");
if (person.LastNameOption.IsSet && person.LastName == null)
- throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
+ throw new JsonException("Cannot write null property Person.LastName to non-nullable JSON property 'lastName'.");
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 ba3ebde0806b..e6e5bf9b1853 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 ddd75420f237..65dc4a02463e 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 a552837a0067..9ccac387b196 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
@@ -245,7 +245,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 6d957f4666fe..ba2d70c2fab5 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
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 b31f8fe51330..7b0cc8bc8756 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
@@ -175,6 +175,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 b23a45484ba3..c7ad4a614836 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
@@ -244,7 +244,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Activity.cs
index 8883f1323639..2fb20fd76ba8 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index a7ae93ee504a..a7c053f968ff 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 4c9fc1cad5f2..2d355959392c 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Animal.cs
index 117be25b4c3f..90faf3ed2ad0 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
index 5a61538e1f17..332e1e100ce2 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Apple.cs
index ead5728d626b..8559896f3b99 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
index bd8cd61c4221..cc81766fcebe 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 850a9c376b5a..9a6a9cb6326c 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 2e5eb229f1c3..1b911bc1d6c0 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
index 2b63506f4b44..e42133d4a724 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Banana.cs
index 40d370fd1cdb..d887a45c931e 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
index 0673de456831..db3b3f2aabd1 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
index ea23cb6d7166..57decedb097c 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Cat.cs
index 9ff7be2175c6..f3f27956ed3b 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Category.cs
index b977a0ca50b9..d78edc3ee72c 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
index db3c3064f4e2..46fc753b3481 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
writer.WriteString("pet_type", ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType));
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
index 4d1213df9a8d..012fb4ea1848 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
index 2a75237fd09f..8d25c498e494 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 2b1f5670dec1..72a7565ec3c6 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index a0a059430fbf..4e0d1370cc9a 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
index 4386ed6689ff..5b8587c218e1 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
index d0974d2d3ae9..82cc312ea062 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -175,12 +175,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Dog.cs
index e4066eb72582..5d01cd38ebbe 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
index fce60664f896..b1c4e76fe748 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
index a954055cecef..ee70392a1686 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
index cab43b30299d..780950460e89 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -351,6 +351,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/File.cs
index e6c3a7cd844f..598363737a5e 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 433035256031..74bfbfa1b1ec 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Foo.cs
index 9da199ab2477..ab3a41f87790 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 8e9bba64db14..5d64e47dc7f5 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
index 7c655b0827f2..b489e77a1e15 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
index ca703d27f96c..a73048ec0ad1 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
index c3c2a4e247ab..7071fe00f86d 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index fbd98eae40a9..2f37dd2a61d9 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/List.cs
index d6ac694585ca..b65cac7456c4 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e0e39a3acce3..4b1007e9aaf5 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
index a416718859af..463b714170dd 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MapTest.cs
@@ -244,16 +244,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 42247df00c07..57207f29ddb1 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a8f039e97905..c3a43f3fc745 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index c54becfdc303..1d5a4defe637 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
index ec25fab92034..c1fbf300b336 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
index a78b4b9ae3a8..bb2913f5df66 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
index 9135c0e022ad..f4acaf49d8f1 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Name.cs
index e3a0ef4d62fc..19757fa1c327 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
index b83140b058a7..0c4818c0bff4 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
index 21b40632deb7..428f234deaeb 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index a6be5066e8cd..d8bd9f36ea39 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Order.cs
index 79cfaaf0e5bf..66edef8216f7 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Order.cs
@@ -295,6 +295,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
index 994ccd227bef..93be59d99690 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Pet.cs
index b94bf16627ff..f60a0987b590 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Pet.cs
@@ -282,17 +282,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 495b0d273f6a..ddd15217fc1f 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
index b84dae9064af..eeda5ef0fcc7 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -1053,17 +1053,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Result.cs
index 3d22bb06491f..b57d0b4c7e8e 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Return.cs
index 184ad3ab12c4..c4b5b9636bb3 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index d67bf5ddc948..9b73fae206ff 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 27c3871866be..22702cfaa178 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
index a24895d6f930..9b3bfdab8bcf 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Tag.cs
index ce29344d2cdf..9ac1082f742a 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 764f36716e27..b48698e26e70 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index d6de3eb2c298..4d1c9e06a24f 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
index e77c43ecd5d4..c5b9db5913dd 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -216,9 +216,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendantsObjectTypeValueConverter.ToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a09ec60e3535..5bd2ec9a6bba 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
index e023fb8f77fc..5abf98b1e65b 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/User.cs
index dc078c480cbc..90deb77dbaaa 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Whale.cs
index 02655307d760..1cdb5bad9dd1 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
index 449736faed56..67b6d90eb1d7 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Zebra.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 9add0a06d4cc..ad7eadb1b479 100644
--- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClassZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnumClass.ZeroBasedEnum.Value);
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 4103a73cd4f0..d43c6780ca28 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
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 adf86a28dcd0..23f5c4b3a85d 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
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 2c52c15ccdcc..ad641f68f2e9 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
@@ -336,25 +336,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
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 b5e2ed9ae27f..6344d530cd6e 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
@@ -223,7 +223,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
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 ffbd21ce4a6a..70585c8acf5b 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
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
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 0f80dc0d9c03..edd6e65f1f41 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
@@ -253,13 +253,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
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 a43c764f8240..a98f5bd8787f 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
@@ -188,8 +188,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
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 aef7d7e481d8..509645c3f350 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
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 93684cf9efc6..9d5c27336962 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
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 0b5b6d24743d..14d7950c4b6f 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
@@ -223,13 +223,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
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 fab250f7b537..0a7d794e23fc 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
}
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 42e9d1890af1..1973db4c4bed 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
@@ -188,6 +188,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
index a19a8488e044..8dbfb7552b5f 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
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 eb14befa97d3..68e8220438eb 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
@@ -293,22 +293,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
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 b1fedb233db5..0f47bd35e784 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
@@ -179,7 +179,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
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 97e28530372b..d411efbb83bd 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
@@ -195,8 +195,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value!.Value);
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 d99184db6550..d7c5a4cd96ec 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
@@ -238,7 +238,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
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 a7666cfb698a..16551511b256 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index cbc3e80b4a27..e1e504b538e1 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
index 77fc65981096..260d78873e2e 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -233,9 +233,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
index 6ee21a0298c9..ed6bc6534338 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
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 c04c4f439bdf..f39aa601716f 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
@@ -182,6 +182,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
}
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 0490d964f022..5e4782e9741b 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
index b78ed38fc503..68a2f65c9aff 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
index d4c4e6c2273c..5a130166a0b1 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
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 6908fb106b63..b8435f95759c 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
@@ -179,10 +179,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
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 74c2e0ae5d4b..cce96329e588 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
@@ -240,10 +240,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
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 3bcb6d9b4888..05f5e7db1d24 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
@@ -339,7 +339,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
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 647002803b89..62c8f51ce807 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
@@ -877,6 +877,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index bf25136ce8d5..407e33a7b6f5 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
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 668ebfa6c77c..6608c8f2c0e0 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
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 b29be867e838..d8837421dcac 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
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 98e50928aae1..4b75918a83d5 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
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 763577d494c8..baa4b149818a 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
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 d7ca66d7495a..1badd1c0d948 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
@@ -953,32 +953,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
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 ec0062ba20d3..f902f78034c4 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
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 039f5faedfc4..1eccb13e9003 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
@@ -238,7 +238,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
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 6fa1889a08bd..1a446ca46e5a 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
@@ -241,10 +241,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 962e2a3c1294..82b78a3e00f9 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -339,22 +339,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index fac6f52f2522..b211cf0586b1 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -184,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
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 aac40319978e..b8a8a257d0d2 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-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 027d4fde6be0..70963bef2fc5 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
@@ -200,10 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
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 3c7e075d574e..64474ff0d16d 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
@@ -312,16 +312,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
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 71af55e64992..48eca2b1e0b8 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
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 1536ccf00030..e5c9f6f2f2f7 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
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 d7d6068bcd10..1cef2917ba78 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
@@ -257,8 +257,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
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 7f178b026301..77c1611f8f80 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
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 2d6852d12c7e..ff4080153aea 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
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 0e9021c907a6..b32d7f964146 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
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 d54d7b7d29b5..8fd568be1a6b 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
@@ -283,7 +283,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 2e206a226911..10c8125b1068 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -191,9 +191,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
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 ea88ed18b540..d1327d7b480f 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
@@ -410,10 +410,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
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 fa2f63c11abf..a463ed4572d3 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
}
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 c858d1b3727b..03727598207c 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
@@ -249,13 +249,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
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 ac6f4585d259..ee4d0c85d40a 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
@@ -386,6 +386,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
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 6ed3bf816867..686aa2d77797 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
@@ -222,8 +222,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
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 6cd3a02b4296..5c16160c5db9 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
@@ -373,17 +373,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 33061272899b..bbd3a56b31ed 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
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 bb29062628a7..3b1999efb42d 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
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
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 d1f6c6f40209..1912f3c24ebf 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
@@ -2237,17 +2237,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
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 17f97f2387a3..a6bef2efe103 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
@@ -226,13 +226,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
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 02b3fdc639e2..fd9446247331 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
@@ -234,11 +234,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
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 affe88bd8aea..ac6dd43ef0b2 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
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 ed0af26e87fb..55d774689f49 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index ada72abaf3ad..f1779050584b 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
index 7d55af95627a..cb375197e488 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 48481ee56dfe..0034604725d0 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -191,12 +191,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
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 7af87418b89f..81c58c98aa68 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
@@ -200,7 +200,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
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 fbc5d4a9829e..a16ea726bfff 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
@@ -199,8 +199,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value!.Value);
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 dc66551a230d..182412d38e32 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
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 f297317601df..97b4b270f1c9 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
index c9e049a3db72..5b568b36e9ec 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -291,9 +291,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
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 32e069929830..07d98ed51393 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
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 1edb92ec63a9..d168aff8b9c2 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
@@ -224,11 +224,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 9fbc6b8085b5..c97244ab95ff 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -172,9 +172,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
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 50de52ddebec..c6a4d2cddb86 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
@@ -426,25 +426,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
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 00e53f6dc690..74e3afd8dbf8 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
@@ -218,8 +218,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
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 a871ad34d76d..f6faea2fd5ed 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
@@ -282,8 +282,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
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 5e17279cd925..796310e1783f 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
@@ -249,6 +249,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 ba3ebde0806b..e6e5bf9b1853 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
@@ -177,7 +177,7 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.Kind to non-nullable JSON property 'kind'.");
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 ddd75420f237..65dc4a02463e 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.CountOption.IsSet && banana.Count == null)
+ throw new JsonException("Cannot write null property Banana.Count to non-nullable JSON property 'count'.");
+
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);
}
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 1a4743015087..af45459bafc7 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
@@ -252,7 +252,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 02e5aab13a27..793f5553239f 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
@@ -176,6 +176,9 @@ public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
+ if (orange.SweetOption.IsSet && orange.Sweet == null)
+ throw new JsonException("Cannot write null property Orange.Sweet to non-nullable JSON property 'sweet'.");
+
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Activity.cs
index 8883f1323639..2fb20fd76ba8 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index a7ae93ee504a..a7c053f968ff 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 4c9fc1cad5f2..2d355959392c 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Animal.cs
index 117be25b4c3f..90faf3ed2ad0 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
index 5a61538e1f17..332e1e100ce2 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Apple.cs
index ead5728d626b..8559896f3b99 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
index bd8cd61c4221..cc81766fcebe 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 850a9c376b5a..9a6a9cb6326c 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 2e5eb229f1c3..1b911bc1d6c0 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
index 2b63506f4b44..e42133d4a724 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Banana.cs
index 40d370fd1cdb..d887a45c931e 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
index 0673de456831..db3b3f2aabd1 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
index ea23cb6d7166..57decedb097c 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Cat.cs
index 9ff7be2175c6..f3f27956ed3b 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Category.cs
index b977a0ca50b9..d78edc3ee72c 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
index aad251c4d9e7..d5e2a907d867 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
index 4d1213df9a8d..012fb4ea1848 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
index 73f65a894734..790b30d0598c 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -231,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 2b1f5670dec1..72a7565ec3c6 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index a0a059430fbf..4e0d1370cc9a 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
index 8abf3f5844d0..00e11bca0df2 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
index 5484c2ec84ad..3ad11787dcb3 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Dog.cs
index e4066eb72582..5d01cd38ebbe 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
index fce60664f896..b1c4e76fe748 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
index 45da2f7dc94c..231e6fbbf6bc 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -337,7 +337,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
index 62d913a7c0d7..0aaa3e6fe0aa 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -875,6 +875,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/File.cs
index e6c3a7cd844f..598363737a5e 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 433035256031..74bfbfa1b1ec 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Foo.cs
index 9da199ab2477..ab3a41f87790 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 8e9bba64db14..5d64e47dc7f5 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
index 7c655b0827f2..b489e77a1e15 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
index ca703d27f96c..a73048ec0ad1 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
index c3c2a4e247ab..7071fe00f86d 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index fbd98eae40a9..2f37dd2a61d9 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/List.cs
index d6ac694585ca..b65cac7456c4 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e0e39a3acce3..4b1007e9aaf5 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
index 41b65bf5bc38..b5cdc783088c 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
@@ -310,16 +310,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 42247df00c07..57207f29ddb1 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a8f039e97905..c3a43f3fc745 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index c54becfdc303..1d5a4defe637 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
index ec25fab92034..c1fbf300b336 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
index a78b4b9ae3a8..bb2913f5df66 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
index 9135c0e022ad..f4acaf49d8f1 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Name.cs
index e3a0ef4d62fc..19757fa1c327 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
index b83140b058a7..0c4818c0bff4 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
index 21b40632deb7..428f234deaeb 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index a6be5066e8cd..d8bd9f36ea39 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Order.cs
index 43827461cc02..d3f99122b153 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Order.cs
@@ -384,6 +384,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
index 994ccd227bef..93be59d99690 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Pet.cs
index 41de214278b4..6d3d8121e68c 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Pet.cs
@@ -371,17 +371,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 495b0d273f6a..ddd15217fc1f 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
index bda0936c7e46..50d69fccab91 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2235,17 +2235,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs
index 3d22bb06491f..b57d0b4c7e8e 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Return.cs
index 184ad3ab12c4..c4b5b9636bb3 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index d67bf5ddc948..9b73fae206ff 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 27c3871866be..22702cfaa178 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
index a24895d6f930..9b3bfdab8bcf 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Tag.cs
index ce29344d2cdf..9ac1082f742a 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 764f36716e27..b48698e26e70 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index d6de3eb2c298..4d1c9e06a24f 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
index 3b7c69765ecd..a28ece650979 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -289,9 +289,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a09ec60e3535..5bd2ec9a6bba 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
index e023fb8f77fc..5abf98b1e65b 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/User.cs
index dc078c480cbc..90deb77dbaaa 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Whale.cs
index 02655307d760..1cdb5bad9dd1 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
index 26ed2ec21c31..8bd6f70f0a95 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
@@ -280,8 +280,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 18dfbaafaf8c..0f0d25e333db 100644
--- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -247,6 +247,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 80dce6546255..14a5655c8023 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
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 b609046e8738..06c18ced2a1c 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
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 cd282ab084bb..d4e0bd11b830 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
@@ -337,25 +337,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
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 2fa4fe8d9972..6861539d48cb 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
@@ -224,7 +224,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
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 f0ae4ef850cb..6895b23c9654 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
@@ -223,11 +223,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
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 edbe669c8994..ed26f278fc46 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
@@ -254,13 +254,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
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 0b270e3d4ebb..95c14d25d542 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
@@ -189,8 +189,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
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 6351ae775d17..270d77309df1 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
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 f1d13b9ea264..c2fbcd6a7e57 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
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 6fe159c3a522..877795d5cfd4 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
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
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 c35241ce3891..fd95bd629bbe 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
@@ -177,6 +177,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
}
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 5639dd362d9b..afdff1b19be1 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
@@ -189,6 +189,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
index 04f114d2c52d..d2b0f9fc8e45 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
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 b1ad2e90a31e..26ea3730fba7 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
@@ -294,22 +294,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
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 306e5e5f4010..c44fc9083169 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
@@ -180,7 +180,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
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 60daf384a42b..9795a7beec1b 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
@@ -196,8 +196,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value!.Value);
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 61e9f0c189bc..77c923435187 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
@@ -239,7 +239,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
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 187afe4824bb..90236769cb4a 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index a7184463a89b..d1828daed8ba 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
index b5df3dc0625e..7c1c3f7fe287 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -234,9 +234,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
index 130e644a578d..94e9213fe899 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
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 38bca8c661f8..60ef9165d975 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
@@ -183,6 +183,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
}
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 06763ca2d13c..4b96563e3461 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
index 4547aa00e1c6..48aba268c5b9 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
index 5c2a73bce3fd..aae60577a78f 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
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 ad6546f5ed2e..f43fe465b65a 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
@@ -180,10 +180,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
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 c842739103d3..d26192a1adba 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
@@ -241,10 +241,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
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 ec67776ec0a4..5c6eccf09721 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
@@ -340,7 +340,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
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 534039c94588..57e8cd61d373 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
@@ -878,6 +878,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index c10e5ccee004..a4d6ad4c2f68 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
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 ddeebaa52e17..c26fe4f172ce 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
@@ -179,7 +179,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
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 d90772377b69..77eeacd1bfce 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
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 c0fff6bbf2db..a26bca0b15d4 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
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 b0493a92bcf0..23d6edaccb8c 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
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 a2a69a9962fb..bc64a259b1eb 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
@@ -954,32 +954,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
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 9bad6c70417c..b9adf9d71cc8 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
@@ -222,7 +222,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
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 2dff0e74d24c..a2198a7ec32a 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
@@ -239,7 +239,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
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 716fb2ec240c..098874540247 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
@@ -242,10 +242,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 4682d88e6894..f14013f65705 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -340,22 +340,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index d936a509fa55..261267b6c02f 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -185,12 +185,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
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 0af9622c0f0c..d6cd61b8668e 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-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 0b811f15795c..3de1c9b7ebc5 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
@@ -201,10 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
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 57ff0614c54e..a8ff51c976de 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
@@ -313,16 +313,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
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 93d9cddbe354..93b19a688f74 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
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 2f853d145282..f79216144534 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
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 da7a9e873433..2a2d05afb5bf 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
@@ -258,8 +258,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
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 3ee3e91634c4..e9036f7546d3 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
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 8ed7851b3215..4538cb6884df 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
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 bac5b01c0825..357ce5b2d143 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
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 56ab59544304..37f41d119044 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
@@ -284,7 +284,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 8f71e4492518..358f13e8de5f 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -192,9 +192,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
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 b24440849590..5bf7c08c2823 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
@@ -411,10 +411,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
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 46933a2fbf95..b051d11b1761 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
@@ -177,6 +177,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
}
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 3602dfda1310..e041d875bc51 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
@@ -250,13 +250,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
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 c4a7ebd764c5..5a9d1362547d 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
@@ -387,6 +387,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
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 0c0d0abd343f..4a94f026f474 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
@@ -223,8 +223,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
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 ad57645de2f5..4e7c71f8a59d 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
@@ -374,17 +374,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 63195ad709ae..ac2b8e61cd67 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
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 b411dc6e9d33..8a93f3022a91 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
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
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 41a2c79c34d6..599aa94d5e5e 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
@@ -2238,17 +2238,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
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 02d0d8c34c20..5e2d71377d97 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
@@ -227,13 +227,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
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 6ac928d7c6b8..36c27ec413ed 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
@@ -235,11 +235,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
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 9c544ea876ee..bbaefb23e8b7 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
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 b1122b96b779..e292a138c48e 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 6e5cff7d75a8..9e866915b32f 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
index 94079e588b26..5aedd501c226 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 794c35454611..e7ed21a8c3ca 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -192,12 +192,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
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 1e1b860dedd7..edf8a9edcacf 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
@@ -201,7 +201,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
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 df7dabd4bbb6..a5f86d17a002 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
@@ -200,8 +200,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value!.Value);
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 b42fcd243ecc..508388831ad1 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
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 5e985a42157a..cdd78842b091 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
index 6b0ee1bbe913..7410185d15aa 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -292,9 +292,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
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 9c65047ab818..41fcb61c7c76 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
@@ -178,7 +178,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
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 d935ee12b186..eee7fb7736e2 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
@@ -225,11 +225,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 78caa9c95ad1..20b576d5efbd 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -173,9 +173,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
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 01aeeb13e1de..2589af030b24 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
@@ -427,25 +427,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
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 89658a5314c9..a55ad54be20d 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
@@ -219,8 +219,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
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 3d814ffc0b00..143976f6b272 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
@@ -283,8 +283,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
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 98e4d7afdbfd..733adac3c5c4 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
@@ -250,6 +250,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
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 7027a58c996a..f8d7a66197ae 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
@@ -201,6 +201,12 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res
///
public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions)
{
+ if (nowGet200Response.NowOption.IsSet && nowGet200Response.Now == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Now to non-nullable JSON property 'now'.");
+
+ if (nowGet200Response.TodayOption.IsSet && nowGet200Response.Today == null)
+ throw new JsonException("Cannot write null property NowGet200Response.Today to non-nullable JSON property 'today'.");
+
if (nowGet200Response.NowOption.IsSet)
writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Activity.cs
index bf0ea857b8b2..6ef65dc03490 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Activity.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Activity.ActivityOutputs to non-nullable JSON property 'activity_outputs'.");
if (activity.ActivityOutputsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 3eaef3fdb68a..0900bb21d987 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop1 to non-nullable JSON property 'prop1'.");
if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
+ throw new JsonException("Cannot write null property ActivityOutputElementRepresentation.Prop2 to non-nullable JSON property 'prop2'.");
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index e2bc7e5c95e3..1ea3cc6d6d13 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -334,25 +334,25 @@ 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.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.EmptyMap to non-nullable JSON property 'empty_map'.");
if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapOfMapProperty to non-nullable JSON property 'map_of_map_property'.");
if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapProperty to non-nullable JSON property 'map_property'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 to non-nullable JSON property 'map_with_undeclared_properties_anytype_1'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 to non-nullable JSON property 'map_with_undeclared_properties_anytype_2'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 to non-nullable JSON property 'map_with_undeclared_properties_anytype_3'.");
if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property AdditionalPropertiesClass.MapWithUndeclaredPropertiesString to non-nullable JSON property 'map_with_undeclared_properties_string'.");
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Animal.cs
index 6b2c354e9d0c..af30b50b1efd 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Animal.cs
@@ -221,7 +221,7 @@ 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.");
+ throw new JsonException("Cannot write null property Animal.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", animal.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
index a3bb92ba8e56..891117de444d 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -220,11 +220,14 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
+ if (apiResponse.CodeOption.IsSet && apiResponse.Code == null)
+ throw new JsonException("Cannot write null property ApiResponse.Code to non-nullable JSON property 'code'.");
+
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Message to non-nullable JSON property 'message'.");
if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
+ throw new JsonException("Cannot write null property ApiResponse.Type to non-nullable JSON property 'type'.");
if (apiResponse.CodeOption.IsSet)
writer.WriteNumber("code", apiResponse.CodeOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Apple.cs
index c0b3b74eccb6..415d977cb273 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Apple.cs
@@ -251,13 +251,13 @@ 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.");
+ throw new JsonException("Cannot write null property Apple.ColorCode to non-nullable JSON property 'color_code'.");
if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Cultivar to non-nullable JSON property 'cultivar'.");
if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
+ throw new JsonException("Cannot write null property Apple.Origin to non-nullable JSON property 'origin'.");
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
index b1a035bf1427..a8bb9970d266 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -186,8 +186,8 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
- if (appleReq.Cultivar == null)
- throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");
+ if (appleReq.MealyOption.IsSet && appleReq.Mealy == null)
+ throw new JsonException("Cannot write null property AppleReq.Mealy to non-nullable JSON property 'mealy'.");
writer.WriteString("cultivar", appleReq.Cultivar);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index 8d4e9cf9a280..cf982fbeaccc 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfArrayOfNumberOnly.ArrayArrayNumber to non-nullable JSON property 'ArrayArrayNumber'.");
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 61678ca8a262..9a0450a54939 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayOfNumberOnly.ArrayNumber to non-nullable JSON property 'ArrayNumber'.");
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
index 5ca882e055d9..946aa81707b4 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -221,13 +221,13 @@ 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.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfInteger to non-nullable JSON property 'array_array_of_integer'.");
if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayArrayOfModel to non-nullable JSON property 'array_array_of_model'.");
if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
+ throw new JsonException("Cannot write null property ArrayTest.ArrayOfString to non-nullable JSON property 'array_of_string'.");
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Banana.cs
index 6e96c0db4a48..1963adefce90 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Banana.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
+ if (banana.LengthCmOption.IsSet && banana.LengthCm == null)
+ throw new JsonException("Cannot write null property Banana.LengthCm to non-nullable JSON property 'lengthCm'.");
+
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
index 6e639dde3a6c..d88783cbab2d 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -186,6 +186,9 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
+ if (bananaReq.SweetOption.IsSet && bananaReq.Sweet == null)
+ throw new JsonException("Cannot write null property BananaReq.Sweet to non-nullable JSON property 'sweet'.");
+
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
index d8187db4ad9f..da8a396dd208 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
- if (basquePig.ClassName == null)
- throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");
-
writer.WriteString("className", basquePig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
index 1734a7d71bbe..35fa5c799fe0 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -291,22 +291,22 @@ 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.");
+ throw new JsonException("Cannot write null property Capitalization.ATT_NAME to non-nullable JSON property 'ATT_NAME'.");
if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalCamel to non-nullable JSON property 'CapitalCamel'.");
if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.CapitalSnake to non-nullable JSON property 'Capital_Snake'.");
if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SCAETHFlowPoints to non-nullable JSON property 'SCA_ETH_Flow_Points'.");
if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallCamel to non-nullable JSON property 'smallCamel'.");
if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
+ throw new JsonException("Cannot write null property Capitalization.SmallSnake to non-nullable JSON property 'small_Snake'.");
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Cat.cs
index 07d7a0a7ce17..dbf7d5878726 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Cat.cs
@@ -177,7 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Cat.Color to non-nullable JSON property 'color'.");
+
+ if (cat.DeclawedOption.IsSet && cat.Declawed == null)
+ throw new JsonException("Cannot write null property Cat.Declawed to non-nullable JSON property 'declawed'.");
writer.WriteString("className", cat.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Category.cs
index ee17225920da..c33db720faab 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Category.cs
@@ -193,8 +193,8 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
- if (category.Name == null)
- throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
+ if (category.IdOption.IsSet && category.Id == null)
+ throw new JsonException("Cannot write null property Category.Id to non-nullable JSON property 'id'.");
if (category.IdOption.IsSet)
writer.WriteNumber("id", category.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
index 711470ca3a83..0df505327662 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property ChildCat.Name to non-nullable JSON property 'name'.");
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
index 55e14e4e7e7d..2cec4e3ee767 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ClassModel.Class to non-nullable JSON property '_class'.");
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
index 675cea7e9800..71f28630fcd3 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu
///
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (complexQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");
-
- if (complexQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral.");
-
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
index 73f65a894734..790b30d0598c 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs
@@ -231,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, Jso
///
public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions)
{
- if (copyActivity.CopyActivitytt == null)
- throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity.");
-
writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt);
writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema));
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
index e1321fb84673..36182d9cbb8e 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
- if (danishPig.ClassName == null)
- throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");
-
writer.WriteString("className", danishPig.ClassName);
}
}
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 12f63bed52c3..f272f800a65b 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -180,6 +180,9 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
///
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (dateOnlyClass.DateOnlyPropertyOption.IsSet && dateOnlyClass.DateOnlyProperty == null)
+ throw new JsonException("Cannot write null property DateOnlyClass.DateOnlyProperty to non-nullable JSON property 'dateOnlyProperty'.");
+
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));
}
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index cea3eed9a750..5b795e143682 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property DeprecatedObject.Name to non-nullable JSON property 'name'.");
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
index 8abf3f5844d0..00e11bca0df2 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Descendant1.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant1 descendant1, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant1 descendant1, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant1.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant1.AlternativeName), "Property is required for class Descendant1.");
-
- if (descendant1.DescendantName == null)
- throw new ArgumentNullException(nameof(descendant1.DescendantName), "Property is required for class Descendant1.");
-
writer.WriteString("alternativeName", descendant1.AlternativeName);
writer.WriteString("descendantName", descendant1.DescendantName);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
index 5484c2ec84ad..3ad11787dcb3 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Descendant2.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, Descendant2 descendant2, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, Descendant2 descendant2, JsonSerializerOptions jsonSerializerOptions)
{
- if (descendant2.AlternativeName == null)
- throw new ArgumentNullException(nameof(descendant2.AlternativeName), "Property is required for class Descendant2.");
-
- if (descendant2.Confidentiality == null)
- throw new ArgumentNullException(nameof(descendant2.Confidentiality), "Property is required for class Descendant2.");
-
writer.WriteString("alternativeName", descendant2.AlternativeName);
writer.WriteString("confidentiality", descendant2.Confidentiality);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Dog.cs
index ea0b4d3071f1..8f43963d5b4f 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Dog.cs
@@ -177,10 +177,10 @@ 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.");
+ throw new JsonException("Cannot write null property Dog.Breed to non-nullable JSON property 'breed'.");
if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
+ throw new JsonException("Cannot write null property Dog.Color to non-nullable JSON property 'color'.");
writer.WriteString("className", dog.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
index 0c6925ca0e37..2bf745f2f7d4 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs
@@ -238,10 +238,10 @@ 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.");
+ throw new JsonException("Cannot write null property Drawing.MainShape to non-nullable JSON property 'mainShape'.");
if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
+ throw new JsonException("Cannot write null property Drawing.Shapes to non-nullable JSON property 'shapes'.");
if (drawing.MainShapeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
index e04f4f594f2b..75fc3819ecf1 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -337,7 +337,10 @@ 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.");
+ throw new JsonException("Cannot write null property EnumArrays.ArrayEnum to non-nullable JSON property 'array_enum'.");
+
+ if (enumArrays.JustSymbolOption.IsSet && enumArrays.JustSymbol == null)
+ throw new JsonException("Cannot write null property EnumArrays.JustSymbol to non-nullable JSON property 'just_symbol'.");
if (enumArrays.ArrayEnumOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
index 4f4100fc359e..bd1502d4326b 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -875,6 +875,27 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
+ if (enumTest.EnumIntegerOption.IsSet && enumTest.EnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumInteger to non-nullable JSON property 'enum_integer'.");
+
+ if (enumTest.EnumIntegerOnlyOption.IsSet && enumTest.EnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumIntegerOnly to non-nullable JSON property 'enum_integer_only'.");
+
+ if (enumTest.EnumNumberOption.IsSet && enumTest.EnumNumber == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumNumber to non-nullable JSON property 'enum_number'.");
+
+ if (enumTest.EnumStringOption.IsSet && enumTest.EnumString == null)
+ throw new JsonException("Cannot write null property EnumTest.EnumString to non-nullable JSON property 'enum_string'.");
+
+ if (enumTest.OuterEnumDefaultValueOption.IsSet && enumTest.OuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumDefaultValue to non-nullable JSON property 'outerEnumDefaultValue'.");
+
+ if (enumTest.OuterEnumIntegerOption.IsSet && enumTest.OuterEnumInteger == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumInteger to non-nullable JSON property 'outerEnumInteger'.");
+
+ if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet && enumTest.OuterEnumIntegerDefaultValue == null)
+ throw new JsonException("Cannot write null property EnumTest.OuterEnumIntegerDefaultValue to non-nullable JSON property 'outerEnumIntegerDefaultValue'.");
+
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
index a7ae4b88717c..6945fabbfb86 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera
///
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (equilateralTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");
-
- if (equilateralTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle.");
-
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/File.cs
index ee5463fb46f9..f3b89016ca8c 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/File.cs
@@ -176,7 +176,7 @@ 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.");
+ throw new JsonException("Cannot write null property File.SourceURI to non-nullable JSON property 'sourceURI'.");
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index e129b109115f..70c50972598e 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.File to non-nullable JSON property 'file'.");
if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
+ throw new JsonException("Cannot write null property FileSchemaTestClass.Files to non-nullable JSON property 'files'.");
if (fileSchemaTestClass.FileOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Foo.cs
index 77a9cd5f82b8..0bde70e7d10c 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Foo.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property Foo.Bar to non-nullable JSON property 'bar'.");
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 73a4dbbcaf22..6f6db2d948a2 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property FooGetDefaultResponse.String to non-nullable JSON property 'string'.");
if (fooGetDefaultResponse.StringOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
index 3156ed4239ce..b16df5f518e0 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -951,32 +951,74 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (formatTest.Byte == null)
- throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");
+ if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
+ throw new JsonException("Cannot write null property FormatTest.Binary to non-nullable JSON property 'binary'.");
- if (formatTest.Password == null)
- throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
+ if (formatTest.DateTimeOption.IsSet && formatTest.DateTime == null)
+ throw new JsonException("Cannot write null property FormatTest.DateTime to non-nullable JSON property 'dateTime'.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
+ if (formatTest.DecimalOption.IsSet && formatTest.Decimal == null)
+ throw new JsonException("Cannot write null property FormatTest.Decimal to non-nullable JSON property 'decimal'.");
+
+ if (formatTest.DoubleOption.IsSet && formatTest.Double == null)
+ throw new JsonException("Cannot write null property FormatTest.Double to non-nullable JSON property 'double'.");
if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName2 to non-nullable JSON property 'duplicate_property_name'.");
if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.DuplicatePropertyName to non-nullable JSON property '@duplicate_property_name'.");
+
+ if (formatTest.FloatOption.IsSet && formatTest.Float == null)
+ throw new JsonException("Cannot write null property FormatTest.Float to non-nullable JSON property 'float'.");
+
+ if (formatTest.Int32Option.IsSet && formatTest.Int32 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32 to non-nullable JSON property 'int32'.");
+
+ if (formatTest.Int32RangeOption.IsSet && formatTest.Int32Range == null)
+ throw new JsonException("Cannot write null property FormatTest.Int32Range to non-nullable JSON property 'int32Range'.");
+
+ if (formatTest.Int64Option.IsSet && formatTest.Int64 == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64 to non-nullable JSON property 'int64'.");
+
+ if (formatTest.Int64NegativeOption.IsSet && formatTest.Int64Negative == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Negative to non-nullable JSON property 'int64Negative'.");
+
+ if (formatTest.Int64NegativeExclusiveOption.IsSet && formatTest.Int64NegativeExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64NegativeExclusive to non-nullable JSON property 'int64NegativeExclusive'.");
+
+ if (formatTest.Int64PositiveOption.IsSet && formatTest.Int64Positive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64Positive to non-nullable JSON property 'int64Positive'.");
+
+ if (formatTest.Int64PositiveExclusiveOption.IsSet && formatTest.Int64PositiveExclusive == null)
+ throw new JsonException("Cannot write null property FormatTest.Int64PositiveExclusive to non-nullable JSON property 'int64PositiveExclusive'.");
+
+ if (formatTest.IntegerOption.IsSet && formatTest.Integer == null)
+ throw new JsonException("Cannot write null property FormatTest.Integer to non-nullable JSON property 'integer'.");
if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithBackslash to non-nullable JSON property 'pattern_with_backslash'.");
if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigits to non-nullable JSON property 'pattern_with_digits'.");
if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.PatternWithDigitsAndDelimiter to non-nullable JSON property 'pattern_with_digits_and_delimiter'.");
if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
+ throw new JsonException("Cannot write null property FormatTest.String to non-nullable JSON property 'string'.");
+
+ if (formatTest.StringFormattedAsDecimalOption.IsSet && formatTest.StringFormattedAsDecimal == null)
+ throw new JsonException("Cannot write null property FormatTest.StringFormattedAsDecimal to non-nullable JSON property 'string_formatted_as_decimal'.");
+
+ if (formatTest.UnsignedIntegerOption.IsSet && formatTest.UnsignedInteger == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedInteger to non-nullable JSON property 'unsigned_integer'.");
+
+ if (formatTest.UnsignedLongOption.IsSet && formatTest.UnsignedLong == null)
+ throw new JsonException("Cannot write null property FormatTest.UnsignedLong to non-nullable JSON property 'unsigned_long'.");
+
+ if (formatTest.UuidOption.IsSet && formatTest.Uuid == null)
+ throw new JsonException("Cannot write null property FormatTest.Uuid to non-nullable JSON property 'uuid'.");
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
index ba5d85932b34..e6781b1c920b 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Fruit.cs
@@ -219,7 +219,7 @@ 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.");
+ throw new JsonException("Cannot write null property Fruit.Color to non-nullable JSON property 'color'.");
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
index 6d9269ff3873..2df46dde14c4 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -236,7 +236,7 @@ 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.");
+ throw new JsonException("Cannot write null property GmFruit.Color to non-nullable JSON property 'color'.");
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index af770d67c662..925dfb5ff515 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -239,10 +239,10 @@ 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.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Bar to non-nullable JSON property 'bar'.");
if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
+ throw new JsonException("Cannot write null property HasOnlyReadOnly.Foo to non-nullable JSON property 'foo'.");
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
index 62dc7cbf449c..4655c9cbb01e 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/InjectedVendorExtensionsTest.cs
@@ -337,22 +337,22 @@ public override void Write(Utf8JsonWriter writer, InjectedVendorExtensionsTest i
public void WriteProperties(Utf8JsonWriter writer, InjectedVendorExtensionsTest injectedVendorExtensionsTest, JsonSerializerOptions jsonSerializerOptions)
{
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor to non-nullable JSON property 'potentiallyOverriddenPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternalOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToInternal to non-nullable JSON property 'potentiallyOverriddenPropertyToInternal'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivateOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPrivate to non-nullable JSON property 'potentiallyOverriddenPropertyToPrivate'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublicOption.IsSet && injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.PotentiallyOverriddenPropertyToPublic to non-nullable JSON property 'potentiallyOverriddenPropertyToPublic'.");
if (injectedVendorExtensionsTest.UnalteredPropertyOption.IsSet && injectedVendorExtensionsTest.UnalteredProperty == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredProperty), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredProperty to non-nullable JSON property 'unalteredProperty'.");
if (injectedVendorExtensionsTest.UnalteredPropertyAccessorOption.IsSet && injectedVendorExtensionsTest.UnalteredPropertyAccessor == null)
- throw new ArgumentNullException(nameof(injectedVendorExtensionsTest.UnalteredPropertyAccessor), "Property is required for class InjectedVendorExtensionsTest.");
+ throw new JsonException("Cannot write null property InjectedVendorExtensionsTest.UnalteredPropertyAccessor to non-nullable JSON property 'unalteredPropertyAccessor'.");
if (injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessorOption.IsSet)
writer.WriteString("potentiallyOverriddenPropertyAccessor", injectedVendorExtensionsTest.PotentiallyOverriddenPropertyAccessor);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
index f48f46edb14a..9e34531ab9ba 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs
@@ -182,12 +182,6 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri
///
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (isoscelesTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");
-
- if (isoscelesTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle.");
-
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/List.cs
index 43d2716ec68c..0ba836f7be5f 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/List.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property List.Var123List to non-nullable JSON property '123-list'.");
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 8be2841ce1c9..4e22fe711e2a 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -198,10 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property LiteralStringClass.EscapedLiteralString to non-nullable JSON property 'escapedLiteralString'.");
if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
+ throw new JsonException("Cannot write null property LiteralStringClass.UnescapedLiteralString to non-nullable JSON property 'unescapedLiteralString'.");
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
index 21cad314eb1d..c216c04d6468 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MapTest.cs
@@ -310,16 +310,16 @@ 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.");
+ throw new JsonException("Cannot write null property MapTest.DirectMap to non-nullable JSON property 'direct_map'.");
if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.IndirectMap to non-nullable JSON property 'indirect_map'.");
if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapMapOfString to non-nullable JSON property 'map_map_of_string'.");
if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
+ throw new JsonException("Cannot write null property MapTest.MapOfEnumString to non-nullable JSON property 'map_of_enum_string'.");
if (mapTest.DirectMapOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 0c8cceae99d0..90526549ac2b 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedAnyOf.Content to non-nullable JSON property 'content'.");
if (mixedAnyOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
index a9e0341e6431..2376786bd50e 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedOneOf.Content to non-nullable JSON property 'content'.");
if (mixedOneOf.ContentOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3229c397c986..d406287f4039 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -255,8 +255,17 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.DateTime == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.DateTime to non-nullable JSON property 'dateTime'.");
+
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Map to non-nullable JSON property 'map'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Uuid == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.Uuid to non-nullable JSON property 'uuid'.");
+
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern == null)
+ throw new JsonException("Cannot write null property MixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern to non-nullable JSON property 'uuid_with_pattern'.");
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat));
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
index d89d53fe55c9..2220371abceb 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property MixedSubId.Id to non-nullable JSON property 'id'.");
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
index aac8654e884b..09990a706a8c 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property Model200Response.Class to non-nullable JSON property 'class'.");
+
+ if (model200Response.NameOption.IsSet && model200Response.Name == null)
+ throw new JsonException("Cannot write null property Model200Response.Name to non-nullable JSON property 'name'.");
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
index 90ac80d193a6..64b5da999734 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property ModelClient.VarClient to non-nullable JSON property 'client'.");
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Name.cs
index b487237e70e3..f657f42be0ab 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Name.cs
@@ -281,7 +281,13 @@ 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.");
+ throw new JsonException("Cannot write null property Name.Property to non-nullable JSON property 'property'.");
+
+ if (name.SnakeCaseOption.IsSet && name.SnakeCase == null)
+ throw new JsonException("Cannot write null property Name.SnakeCase to non-nullable JSON property 'snake_case'.");
+
+ if (name.Var123NumberOption.IsSet && name.Var123Number == null)
+ throw new JsonException("Cannot write null property Name.Var123Number to non-nullable JSON property '123Number'.");
writer.WriteNumber("name", name.VarName);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
index 173109b5fa48..2858e8d86e69 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs
@@ -189,9 +189,6 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R
///
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
- if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
- throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");
-
writer.WritePropertyName("a_objVariableobject");
JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions);
writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
index 1e08ccc57034..ba9cfa507092 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -408,10 +408,10 @@ 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.");
+ throw new JsonException("Cannot write null property NullableClass.ArrayItemsNullable to non-nullable JSON property 'array_items_nullable'.");
if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
+ throw new JsonException("Cannot write null property NullableClass.ObjectItemsNullable to non-nullable JSON property 'object_items_nullable'.");
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
index 1a88e07e0def..209be6be1047 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -174,6 +174,9 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
+ if (numberOnly.JustNumberOption.IsSet && numberOnly.JustNumber == null)
+ throw new JsonException("Cannot write null property NumberOnly.JustNumber to non-nullable JSON property 'JustNumber'.");
+
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index 047b1dcde4d2..7881bc48f66e 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -247,13 +247,16 @@ 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.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Bars to non-nullable JSON property 'bars'.");
if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.DeprecatedRef to non-nullable JSON property 'deprecatedRef'.");
+
+ if (objectWithDeprecatedFields.IdOption.IsSet && objectWithDeprecatedFields.Id == null)
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Id to non-nullable JSON property 'id'.");
if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
+ throw new JsonException("Cannot write null property ObjectWithDeprecatedFields.Uuid to non-nullable JSON property 'uuid'.");
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Order.cs
index 76ffea5c5ab4..4d4a6167efc2 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Order.cs
@@ -384,6 +384,24 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
+ if (order.CompleteOption.IsSet && order.Complete == null)
+ throw new JsonException("Cannot write null property Order.Complete to non-nullable JSON property 'complete'.");
+
+ if (order.IdOption.IsSet && order.Id == null)
+ throw new JsonException("Cannot write null property Order.Id to non-nullable JSON property 'id'.");
+
+ if (order.PetIdOption.IsSet && order.PetId == null)
+ throw new JsonException("Cannot write null property Order.PetId to non-nullable JSON property 'petId'.");
+
+ if (order.QuantityOption.IsSet && order.Quantity == null)
+ throw new JsonException("Cannot write null property Order.Quantity to non-nullable JSON property 'quantity'.");
+
+ if (order.ShipDateOption.IsSet && order.ShipDate == null)
+ throw new JsonException("Cannot write null property Order.ShipDate to non-nullable JSON property 'shipDate'.");
+
+ if (order.StatusOption.IsSet && order.Status == null)
+ throw new JsonException("Cannot write null property Order.Status to non-nullable JSON property 'status'.");
+
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
index 686d151558e0..448c538f19d8 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -220,8 +220,14 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
+ if (outerComposite.MyBooleanOption.IsSet && outerComposite.MyBoolean == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyBoolean to non-nullable JSON property 'my_boolean'.");
+
+ if (outerComposite.MyNumberOption.IsSet && outerComposite.MyNumber == null)
+ throw new JsonException("Cannot write null property OuterComposite.MyNumber to non-nullable JSON property 'my_number'.");
+
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
+ throw new JsonException("Cannot write null property OuterComposite.MyString to non-nullable JSON property 'my_string'.");
if (outerComposite.MyBooleanOption.IsSet)
writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pet.cs
index cab3ba9dbf6e..d8bb45eae944 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pet.cs
@@ -371,17 +371,17 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
- if (pet.Name == null)
- throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");
+ if (pet.CategoryOption.IsSet && pet.Category == null)
+ throw new JsonException("Cannot write null property Pet.Category to non-nullable JSON property 'category'.");
- if (pet.PhotoUrls == null)
- throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
+ if (pet.IdOption.IsSet && pet.Id == null)
+ throw new JsonException("Cannot write null property Pet.Id to non-nullable JSON property 'id'.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
+ if (pet.StatusOption.IsSet && pet.Status == null)
+ throw new JsonException("Cannot write null property Pet.Status to non-nullable JSON property 'status'.");
if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
+ throw new JsonException("Cannot write null property Pet.Tags to non-nullable JSON property 'tags'.");
writer.WriteString("name", pet.Name);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
index 8a448cd3387c..790693a4ee03 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril
///
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (quadrilateralInterface.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");
-
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 42af39d72901..6c679f4eadf0 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -236,10 +236,10 @@ 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.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Bar to non-nullable JSON property 'bar'.");
if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
+ throw new JsonException("Cannot write null property ReadOnlyFirst.Baz to non-nullable JSON property 'baz'.");
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
index 01ceaaae2c51..a5e6b6f451b2 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2235,17 +2235,38 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J
///
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (requiredClass.RequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet && requiredClass.NotRequiredNotnullableDateProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableDateProp to non-nullable JSON property 'not_required_notnullable_date_prop'.");
- if (requiredClass.RequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet && requiredClass.NotRequiredNotnullableintegerProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotRequiredNotnullableintegerProp to non-nullable JSON property 'not_required_notnullableinteger_prop'.");
if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableArrayOfString to non-nullable JSON property 'notrequired_notnullable_array_of_string'.");
+
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet && requiredClass.NotrequiredNotnullableBooleanProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableBooleanProp to non-nullable JSON property 'notrequired_notnullable_boolean_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet && requiredClass.NotrequiredNotnullableDatetimeProp == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableDatetimeProp to non-nullable JSON property 'notrequired_notnullable_datetime_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet && requiredClass.NotrequiredNotnullableEnumInteger == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumInteger to non-nullable JSON property 'notrequired_notnullable_enum_integer'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet && requiredClass.NotrequiredNotnullableEnumIntegerOnly == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumIntegerOnly to non-nullable JSON property 'notrequired_notnullable_enum_integer_only'.");
+
+ if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet && requiredClass.NotrequiredNotnullableEnumString == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableEnumString to non-nullable JSON property 'notrequired_notnullable_enum_string'.");
+
+ if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet && requiredClass.NotrequiredNotnullableOuterEnumDefaultValue == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableOuterEnumDefaultValue to non-nullable JSON property 'notrequired_notnullable_outerEnumDefaultValue'.");
if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableStringProp to non-nullable JSON property 'notrequired_notnullable_string_prop'.");
+
+ if (requiredClass.NotrequiredNotnullableUuidOption.IsSet && requiredClass.NotrequiredNotnullableUuid == null)
+ throw new JsonException("Cannot write null property RequiredClass.NotrequiredNotnullableUuid to non-nullable JSON property 'notrequired_notnullable_uuid'.");
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs
index dd616a09ce41..7ed1ea210629 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs
@@ -224,13 +224,13 @@ 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.");
+ throw new JsonException("Cannot write null property Result.Code to non-nullable JSON property 'code'.");
if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Data to non-nullable JSON property 'data'.");
if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
+ throw new JsonException("Cannot write null property Result.Uuid to non-nullable JSON property 'uuid'.");
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Return.cs
index cabc503d20d8..6870e58a4e5b 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Return.cs
@@ -232,11 +232,11 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ
///
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
- if (varReturn.Lock == null)
- throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
+ if (varReturn.VarReturnOption.IsSet && varReturn.VarReturn == null)
+ throw new JsonException("Cannot write null property Return.VarReturn to non-nullable JSON property 'return'.");
if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
+ throw new JsonException("Cannot write null property Return.Unsafe to non-nullable JSON property 'unsafe'.");
writer.WriteString("lock", varReturn.Lock);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index b074a36ee24f..88ac872eba81 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHash.Role to non-nullable JSON property 'role'.");
+
+ if (rolesReportsHash.RoleUuidOption.IsSet && rolesReportsHash.RoleUuid == null)
+ throw new JsonException("Cannot write null property RolesReportsHash.RoleUuid to non-nullable JSON property 'role_uuid'.");
if (rolesReportsHash.RoleOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 3018f5c27f8f..7ac7e71cbc15 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property RolesReportsHashRole.Name to non-nullable JSON property 'name'.");
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
index 90e3ddf5efa3..fc2982004601 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl
///
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
- if (scaleneTriangle.ShapeType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");
-
- if (scaleneTriangle.TriangleType == null)
- throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle.");
-
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
index a1070f6b741a..54079932ecbf 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface,
///
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (shapeInterface.ShapeType == null)
- throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");
-
writer.WriteString("shapeType", shapeInterface.ShapeType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
index 06867abbfabe..45ef5585c1a2 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs
@@ -189,12 +189,6 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad
///
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
- if (simpleQuadrilateral.QuadrilateralType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");
-
- if (simpleQuadrilateral.ShapeType == null)
- throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral.");
-
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 07924a0aa49a..b6bcd6886413 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -198,7 +198,10 @@ 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.");
+ throw new JsonException("Cannot write null property SpecialModelName.VarSpecialModelName to non-nullable JSON property '_special_model.name_'.");
+
+ if (specialModelName.SpecialPropertyNameOption.IsSet && specialModelName.SpecialPropertyName == null)
+ throw new JsonException("Cannot write null property SpecialModelName.SpecialPropertyName to non-nullable JSON property '$special[property.name]'.");
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Tag.cs
index 9512c15160f5..d0d4298cab55 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Tag.cs
@@ -197,8 +197,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
+ if (tag.IdOption.IsSet && tag.Id == null)
+ throw new JsonException("Cannot write null property Tag.Id to non-nullable JSON property 'id'.");
+
if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
+ throw new JsonException("Cannot write null property Tag.Name to non-nullable JSON property 'name'.");
if (tag.IdOption.IsSet)
writer.WriteNumber("id", tag.IdOption.Value.Value);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index 3a19c8ecaffb..db057bf9b74f 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordList.Value to non-nullable JSON property 'value'.");
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index a5b3a7caf550..e7b97dd14788 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestCollectionEndingWithWordListObject.TestCollectionEndingWithWordList to non-nullable JSON property 'TestCollectionEndingWithWordList'.");
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
index 3b7c69765ecd..a28ece650979 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestDescendants.cs
@@ -289,9 +289,6 @@ public override void Write(Utf8JsonWriter writer, TestDescendants testDescendant
///
public void WriteProperties(Utf8JsonWriter writer, TestDescendants testDescendants, JsonSerializerOptions jsonSerializerOptions)
{
- if (testDescendants.AlternativeName == null)
- throw new ArgumentNullException(nameof(testDescendants.AlternativeName), "Property is required for class TestDescendants.");
-
writer.WriteString("alternativeName", testDescendants.AlternativeName);
writer.WriteString("objectType", TestDescendants.ObjectTypeEnumToJsonValue(testDescendants.ObjectType));
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index a8630ed8db3c..b2ef6e096109 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -175,7 +175,7 @@ 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.");
+ throw new JsonException("Cannot write null property TestInlineFreeformAdditionalPropertiesRequest.SomeProperty to non-nullable JSON property 'someProperty'.");
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
index 15113add0df2..e367448c907f 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs
@@ -222,11 +222,14 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
+ if (testResult.CodeOption.IsSet && testResult.Code == null)
+ throw new JsonException("Cannot write null property TestResult.Code to non-nullable JSON property 'code'.");
+
if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Data to non-nullable JSON property 'data'.");
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
+ throw new JsonException("Cannot write null property TestResult.Uuid to non-nullable JSON property 'uuid'.");
if (testResult.CodeOption.IsSet)
{
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
index 4774a8af8087..afe9457b01a5 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs
@@ -170,9 +170,6 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte
///
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
- if (triangleInterface.TriangleType == null)
- throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");
-
writer.WriteString("triangleType", triangleInterface.TriangleType);
}
}
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/User.cs
index f3ea6b22b2af..dd4db4f456f1 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/User.cs
@@ -424,25 +424,31 @@ 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.");
+ throw new JsonException("Cannot write null property User.Email to non-nullable JSON property 'email'.");
if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.FirstName to non-nullable JSON property 'firstName'.");
+
+ if (user.IdOption.IsSet && user.Id == null)
+ throw new JsonException("Cannot write null property User.Id to non-nullable JSON property 'id'.");
if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.LastName to non-nullable JSON property 'lastName'.");
if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.ObjectWithNoDeclaredProps to non-nullable JSON property 'objectWithNoDeclaredProps'.");
if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Password to non-nullable JSON property 'password'.");
if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Phone to non-nullable JSON property 'phone'.");
+
+ if (user.UserStatusOption.IsSet && user.UserStatus == null)
+ throw new JsonException("Cannot write null property User.UserStatus to non-nullable JSON property 'userStatus'.");
if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
+ throw new JsonException("Cannot write null property User.Username to non-nullable JSON property 'username'.");
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Whale.cs
index 08d6186ad435..c1abfbfd12c0 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Whale.cs
@@ -216,8 +216,11 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
- if (whale.ClassName == null)
- throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");
+ if (whale.HasBaleenOption.IsSet && whale.HasBaleen == null)
+ throw new JsonException("Cannot write null property Whale.HasBaleen to non-nullable JSON property 'hasBaleen'.");
+
+ if (whale.HasTeethOption.IsSet && whale.HasTeeth == null)
+ throw new JsonException("Cannot write null property Whale.HasTeeth to non-nullable JSON property 'hasTeeth'.");
writer.WriteString("className", whale.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
index bc1f99da6d94..c6144e93c73d 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Zebra.cs
@@ -280,8 +280,8 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions)
{
- if (zebra.ClassName == null)
- throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra.");
+ if (zebra.TypeOption.IsSet && zebra.Type == null)
+ throw new JsonException("Cannot write null property Zebra.Type to non-nullable JSON property 'type'.");
writer.WriteString("className", zebra.ClassName);
diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index e8cf530a9235..4ce3561c85ec 100644
--- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -247,6 +247,9 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn
///
public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
+ if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet && zeroBasedEnumClass.ZeroBasedEnum == null)
+ throw new JsonException("Cannot write null property ZeroBasedEnumClass.ZeroBasedEnum to non-nullable JSON property 'ZeroBasedEnum'.");
+
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value);
writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}