swagger-api / swagger-api/swagger-ui

Curl Acts Different Then On Page Try it for header string with pipe in it

Open
#4,920 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: try-it-out Hacktoberfest 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: Windows 10
  • Browser: chrome
  • Version: 68.0.3440.106
  • Method of installation: Swashbuckle
  • Swagger-UI version:
  • Swagger/OpenAPI version: Swagger 2.0
Content & configuration

I have configured swashbuckle to attach a json header to every request
image

How can we help?

When I use the "Try it out" feature it works as expected and I see my browser sending the json out in the header:
image

When I try to copy and paste the curl command to my Cygwin bash for git for windows I see that the pipe in the header was not properly escaped so the command fails:
curl -X GET "http://localhost:26419/api/Widget/{id}" -H "accept: application/json" -H "CUSTOM_HEADER: [{"Type":"PIPE|test","Value":"value"},{"Type":"test2","Value":"value2"}]"
image

Is it fair to think that the UI should escape the header value for anything bash may miss-interpret so that the experience between the "Try it out" and curl is the same?

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 from Swagger UI's generated curl command in the Try it out flow and reproduce the issue with a header value containing a pipe, using the command shown in the report. Done means the copied command preserves the header value and behaves like the in-page request in Cygwin bash.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, javascript
Domain
api, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.