-
Notifications
You must be signed in to change notification settings - Fork 367
Data in cURL examples is not quoted properly #58
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
Comments
If I was at home, I'd fork and fix it but I believe the double-quotes here just need to be changed to single quotes. |
Temporary fix, put this into spec/support/api_doc.rb RspecApiDocumentation::Curl # force autoload
module RspecApiDocumentation
class Curl
def post_data
escaped_data = data.gsub('"', '\\"')
"-d \"#{escaped_data}\""
end
end
end This should be updated, I ran into this issue as well. |
A little better, quote in single quotes and escape any single quote (can't use ', but \u0027 works). RspecApiDocumentation::Curl
module RspecApiDocumentation
class Curl
def post_data
escaped_data = data.gsub("'", "\\u0027")
"-d '#{escaped_data}'"
end
end
end |
The cURL examples genreated when doing a POST or PUT don't properly quote the data associated with the
-d
flag.For example, the rad-example app has the following cURL example for creating an order:
source: http://rad-example.herokuapp.com/docs/orders/creating_an_order
If you copy/paste that example it'll fail because the data uses all double quotes. Instead the outer quotes should be single quotes such as:
The text was updated successfully, but these errors were encountered: