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

[C#] Fix non-nullable enums on operation parameters not compiling #1543

Merged
merged 5 commits into from
Dec 3, 2018

Conversation

rubms
Copy link
Contributor

@rubms rubms commented Nov 26, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

C.C. @mandrean (2017/08) @jimschubert (2017/09)

Description of the PR

Fixed issue #1531 which caused enums used as non-required operation parameters to generate a C# code that does not compile. The reason for the error was that these enums were not generated as Nullable but they where being assigned null and compared to null.

I have fixed the error by:

  • Adding a piece of code in the csharp api.mustache template, that adds a ? after parameter data types when the parameter is non-required and non-nullable.
  • Correctly marking the isEnum and isNullable properties of operation parameters in the post-process performed in AbstractCsharpCodegen.

rubms and others added 5 commits August 1, 2018 13:16
…t-processed to correctly mark them as enumerations. The api.mustache C# template now marks parameters as nullable when they're non-required enums.
…interface of the auto-generated C# Apis.
…uplicated nullable question marks for primitive types.
@wing328 wing328 added this to the 4.0.0 milestone Dec 3, 2018
@wing328 wing328 merged commit e3ab059 into OpenAPITools:master Dec 3, 2018
@wing328 wing328 changed the title [csharp] Fix #1531 with non-nullable enums on operation parameters not compiling [csharp] Fix non-nullable enums on operation parameters not compiling Dec 3, 2018
@wing328 wing328 changed the title [csharp] Fix non-nullable enums on operation parameters not compiling [C#] Fix non-nullable enums on operation parameters not compiling Dec 3, 2018
@wing328
Copy link
Member

wing328 commented Dec 3, 2018

@rubms as discussed, we'll focus on the refactored C# client moving forward and will add better nullable support (which may undo some of the changes in this request)

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
…arameters not compiling (OpenAPITools#1543)

* Run ./bin/utils/ensure-up-to-date to re-generate samples run in the CI.

* Fixed issue OpenAPITools#1531. Now in C# operation parameters are post-processed to correctly mark them as enumerations. The api.mustache C# template now marks parameters as nullable when they're non-required enums.

* OpenAPITools#1531 Added fix for enum, non-required parameters to the interface of the auto-generated C# Apis.

* Fixed error with the development of ticket OpenAPITools#1531, which duplicated nullable question marks for primitive types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants