swagger-api / swagger-api/swagger-ui

[BUG]: Parameters with `content` field are not correctly serialized

Open
#10,661 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

To reproduce...

Paste this OpenAPI definition into https://editor.swagger.io:

openapi: 3.1.0
info: 
  title:
  version:
paths:
  /test:
    get: 
      parameters: 
        - in: query
          name: pet
          content:
            application/json: 
              schema: 
                type: string
      responses: 
        2XX:
          description:
          content: 
            application/json: 
              schema:
                type: object
Describe the bug you're encountering

When filling the parameter in Swagger UI the produced request looks like this:

curl -X 'GET' \
  'https://editor.swagger.io/test?pet=cat' \
  -H 'accept: application/json'

The parameter pet is not properly serialized.

Expected behavior

Query string should look like this: %22cat%22 which is percent encoded from "cat" since definition of the pet parameter uses content application/json.
And the curl snippet should look like this:

curl -X 'GET' \
  'https://editor.swagger.io/test?pet=%22cat%22' \
  -H 'accept: application/json'

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 with the OpenAPI definition in the issue and reproduce it in https://editor.swagger.io. Trace how a query parameter using a content schema is serialized and how the generated curl snippet reflects that request. Done means the parameter value is JSON-encoded and percent-encoded as %22cat%22 in both the request and curl output.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.