You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
The text was updated successfully, but these errors were encountered: