OpenAPITools / OpenAPITools/openapi-generator
[BUG] C# generator creates invalid property signature for nullable dictionaries
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
We're having the issue the the ASP.NET c# code generator returns a wrong format for nullable dictionaries. Right now, the output is as follows:
public Dictionary?<string, string> MyProperty { get; set; }
However, in c#, the ? has to be placed behind th data type. So the correct format would be:
public Dictionary<string, string>? MyProperty { get; set; }
Here's the example model in TypeSpec and OpenAPI:
model TestModel {
myProperty?: Record<string> | null;
}
openapi: 3.0.0
info:
title: (title)
version: 0.0.0
tags: []
paths: {}
components:
schemas:
TestModel:
type: object
properties:
myProperty:
type: object
additionalProperties:
type: string
nullable: true
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the provided TypeSpec model and OpenAPI document as the reproduction input for the C# generator. Compare the generated property declaration with the expected nullable dictionary signature; done means the output places the nullable marker after the dictionary type and remains valid C#.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100