Provide more control over quotes used in curl and HTTPie request snippets
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 50/100
Research direction
Start with spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CurlRequestSnippet.java, especially line 148 and the other writer methods where single quotes are hardcoded. Review how curl and HTTPie request snippets are generated, then define the quote behavior requested by the issue. Done means generated requests support the chosen quote behavior and allow $TOKEN substitution when double quotes are used.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 731
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spring-projects/spring-restdocs
-
status: waiting-for-triage
Difficulty 5/5 Over a week Newbie friendliness 45/100
spring-projects/spring-restdocs#1026 · 2 comments ·
-
status: waiting-for-votes type: enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
spring-projects/spring-restdocs#1020 · 6 comments ·
-
type: enhancement
spring-projects/spring-restdocs#995 · 1 assignee ·
-
status: blocked status: waiting-for-triage
Difficulty 4/5 3-5 days Newbie friendliness 35/100
spring-projects/spring-restdocs#953 · 7 comments ·
-
type: enhancement
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in spring-projects/spring-restdocs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100