swagger-api / swagger-api/swagger-ui

Inconsistency in the cURLs generated via the swagger-ui and swagger editor

Open
#5,284 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When creating an API resource with a multipart/form-data file upload parameter, the swagger editor and the swagger-UI generates the cURL commands differently.

Q&A (please complete the following information)
  • OS: macOS
  • Browser: chrome
  • Version: [e.g. 22]
  • Method of installation: dist assets
  • Swagger-UI version: 3.22.0
  • Swagger/OpenAPI version: Swagger 2.0
Example Swagger/OpenAPI definition:
swagger: "2.0"
paths:
  /file:
    post:
      parameters:
        - name: file
          in: formData
          required: true
          type: file
      responses:
        "200":
          description: ""
      x-auth-type: "Application & Application User"
      x-throttling-tier: Unlimited
      consumes:
        - multipart/form-data
info:
  title: test
  version: v1
Describe the bug you're encountering

When an API is created from the swagger file provided, the swagger-UI will generate the cURL as follows
curl -k -X POST "https://host:port/test/v1/file" -H "accept: application/json" -H "Content-Type: multipart/form-data" -H "Authorization: Bearer d779534f-ff49-357f-a9e6-64be590df7e6" -d {"file":{}}

However, the swagger editor generates the cURL in the following format;
curl -X POST "https://host:port/file" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "file=@image.png;type=image/png"

The swagger-UI presents the file data as -d {"file":{}} where as the swagger editor presents it as -F "file=@image.png;type=image/png"

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 discrepancy in swagger-ui and the swagger editor using the supplied Swagger 2.0 multipart/form-data definition. Compare the generated cURL for the file parameter, then verify that the completed behavior uses the expected multipart file form syntax consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, frontend
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.