Skip to content

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

Open
@ke4

Description

@ke4

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementEnhancement that adds a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions