| 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
The generated curl available in the UI should be immediately executable when it's copied to a terminal, even if the address contains spaces.
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"
Replacing the spaces with %20 fixes the issue:
curl -X POST "http://localhost:1234/v1/commands/apps/list%20disabled" -H "accept: application/json"
We are representing some underlying API that unfortunately allows spaces in its naming convention. Developers attempting to quickly script REST communications were held up.
Thanks for the report, but it would really help having an API definition that reproduces the problem.
Here is a definition reproducing the issue:
petstore.swagger.io/?...url=http://heldersepu.github.io/hs-scripts/swagger/4263_swagger.yaml
I thing the Possible solution will be on:
https://github.com/swagger-api/swagger-ui/blob/master/src/core/curlify.js#L9
But is replacing spaces with %20 all we need? or are there other problematic characters?
Thank you Helder, that's the situation I was describing.
I was looking at other chars that could be causing problems the # is a problem too...
http://swagger-net-test.azurewebsites.net/swagger/ui/index?filter=ArrayTest#/ArrayTest/ArrayTest_Put
And that one is causing bigger problems in the UI
@dotasek can you please clarify
Replacing the spaces with %20 fixes the issue:
what's %20 mean ?
curl expects that the URL is properly URL-encoded. The https://tools.ietf.org/html/rfc3986#section-2 explains what has to be encoded.
@vikramvi "%20" is simply an ASCII code for space written in hexadecimal.
Most helpful comment
Here is a definition reproducing the issue:
petstore.swagger.io/?...url=http://heldersepu.github.io/hs-scripts/swagger/4263_swagger.yaml
I thing the Possible solution will be on:
https://github.com/swagger-api/swagger-ui/blob/master/src/core/curlify.js#L9
But is replacing spaces with
%20all we need? or are there other problematic characters?