Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dollar sign not works on copy / paste of curl command line #5390

Closed
jbarotin opened this issue Jun 5, 2019 · 4 comments · Fixed by #6245
Closed

Dollar sign not works on copy / paste of curl command line #5390

jbarotin opened this issue Jun 5, 2019 · 4 comments · Fixed by #6245

Comments

@jbarotin
Copy link

jbarotin commented Jun 5, 2019

Content & configuration

I'm using swagger-ui to document an odata api

The curl command generated looks like this one :

curl -X GET "https://myservice.net/odata/v4/Items?$top=3" -H  "accept: application/json"

Is your feature request related to a problem?

A copy / copy and paste of the following command line (on Unix based OS), the url will be interpreted as https://myservice.net/odata/v4/Items?=3

Describe the solution you'd like

In order to make sure the dollar is not interpreted, it would be nice to have this kind of command line with parameter using single quote.

curl -X GET 'https://myservice.net/odata/v4/Items?$top=3' -H  'accept: application/json'

Describe alternatives you've considered

Otherwise dollar could be escaped, but I'm not sure it works under Windows :

curl -X GET "https://myservice.net/odata/v4/Items?\$top=3" -H  "accept: application/json"

Maybee using the url encoding code :

curl -X GET "https://myservice.net/odata/v4/Items?%24top=3" -H  "accept: application/json" 
@jbarotin jbarotin changed the title Ability to choose single quote or double quote for curl parameters Dollar sign not work on copy / past of curl command line Jun 5, 2019
@jbarotin jbarotin changed the title Dollar sign not work on copy / past of curl command line Dollar sign not works on copy / paste of curl command line Jun 5, 2019
@shockey
Copy link
Contributor

shockey commented Jun 5, 2019

Depending on the tradeoffs, it might be better to just always use singlequotes.

@shockey
Copy link
Contributor

shockey commented Jun 25, 2019

per @hkosova:

single quotes are for Bash and won't work in Windows cmd

@jbarotin
Copy link
Author

Also, the "Add a backslash before '$'" solution is fine to me

@shockey
Copy link
Contributor

shockey commented Jul 2, 2019

Yeah, perhaps we should just be using an escape library (a la shell-escape).

Conveniently, we do build up an args array in our curlify function:

let curlified = []
let type = ""
let headers = request.get("headers")
curlified.push( "curl" )
curlified.push( "-X", request.get("method") )
curlified.push( `"${request.get("url")}"`)

harpocrates added a commit to harpocrates/swagger-ui that referenced this issue Jul 21, 2020
This address a bug where a `$` character in a request body or header
would not be properly escaped in a string in the generated curl command.

Fixes swagger-api#5390
harpocrates added a commit to harpocrates/swagger-ui that referenced this issue Jul 29, 2020
This address a bug where a `$` character in a request body or header
would not be properly escaped in a string in the generated curl command.

Fixes swagger-api#5390
harpocrates added a commit to harpocrates/swagger-ui that referenced this issue Jul 29, 2020
This address a bug where a `$` character in a request body or header
would not be properly escaped in a string in the generated curl command.

Fixes swagger-api#5390
tim-lai pushed a commit that referenced this issue Aug 3, 2020
This address a bug where a `$` character in a request body or header
would not be properly escaped in a string in the generated curl command.

Fixes #5390
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants