Skip to content

[BUG] [CSHARP] [GENERICHOST] OptionProperty.mustache and JsonConverter.mustache use different Option<T> nullability handlings. #23530

@laazik

Description

@laazik

{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} = {{>OptionProperty}}JsonSerializer.Deserialize<DateTime{{#useDateTimeOffset}}Offset{{/useDateTimeOffset}}{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions));

OptionProperty.mustache uses x-is-value-type to decide if ? is needed.

JsonConverter.mustache uses isNullable from the OpenAPI spec for the same decision on the same property.

Consequence is that marking a DateTime field nullable: true in spec has zero effect on the deserialization path — the non-nullable converter is used regardless.

Proposed fix is to mark all value types as nullable, which would match the contract set in the OptionProperty.mustache (which sets the value types as nullable).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions