Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,14 @@
{{#allVars}}
{{#required}}
if (!{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.IsSet)
throw new ArgumentException("Property is required for class {{classname}}.", nameof({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}));
throw new JsonException("Property is required for class {{classname}}: {{baseName}}.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: When a schema property name contains & or another HTML-significant character, this JsonException reports a name different from the JSON payload. Render a C#-escaped raw baseName value instead of using default HTML escaping.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache, line 299:

<comment>When a schema property name contains `&` or another HTML-significant character, this `JsonException` reports a name different from the JSON payload. Render a C#-escaped raw `baseName` value instead of using default HTML escaping.</comment>

<file context>
@@ -296,14 +296,14 @@
             {{#required}}
             if (!{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.IsSet)
-                throw new ArgumentException("Property is required for class {{classname}}.", nameof({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}));
+                throw new JsonException("Property is required for class {{classname}}: {{baseName}}.");
 
             {{/required}}
</file context>


{{/required}}
{{/allVars}}
{{#allVars}}
{{^isNullable}}
if ({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.IsSet && {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.Value == null)
throw new ArgumentNullException(nameof({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}), "Property is not nullable for class {{classname}}.");
throw new JsonException("Property is not nullable for class {{classname}}: {{baseName}}.");

{{/isNullable}}
{{/allVars}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public void testGenericHostInnerStringEnumUnknownHandlingPreservesNullBehavior()
"if (requiredNotnullableEnumStringValue == null)\n" +
" throw new JsonException();",
"if (!requiredNullableEnumString.IsSet)\n" +
" throw new ArgumentException(\"Property is required for class RequiredClass.\", nameof(requiredNullableEnumString));",
" throw new JsonException(\"Property is required for class RequiredClass: required_nullable_enum_string.\");",
"if (!requiredNotnullableEnumString.IsSet)\n" +
" throw new ArgumentException(\"Property is required for class RequiredClass.\", nameof(requiredNotnullableEnumString));"
" throw new JsonException(\"Property is required for class RequiredClass: required_notnullable_enum_string.\");"
);
}

Expand Down Expand Up @@ -440,9 +440,9 @@ public void testNumericEnumJsonConverterUsesNumericOperations() throws IOExcepti
// Required numeric checks distinguish a missing property from a present null.
assertThat(modelWithEnumProperties).contains(
"if (!requiredInlineIntEnum.IsSet)\n" +
" throw new ArgumentException(\"Property is required for class ModelWithEnumProperties.\", nameof(requiredInlineIntEnum));",
" throw new JsonException(\"Property is required for class ModelWithEnumProperties: requiredInlineIntEnum.\");",
"if (requiredInlineIntEnum.IsSet && requiredInlineIntEnum.Value == null)\n" +
" throw new ArgumentNullException(nameof(requiredInlineIntEnum), \"Property is not nullable for class ModelWithEnumProperties.\");"
" throw new JsonException(\"Property is not nullable for class ModelWithEnumProperties: requiredInlineIntEnum.\");"
);

// Verify long enum uses int64 reader with validation and actual int64 values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override OneOfNullAndRef Read(ref Utf8JsonReader utf8JsonReader, Type typ
}

if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class OneOfNullAndRef.");
throw new JsonException("Property is not nullable for class OneOfNullAndRef: number.");

return new OneOfNullAndRef(number);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override OneOfNullAndRef2 Read(ref Utf8JsonReader utf8JsonReader, Type ty
}

if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class OneOfNullAndRef2.");
throw new JsonException("Property is not nullable for class OneOfNullAndRef2: number.");

return new OneOfNullAndRef2(number);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override OneOfNullAndRef3 Read(ref Utf8JsonReader utf8JsonReader, Type ty
}

if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class OneOfNullAndRef3.");
throw new JsonException("Property is not nullable for class OneOfNullAndRef3: number.");

return new OneOfNullAndRef3(number);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override Parent Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}

if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class Parent.");
throw new JsonException("Property is not nullable for class Parent: number.");

return new Parent(number);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override ParentWithOneOfProperty Read(ref Utf8JsonReader utf8JsonReader,
}

if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class ParentWithOneOfProperty.");
throw new JsonException("Property is not nullable for class ParentWithOneOfProperty: number.");

return new ParentWithOneOfProperty(number);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override ParentWithPluralOneOfProperty Read(ref Utf8JsonReader utf8JsonRe
}

if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class ParentWithPluralOneOfProperty.");
throw new JsonException("Property is not nullable for class ParentWithPluralOneOfProperty: number.");

return new ParentWithPluralOneOfProperty(number);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override HelloWorldPostRequest Read(ref Utf8JsonReader utf8JsonReader, Ty
}

if (message.IsSet && message.Value == null)
throw new ArgumentNullException(nameof(message), "Property is not nullable for class HelloWorldPostRequest.");
throw new JsonException("Property is not nullable for class HelloWorldPostRequest: message.");

return new HelloWorldPostRequest(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}

if (bar.IsSet && bar.Value == null)
throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo.");
throw new JsonException("Property is not nullable for class Foo: bar.");

return new Foo(bar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override IconsDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Typ
}

if (varString.IsSet && varString.Value == null)
throw new ArgumentNullException(nameof(varString), "Property is not nullable for class IconsDefaultResponse.");
throw new JsonException("Property is not nullable for class IconsDefaultResponse: string.");

return new IconsDefaultResponse(varString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ public override Color Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}

if (b.IsSet && b.Value == null)
throw new ArgumentNullException(nameof(b), "Property is not nullable for class Color.");
throw new JsonException("Property is not nullable for class Color: b.");

if (g.IsSet && g.Value == null)
throw new ArgumentNullException(nameof(g), "Property is not nullable for class Color.");
throw new JsonException("Property is not nullable for class Color: g.");

if (r.IsSet && r.Value == null)
throw new ArgumentNullException(nameof(r), "Property is not nullable for class Color.");
throw new JsonException("Property is not nullable for class Color: r.");

return new Color(b, g, r);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public override NullTypeDirect Read(ref Utf8JsonReader utf8JsonReader, Type type
}

if (id.IsSet && id.Value == null)
throw new ArgumentNullException(nameof(id), "Property is not nullable for class NullTypeDirect.");
throw new JsonException("Property is not nullable for class NullTypeDirect: id.");

return new NullTypeDirect(alwaysNull, id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ public override Shape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}

if (!shapeType.IsSet)
throw new ArgumentException("Property is required for class Shape.", nameof(shapeType));
throw new JsonException("Property is required for class Shape: shapeType.");

if (shapeType.IsSet && shapeType.Value == null)
throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape.");
throw new JsonException("Property is not nullable for class Shape: shapeType.");

if (area.IsSet && area.Value == null)
throw new ArgumentNullException(nameof(area), "Property is not nullable for class Shape.");
throw new JsonException("Property is not nullable for class Shape: area.");

return new Shape(shapeType.Value!, area);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ public override ShapeOrNull Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}

if (!shapeType.IsSet)
throw new ArgumentException("Property is required for class ShapeOrNull.", nameof(shapeType));
throw new JsonException("Property is required for class ShapeOrNull: shapeType.");

if (shapeType.IsSet && shapeType.Value == null)
throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull.");
throw new JsonException("Property is not nullable for class ShapeOrNull: shapeType.");

if (area.IsSet && area.Value == null)
throw new ArgumentNullException(nameof(area), "Property is not nullable for class ShapeOrNull.");
throw new JsonException("Property is not nullable for class ShapeOrNull: area.");

return new ShapeOrNull(shapeType.Value!, area);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,16 @@ public override Widget Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}

if (!id.IsSet)
throw new ArgumentException("Property is required for class Widget.", nameof(id));
throw new JsonException("Property is required for class Widget: id.");

if (!name.IsSet)
throw new ArgumentException("Property is required for class Widget.", nameof(name));
throw new JsonException("Property is required for class Widget: name.");

if (id.IsSet && id.Value == null)
throw new ArgumentNullException(nameof(id), "Property is not nullable for class Widget.");
throw new JsonException("Property is not nullable for class Widget: id.");

if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class Widget.");
throw new JsonException("Property is not nullable for class Widget: name.");

return new Widget(id.Value!.Value!, name.Value!, color, debugInfo, shape);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override TestObject Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}

if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class TestObject.");
throw new JsonException("Property is not nullable for class TestObject: name.");

return new TestObject(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
}

if (activityOutputs.IsSet && activityOutputs.Value == null)
throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity.");
throw new JsonException("Property is not nullable for class Activity: activity_outputs.");

return new Activity(activityOutputs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8
}

if (prop1.IsSet && prop1.Value == null)
throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation.");
throw new JsonException("Property is not nullable for class ActivityOutputElementRepresentation: prop1.");

if (prop2.IsSet && prop2.Value == null)
throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation.");
throw new JsonException("Property is not nullable for class ActivityOutputElementRepresentation: prop2.");

return new ActivityOutputElementRepresentation(prop1, prop2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,25 +280,25 @@ public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader
}

if (emptyMap.IsSet && emptyMap.Value == null)
throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass.");
throw new JsonException("Property is not nullable for class AdditionalPropertiesClass: empty_map.");

if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null)
throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
throw new JsonException("Property is not nullable for class AdditionalPropertiesClass: map_of_map_property.");

if (mapProperty.IsSet && mapProperty.Value == null)
throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
throw new JsonException("Property is not nullable for class AdditionalPropertiesClass: map_property.");

if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null)
throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass.");
throw new JsonException("Property is not nullable for class AdditionalPropertiesClass: map_with_undeclared_properties_anytype_1.");

if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null)
throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass.");
throw new JsonException("Property is not nullable for class AdditionalPropertiesClass: map_with_undeclared_properties_anytype_2.");

if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null)
throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass.");
throw new JsonException("Property is not nullable for class AdditionalPropertiesClass: map_with_undeclared_properties_anytype_3.");

if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null)
throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass.");
throw new JsonException("Property is not nullable for class AdditionalPropertiesClass: map_with_undeclared_properties_string.");

return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}

if (!className.IsSet)
throw new ArgumentException("Property is required for class Animal.", nameof(className));
throw new JsonException("Property is required for class Animal: className.");

if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal.");
throw new JsonException("Property is not nullable for class Animal: className.");

if (color.IsSet && color.Value == null)
throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal.");
throw new JsonException("Property is not nullable for class Animal: color.");

return new Animal(color);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}

if (code.IsSet && code.Value == null)
throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse.");
throw new JsonException("Property is not nullable for class ApiResponse: code.");

if (message.IsSet && message.Value == null)
throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse.");
throw new JsonException("Property is not nullable for class ApiResponse: message.");

if (type.IsSet && type.Value == null)
throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse.");
throw new JsonException("Property is not nullable for class ApiResponse: type.");

return new ApiResponse(code, message, type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}

if (colorCode.IsSet && colorCode.Value == null)
throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple.");
throw new JsonException("Property is not nullable for class Apple: color_code.");

if (cultivar.IsSet && cultivar.Value == null)
throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple.");
throw new JsonException("Property is not nullable for class Apple: cultivar.");

if (origin.IsSet && origin.Value == null)
throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple.");
throw new JsonException("Property is not nullable for class Apple: origin.");

return new Apple(colorCode, cultivar, origin);
}
Expand Down
Loading
Loading