Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 949eea6

Browse files
fkalinowskijmisur
authored andcommitted
Disable interpolation of Asciidoctor for the path part of the Rest Enpoint (#327)
* Disable interpolation of Asciidoctor for the path part of the Rest Endpoint Previously, when generating Asciidoctor snipppets, based on this template, the path parameter was interpolated. This was considered by Asciidoctor as an attributes which are typically surrounded by { and }. This commit surrounds the path with + characters which disables all interpolation. Closes #326 * Review unit test after having surrounded the content of 'default-auto-method-path.snippet' with a '+' to avoid interpolating path variables Closes #326
1 parent 259e879 commit 949eea6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
`{{method}} {{path}}`
1+
`+{{method}} {{path}}+`

spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.junit.Test;
2727
import org.springframework.restdocs.AbstractSnippetTests;
2828
import org.springframework.restdocs.templates.TemplateFormat;
29+
import org.springframework.restdocs.templates.TemplateFormats;
2930
import org.springframework.web.method.HandlerMethod;
3031

3132
public class MethodAndPathSnippetTest extends AbstractSnippetTests {
@@ -45,7 +46,12 @@ public void simpleRequest() throws Exception {
4546
.method("POST")
4647
.build());
4748

48-
assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`POST /test`");
49+
if (TemplateFormats.asciidoctor().equals(this.templateFormat)) {
50+
assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`+POST /test+`");
51+
}
52+
else {
53+
assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`POST /test`");
54+
}
4955
}
5056

5157
@Test
@@ -56,7 +62,12 @@ public void noHandlerMethod() throws Exception {
5662
.method("POST")
5763
.build());
5864

59-
assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`POST /test`");
65+
if (TemplateFormats.asciidoctor().equals(this.templateFormat)) {
66+
assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`+POST /test+`");
67+
}
68+
else {
69+
assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`POST /test`");
70+
}
6071
}
6172

6273
private static class TestResource {

0 commit comments

Comments
 (0)