swagger-api / swagger-api/swagger-codegen

[C#] Generator does not respect application/json content for GET query parameters

Open
#11,099 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 define a path in my OAS file that specifies a query parameter as a JSON array. The codegen produces multiple query parameters instead of one parameter containing the JSON array.

The generated client makes the following call:
GET https://<redacted>/file/search/?q=QueryText&types=File&types=Dir

The correct call should be:
GET https://<redacted>/file/search/?q=QueryText&types=%5B%22file%22%2C%22dir%22%5D

Swagger-codegen version

I'm using the version on SwaggerHub.

Swagger declaration file content or url

Gist of OAS: https://gist.github.com/kaburke/e44549b4e3ef31aacb117d378237b39e

Command line used for generation

SwaggerHug was used.

Steps to reproduce
  1. Generate C# client using the given OAS file.
  2. Make a call to the SearchFileSystem method.

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

Reproduce generation with the OAS gist and SwaggerHug, then inspect the generated C# SearchFileSystem method and its query-parameter serialization. Compare the current repeated types parameters with the JSON-array request shown in the issue. Done means a generated client sends one URL-encoded JSON array for the application/json query parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.