[csharp-netcore] Fixed handling of nullable enum values#6112
[csharp-netcore] Fixed handling of nullable enum values#6112wing328 merged 3 commits intoOpenAPITools:masterfrom shibayan:enum-nullable
Conversation
| 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); |
There was a problem hiding this comment.
Only at this timing isEnum is set to the correct value
| parameter.isEnum = true; | ||
| parameter.allowableValues = model.allowableValues; | ||
| parameter.isPrimitiveType = true; | ||
| parameter.vendorExtensions.put("x-csharp-value-type", true); |
There was a problem hiding this comment.
Only an enum with type generation can be determined here.
| super.postProcessModelProperty(model, property); | ||
|
|
||
| if (!property.isContainer && (nullableType.contains(property.dataType) || property.isEnum)) { | ||
| property.vendorExtensions.put("x-csharp-value-type", true); |
There was a problem hiding this comment.
isEnum is always false at this timing
| {{^vendorExtensions.x-csharp-value-type}} | ||
| {{#required}} | ||
| localVarRequestOptions.PathParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // path parameter | ||
| {{/required}} |
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.
|
@mandrean (2017/08), @jimschubert (2017/09) ❤️ @frankyjuang (2019/09) @shibayan (2020/02) |
|
@shibayan thanks for fix. Let's go with what you've filed. |
|
@shibayan thanks for the PR, which has been included in the v4.3.1 release: https://twitter.com/oas_generator/status/1258057660974329861 |
…#6112) * [csharp-netcore] Fixed handling of nullable enum values * Update sample code * Remove unnecessary method calls
…#6112) * [csharp-netcore] Fixed handling of nullable enum values * Update sample code * Remove unnecessary method calls
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.