OpenAPITools / OpenAPITools/openapi-generator

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

Open Beginner friendly
#23,530 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

https://github.com/OpenAPITools/openapi-generator/blob/d11d0efaf096da702d9640bf8ac86b12d8d62a73/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache#L224

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with JsonConverter.mustache at the linked line and compare its nullability handling with OptionProperty.mustache. Trace how both templates handle the same property, especially nullable DateTime fields. Done means the generated deserialization path uses the same value-type nullability contract as OptionProperty.mustache.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.