swagger-api / swagger-api/swagger-ui

Wrong encoding when omitted

Open
#7,695 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

cat: try-it-out specification: 3.x type: bug
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: macOS]
  • Browser: chrome
  • Version: 96
  • Method of installation: maven
  • Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.0
Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  title: Test API
  version: '1.0'
servers:
  - url: 'http://localhost:3000'
paths:
  /implicit-encoding:
    post:
      summary: Implicit encoding
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                numbers:
                  type: array
                  items:
                    format: int64
                    type: integer
      responses:
        '200':
          description: OK
  /explicit-encoding:
    post:
      summary: Explicit encoding
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                numbers:
                  type: array
                  items:
                    format: int64
                    type: integer
            encoding:
              numbers:
                style: form
                explode: true
      responses:
        '200':
          description: OK
Describe the bug you're encountering
To reproduce...

Steps to reproduce the behavior:

  1. Go to '/implicit-encoding'
  2. Click on 'try it out'
  3. Click on 'add integer item'
  4. Add two or more items
  5. Click on 'execute'
Expected behavior

The data of the curl command should be

  -d 'numbers=1&numbers=2&numbers=3'
Actual behavior

The data of the curl command is

  -d 'numbers=1,2,3'
Additional context or thoughts

The provided explicit-encoding endpoint works as expected.

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 the issue with the provided implicit-encoding and explicit-encoding definitions, following the listed Try it out steps. Trace the form-encoding request generation used by the implicit endpoint and verify that executing it produces repeated numbers parameters in the curl command, matching the explicit endpoint's behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.