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

Provide more control over quotes used in curl and HTTPie request snippets #650

Open
ke4 opened this issue Oct 15, 2019 · 1 comment
Open

Comments

@ke4
Copy link

ke4 commented Oct 15, 2019

Currently Spring REST Docs generates snippets using single quotes around header values:

$ curl 'https://some.url.com/teams' -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/hal+json' -H 'Authorization: Bearer $TOKEN' -d '{ "name" : "Test Team" }'

In the above generated curl request $TOKEN would be an environmental variable, but because of the single quotes the variable substitution would not work.
This behaviour is hard coded in CurlRequestSnippet at this line:
https://github.com/spring-projects/spring-restdocs/blob/master/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CurlRequestSnippet.java#L148

As I checked that class I realised that the single quotes are hardcoded in each writer methods of the CurlRequestSnippet class.

Is it possible to change this behaviour either to change the single quotes to double quotes or make it configurable?

I asked this question on Stack Overflow: https://stackoverflow.com/questions/58208877/how-to-create-a-curl-snippet-with-spring-rest-docs-to-use-double-quotes-instead/58211173?noredirect=1#comment102822959_58211173
Andy Wilkinson (@wilkinsona) from the Spring team asked me to create a github issue related to this problem.

@wilkinsona wilkinsona changed the title Improve header generation for the generated code snippets Provide more control over quotes used in curl and HTTPie request snippets Oct 15, 2019
@wilkinsona
Copy link
Member

wilkinsona commented Oct 15, 2019

See #55, which switched things, for good reasons, to consistently use single quotes.

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

No branches or pull requests

3 participants