Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][C#] Generated C# client does not produce nullable response types #20477

Open
4 of 6 tasks
dstepanov25 opened this issue Jan 15, 2025 · 0 comments
Open
4 of 6 tasks

Comments

@dstepanov25
Copy link

dstepanov25 commented Jan 15, 2025

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?0
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When using the OpenAPI Generator CLI (version 7.10.0) to generate a C# client with the nullableReferenceTypes=true option, methods returning a nullable schema do not generate nullable response types (e.g., Task<MyType?>).

openapi-generator version

7.10.0

OpenAPI declaration file content or url

Example.yaml or Example2.yaml

Generation Details

My Environment:

  • Windows 11 Enterprise
  • openjdk version "23.0.1" 2024-10-15

I installed openapi-generator-cli via:
npm install -g @openapitools/openapi-generator-cli

Configuration file:
config.yaml

Steps to reproduce

In my C:\Temp folder I have only Example.yaml and config.yaml files. I'm running next command to generate api in Console:
openapi-generator-cli generate -c config.yaml

As a result I have C:\Temp\output-directory\src\Org.OpenAPITools\Api\DefaultApi.cs with next code:
public async System.Threading.Tasks.Task<MyType> ExamplePostAsync(...
You can find it in attachment DefaultApi.cs.txt.

However, I expected to have
public async System.Threading.Tasks.Task<MyType?> ExamplePostAsync(...

Related issues/PRs
Suggest a fix

Ensure that the C# generator respects the nullableReferenceTypes=true configuration and generates nullable response types (Task<MyType?>) for schemas defined as nullable: true or oneOf with null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant