swagger-api / swagger-api/swagger-ui
curl commands containing spaces won't execute in Linux terminals
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
| Q | A |
|---|---|
| Bug or feature request? | Bug |
| Which Swagger/OpenAPI version? | 2.0 |
| Which Swagger-UI version? | 3.11.0 |
| How did you install Swagger-UI? | Used dist directory for own version, verified on SwaggerUI demo |
| Which browser & version? | 64.0.3282.167 |
| Which operating system? | Ubuntu 16.04 LTS |
Expected Behavior
The generated curl available in the UI should be immediately executable when it's copied to a terminal, even if the address contains spaces.
Current Behavior
On operations that contain spaces, the generated curl cannot be executed within a linux console.
For example, this operation: POST /v1/commands/apps/list disabled results in a 400 error if you try to execute the resulting curl:
curl -X POST "http://localhost:1234/v1/commands/apps/list disabled" -H "accept: application/json"
Possible Solution
Replacing the spaces with %20 fixes the issue:
curl -X POST "http://localhost:1234/v1/commands/apps/list%20disabled" -H "accept: application/json"
Context
We are representing some underlying API that unfortunately allows spaces in its naming convention. Developers attempting to quickly script REST communications were held up.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Swagger UI generated curl output and reproduce the example operation with a space in its path on Ubuntu. The work is done when the copied command encodes the space as %20 and executes successfully, while existing generated curl behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100