-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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#/aspnetcore] Invalid C# code generated with version 7.4.0 #18081
Comments
Hi @wing328 , I think we can safely revert the change and I'll try to do a safer change next time. In the end, it needs to "accumulate" all the reason to be nullable and only render one Do you take care of the revert or do you want me to do it @wing328 ? |
There is OptionalParameterLambda which can mitigate this. |
We are having the same issues with the latest versions and a C# 6 / ASP.NET Core 6 codebase. We forced our build process to v7.3.0 for now. |
@mpo-wd if you or anyone would like to contribute a PR or sponsor the fix, please let us know. |
@wing328 I will definitely try to do a fix in the upcoming weeks but if someone can chime in before that, I will do the review. |
PR merged. thanks for the fix |
Bug Report Checklist
Description
The latest release (v7.4.0) can generate C# code that does not compile when generating for aspnetcore and setting nullableReferenceTypes=true.
It happens when a property is optional and declared with "nullable: true". See the
problem
property in the example OpenAPI document. In the model class it generates the property where the type is declared with double question marks (??) instead of a single question mark.Using version v7.3.0 it works fine.
openapi-generator version
7.4.0
OpenAPI declaration file content or url
Generation Details
Using docker image:
docker run --rm --user $(id -u) -v $(pwd)/Documentation:/local openapitools/openapi-generator-cli:latest-release generate -i /local/api.yaml -o /local/Generated -g aspnetcore -p nullableReferenceTypes=true
or cli
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ~/api.yaml -o ./output -g aspnetcore -p nullableReferenceTypes=true
Steps to reproduce
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ~/api.yaml -o ./output -g aspnetcore -p nullableReferenceTypes=true
dotnet build output/
Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: