[csharp-netcore] Fixed handling of nullable enum values#6112
Merged
wing328 merged 3 commits intoOpenAPITools:masterfrom May 2, 2020
shibayan:enum-nullable
Merged
[csharp-netcore] Fixed handling of nullable enum values#6112wing328 merged 3 commits intoOpenAPITools:masterfrom shibayan:enum-nullable
wing328 merged 3 commits intoOpenAPITools:masterfrom
shibayan:enum-nullable
Conversation
shibayan
commented
Apr 29, 2020
| if (model != null) { | ||
| for (CodegenProperty var : model.vars) { | ||
| if (!var.isContainer && (nullableType.contains(var.dataType) || var.isEnum)) { | ||
| var.vendorExtensions.put("x-csharp-value-type", true); |
Contributor
Author
There was a problem hiding this comment.
Only at this timing isEnum is set to the correct value
shibayan
commented
Apr 29, 2020
| parameter.isEnum = true; | ||
| parameter.allowableValues = model.allowableValues; | ||
| parameter.isPrimitiveType = true; | ||
| parameter.vendorExtensions.put("x-csharp-value-type", true); |
Contributor
Author
There was a problem hiding this comment.
Only an enum with type generation can be determined here.
shibayan
commented
Apr 29, 2020
| super.postProcessModelProperty(model, property); | ||
|
|
||
| if (!property.isContainer && (nullableType.contains(property.dataType) || property.isEnum)) { | ||
| property.vendorExtensions.put("x-csharp-value-type", true); |
Contributor
Author
There was a problem hiding this comment.
isEnum is always false at this timing
shibayan
commented
Apr 29, 2020
| {{^vendorExtensions.x-csharp-value-type}} | ||
| {{#required}} | ||
| localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter | ||
| {{/required}} |
Contributor
Author
There was a problem hiding this comment.
It has been confirmed that required parameters have values at the beginning of the method regardless of whether they are nullable.
Contributor
Author
|
@mandrean (2017/08), @jimschubert (2017/09) ❤️ @frankyjuang (2019/09) @shibayan (2020/02) |
6 tasks
Member
|
@shibayan thanks for fix. Let's go with what you've filed. |
Member
|
@shibayan thanks for the PR, which has been included in the v4.3.1 release: https://twitter.com/oas_generator/status/1258057660974329861 |
michaelpro1
pushed a commit
to michaelpro1/openapi-generator
that referenced
this pull request
May 7, 2020
…#6112) * [csharp-netcore] Fixed handling of nullable enum values * Update sample code * Remove unnecessary method calls
MikailBag
pushed a commit
to MikailBag/openapi-generator
that referenced
this pull request
May 31, 2020
…#6112) * [csharp-netcore] Fixed handling of nullable enum values * Update sample code * Remove unnecessary method calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an issue where the enum type is not properly treated as nullable.
Fixed #5442
PR checklist
./bin/(or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).master,4.3.x,5.0.x. Default:master.