swagger-api / swagger-api/swagger-codegen

[csharp-dotnet2] Why QueryParams are no added as QueryParameters?

Open
#9,838 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I think that for RestSharp should be correct to Add queryParams as ParameterType.QueryString or should be use de request.AddQueryParamter() function.

Swagger declaration file content or url

csharp-dotnet2/ApiClient.mustache

Steps to reproduce

If you call to API with POST Method with QueryString, in your server application with you have generated the ApiClient project, you'll not get the query parameters. It is due to in RestSharp, the Query parameters are Get like this

Suggest a fix/enhancement

Add the queryParams in the restRequest like:
request.AddQueryParameter(param.Key, param.Value);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at modules/swagger-codegen/src/main/resources/csharp-dotnet2/ApiClient.mustache, around line 83, and inspect how query parameters are added to RestSharp requests. Reproduce a POST request with query parameters using a generated client and confirm the generated request includes them as query parameters; done means the server receives them.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.