-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[csharp-netcore] Fixed handling of nullable enum values #6112
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only an enum with type generation can be determined here.
@@ -423,10 +423,6 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert | |||
postProcessEmitDefaultValue(property.vendorExtensions); | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.sh
if 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
.