-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[BUG][csharp-netcore] ParameterToMultiMap method generates inconsistent MultiMap for Dictionary as compared to Swagger UI #8798
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
Comments
Interesting. I think Swagger UI might actually be in the wrong here. What you show only works if you don't actually specify the parameter name in aspnetcore in FromQuery. Which is something that was fixed by me recently as it introduced a different bug when parameter names contained an underscore. Going by the spec you posted I would expect that the swagger ui creates an object called args. |
I just tested it out by adding another parameter to the list. Without the change I made to the aspnetcore generator it gets picked up as an additional dictionary entry, which makes no sense, as its supposed to be a separate parameter. Swagger UI indeed creates a flat object there (which is wrong). |
After further investigation it appears you are also right in that the generated client code ALSO doesn't bind correctly to the query parameter. |
What you actually want as an api spec is the following:
Note the added deepObject. This currently breaks with the default codegen in general however, as deepObject expects (though according to the spec might not need) a schema. I'll try to fix that. |
This seems related: OAI/OpenAPI-Specification#1006, as does this: #469 |
Pull request to fix this is up |
Bug Report Checklist
Description
In my GET API, I have a Dictionary<string, string> as parameter.
When I run it in Swagger UI, the URL it generated does not include the name of the dictionary and my controller is able to receive the KeyValues of the dictionary.
When I use the codegen to generate the client library and run the same method. The URL includes the name of the dictionary itself and my controller is not able to receive any value in the dictionary.
openapi-generator version
I use openapi-generator-cli-5.0.0-beta3
OpenAPI declaration file content or url
Parameter part of the schema
Generation Details
Steps to reproduce
args : {
"key1": "value1",
"key2": "value2"
}
Related issues/PRs
Suggest a fix
It seems to be the problem within the query parameter generation process i.e. ParameterToMultiMap. Please fix it to be consistent with Swagger UI ASAP. Thank you.
The text was updated successfully, but these errors were encountered: