-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fix unwanted query parameter explosion in generated c# client #4310
base: master
Are you sure you want to change the base?
Conversation
Note: this doesn't fix the OpenApi 2.0 variant: |
@@ -6,8 +6,13 @@ foreach (var item_ in {{ parameter.VariableName }}) { urlBuilder_.Append(System. | |||
urlBuilder_.Append(System.Uri.EscapeDataString("{{ parameter.Name }}") + "=").Append(System.Uri.EscapeDataString({% if parameter.IsNullable and parameter.IsRequired %}{{ parameter.VariableName }} != null ? {% endif %}{{ parameter.VariableName }}{% if parameter.IsSystemNullable %}.Value{% endif %}.ToString("{{ ParameterDateTimeFormat }}", System.Globalization.CultureInfo.InvariantCulture){% if parameter.IsNullable and parameter.IsRequired %} : "{{ QueryNullValue }}"{% endif %})).Append("&"); | |||
{% elsif parameter.IsDate -%} | |||
urlBuilder_.Append(System.Uri.EscapeDataString("{{ parameter.Name }}") + "=").Append(System.Uri.EscapeDataString({% if parameter.IsNullable and parameter.IsRequired %}{{ parameter.VariableName }} != null ? {% endif %}{{ parameter.VariableName }}{% if parameter.IsSystemNullable %}.Value{% endif %}.ToString("{{ ParameterDateFormat }}", System.Globalization.CultureInfo.InvariantCulture){% if parameter.IsNullable and parameter.IsRequired %} : "{{ QueryNullValue }}"{% endif %})).Append("&"); | |||
{% elsif parameter.IsArray -%} | |||
{% elsif parameter.IsArray and parameter.Explode == 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.
Should also test for "collectionFormat": "csv",
Hey, can this pull request be considered for merging in near future? This bug is already quite old and it is an easy fix. |
Hey, are any changes needed for this PR? |
Per default NSwag ignores if array parameters should be exploded or not.
So as of now a request containing multiple IDs generates the following:
/users?id=3&id=4&id=5
As per specification we do not want to specify the parameter name every time in case
explode
is set to false.Instead we expect
/users?id=3,4,5
.