$ curl 'http://localhost:8080/items/1' -i -X GET
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/SnippetRegistry.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/SnippetRegistry.java
index 399fd805..f05e09bf 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/SnippetRegistry.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/SnippetRegistry.java
@@ -26,20 +26,34 @@
import org.springframework.restdocs.operation.Operation;
public class SnippetRegistry {
- public static final String AUTHORIZATION = "auto-authorization";
- public static final String DESCRIPTION = "auto-description";
- public static final String METHOD_PATH = "auto-method-path";
- public static final String PATH_PARAMETERS = "auto-path-parameters";
- public static final String REQUEST_HEADERS = "auto-request-headers";
- public static final String REQUEST_PARAMETERS = "auto-request-parameters";
- public static final String REQUEST_FIELDS = "auto-request-fields";
- public static final String RESPONSE_FIELDS = "auto-response-fields";
- public static final String LINKS = "auto-links";
- public static final String EMBEDDED = "auto-embedded";
+ // Spring Auto REST Docs snippets
+ public static final String AUTO_AUTHORIZATION = "auto-authorization";
+ public static final String AUTO_DESCRIPTION = "auto-description";
+ public static final String AUTO_METHOD_PATH = "auto-method-path";
+ public static final String AUTO_PATH_PARAMETERS = "auto-path-parameters";
+ public static final String AUTO_REQUEST_HEADERS = "auto-request-headers";
+ public static final String AUTO_REQUEST_PARAMETERS = "auto-request-parameters";
+ public static final String AUTO_REQUEST_FIELDS = "auto-request-fields";
+ public static final String AUTO_RESPONSE_FIELDS = "auto-response-fields";
+ public static final String AUTO_LINKS = "auto-links";
+ public static final String AUTO_EMBEDDED = "auto-embedded";
+
+ // Spring REST Docs classic snippets
public static final String CURL_REQUEST = "curl-request";
public static final String HTTP_REQUEST = "http-request";
public static final String HTTP_RESPONSE = "http-response";
public static final String HTTPIE_REQUEST = "httpie-request";
+ public static final String PATH_PARAMETERS = "path-parameters";
+ public static final String REQUEST_PARAMETERS = "request-parameters";
+ public static final String REQUEST_FIELDS = "request-fields";
+ public static final String RESPONSE_FIELDS = "response-fields";
+ public static final String REQUEST_BODY_SNIPPET = "request-body";
+ public static final String RESPONSE_BODY = "response-body";
+ public static final String REQUEST_HEADERS = "request-headers";
+ public static final String RESPONSE_HEADERS = "response-headers";
+ public static final String REQUEST_PARTS = "request-parts";
+ public static final String REQUEST_PART_FIELDS = "request-part-fields";
+ public static final String LINKS = "links";
private static final Map
CLASSIC_SNIPPETS;
@@ -49,6 +63,17 @@ public class SnippetRegistry {
CLASSIC_SNIPPETS.put(HTTPIE_REQUEST, section(HTTPIE_REQUEST, "example-request", true));
CLASSIC_SNIPPETS.put(HTTP_REQUEST, section(HTTP_REQUEST, "example-request", true));
CLASSIC_SNIPPETS.put(HTTP_RESPONSE, section(HTTP_RESPONSE, "example-response", true));
+ CLASSIC_SNIPPETS.put(REQUEST_PARAMETERS, section(REQUEST_PARAMETERS, "request-parameters", true));
+ CLASSIC_SNIPPETS.put(PATH_PARAMETERS, section(PATH_PARAMETERS, "path-parameters", true));
+ CLASSIC_SNIPPETS.put(LINKS, section(LINKS, "hypermedia-links", true));
+ CLASSIC_SNIPPETS.put(REQUEST_FIELDS, section(REQUEST_FIELDS, "request-fields", true));
+ CLASSIC_SNIPPETS.put(RESPONSE_FIELDS, section(RESPONSE_FIELDS, "response-fields", true));
+ CLASSIC_SNIPPETS.put(REQUEST_BODY_SNIPPET, section(REQUEST_BODY_SNIPPET, "request-body", true));
+ CLASSIC_SNIPPETS.put(RESPONSE_BODY, section(RESPONSE_BODY, "response-body", true));
+ CLASSIC_SNIPPETS.put(REQUEST_HEADERS, section(REQUEST_HEADERS, "request-headers", true));
+ CLASSIC_SNIPPETS.put(RESPONSE_HEADERS, section(RESPONSE_HEADERS, "response-headers", true));
+ CLASSIC_SNIPPETS.put(REQUEST_PARTS, section(REQUEST_PARTS, "request-parts", true));
+ CLASSIC_SNIPPETS.put(REQUEST_PART_FIELDS, section(REQUEST_PART_FIELDS, "request-part-fields", true));
}
public static SectionSupport getClassicSnippet(String snippetName) {
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippet.java
index c3d0d66a..0c0728a8 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippet.java
@@ -19,13 +19,14 @@
*/
package capital.scalable.restdocs.hypermedia;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_EMBEDDED;
+
import java.lang.reflect.Type;
import capital.scalable.restdocs.payload.AbstractJacksonFieldSnippet;
import org.springframework.web.method.HandlerMethod;
public class EmbeddedSnippet extends AbstractJacksonFieldSnippet {
- public static final String EMBEDDED = "auto-embedded";
private final Type documentationType;
private final boolean failOnUndocumentedFields;
@@ -35,7 +36,7 @@ public EmbeddedSnippet() {
}
public EmbeddedSnippet(Type documentationType, boolean failOnUndocumentedFields) {
- super(EMBEDDED, null);
+ super(AUTO_EMBEDDED, null);
this.documentationType = documentationType;
this.failOnUndocumentedFields = failOnUndocumentedFields;
}
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/hypermedia/LinksSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/hypermedia/LinksSnippet.java
index d6dd6ca9..da2f271f 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/hypermedia/LinksSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/hypermedia/LinksSnippet.java
@@ -19,14 +19,14 @@
*/
package capital.scalable.restdocs.hypermedia;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_LINKS;
+
import java.lang.reflect.Type;
import capital.scalable.restdocs.payload.AbstractJacksonFieldSnippet;
import org.springframework.web.method.HandlerMethod;
public class LinksSnippet extends AbstractJacksonFieldSnippet {
- public static final String LINKS = "auto-links";
-
private final Type documentationType;
private final boolean failOnUndocumentedFields;
@@ -35,7 +35,7 @@ public LinksSnippet() {
}
public LinksSnippet(Type documentationType, boolean failOnUndocumentedFields) {
- super(LINKS, null);
+ super(AUTO_LINKS, null);
this.documentationType = documentationType;
this.failOnUndocumentedFields = failOnUndocumentedFields;
}
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/AuthorizationSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/AuthorizationSnippet.java
index b04c49eb..e35ccf80 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/AuthorizationSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/AuthorizationSnippet.java
@@ -21,6 +21,7 @@
import static capital.scalable.restdocs.OperationAttributeHelper.getAuthorization;
import static capital.scalable.restdocs.OperationAttributeHelper.setAuthorization;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_AUTHORIZATION;
import java.util.HashMap;
import java.util.Map;
@@ -32,12 +33,10 @@
public class AuthorizationSnippet extends TemplatedSnippet implements SectionSupport {
- public static final String AUTHORIZATION = "auto-authorization";
-
private final String defaultAuthorization;
public AuthorizationSnippet(String defaultAuthorization) {
- super(AUTHORIZATION, null);
+ super(AUTO_AUTHORIZATION, null);
this.defaultAuthorization = defaultAuthorization;
}
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/DescriptionSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/DescriptionSnippet.java
index 283f40e1..99e061ca 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/DescriptionSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/DescriptionSnippet.java
@@ -22,6 +22,7 @@
import static capital.scalable.restdocs.OperationAttributeHelper.determineTemplateFormatting;
import static capital.scalable.restdocs.OperationAttributeHelper.getHandlerMethod;
import static capital.scalable.restdocs.OperationAttributeHelper.getJavadocReader;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_DESCRIPTION;
import static capital.scalable.restdocs.i18n.SnippetTranslationResolver.translate;
import static capital.scalable.restdocs.javadoc.JavadocUtil.convertFromJavadoc;
import static capital.scalable.restdocs.util.FormatUtil.addDot;
@@ -39,10 +40,8 @@
public class DescriptionSnippet extends TemplatedSnippet {
- public static final String DESCRIPTION = "auto-description";
-
public DescriptionSnippet() {
- super(DESCRIPTION, null);
+ super(AUTO_DESCRIPTION, null);
}
@Override
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/MethodAndPathSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/MethodAndPathSnippet.java
index 42e13e34..e86679c9 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/MethodAndPathSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/misc/MethodAndPathSnippet.java
@@ -21,6 +21,7 @@
import static capital.scalable.restdocs.OperationAttributeHelper.getRequestMethod;
import static capital.scalable.restdocs.OperationAttributeHelper.getRequestPattern;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_METHOD_PATH;
import java.util.HashMap;
import java.util.Map;
@@ -30,10 +31,8 @@
public class MethodAndPathSnippet extends TemplatedSnippet {
- public static final String METHOD_PATH = "auto-method-path";
-
public MethodAndPathSnippet() {
- super(METHOD_PATH, null);
+ super(AUTO_METHOD_PATH, null);
}
@Override
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippet.java
index cf7fda98..3d2d22d3 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippet.java
@@ -19,6 +19,8 @@
*/
package capital.scalable.restdocs.payload;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_REQUEST_FIELDS;
+
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Type;
@@ -29,8 +31,6 @@
public class JacksonRequestFieldSnippet extends AbstractJacksonFieldSnippet {
- public static final String REQUEST_FIELDS = "auto-request-fields";
-
private final Type requestBodyType;
private final boolean failOnUndocumentedFields;
@@ -39,7 +39,7 @@ public JacksonRequestFieldSnippet() {
}
public JacksonRequestFieldSnippet(Type requestBodyType, boolean failOnUndocumentedFields) {
- super(REQUEST_FIELDS, null);
+ super(AUTO_REQUEST_FIELDS, null);
this.requestBodyType = requestBodyType;
this.failOnUndocumentedFields = failOnUndocumentedFields;
}
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippet.java
index 5db0799d..4eef522e 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippet.java
@@ -19,6 +19,8 @@
*/
package capital.scalable.restdocs.payload;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_RESPONSE_FIELDS;
+
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Type;
import java.util.Map;
@@ -29,7 +31,6 @@
public class JacksonResponseFieldSnippet extends AbstractJacksonFieldSnippet {
- public static final String RESPONSE_FIELDS = "auto-response-fields";
public static final String SPRING_DATA_PAGE_CLASS = "org.springframework.data.domain.Page";
public static final String REACTOR_MONO_CLASS = "reactor.core.publisher.Mono";
public static final String REACTOR_FLUX_CLASS = "reactor.core.publisher.Flux";
@@ -42,7 +43,7 @@ public JacksonResponseFieldSnippet() {
}
public JacksonResponseFieldSnippet(Type responseBodyType, boolean failOnUndocumentedFields) {
- super(RESPONSE_FIELDS, null);
+ super(AUTO_RESPONSE_FIELDS, null);
this.responseBodyType = responseBodyType;
this.failOnUndocumentedFields = failOnUndocumentedFields;
}
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/PathParametersSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/PathParametersSnippet.java
index 8158e937..81b09112 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/PathParametersSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/PathParametersSnippet.java
@@ -19,12 +19,13 @@
*/
package capital.scalable.restdocs.request;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_PATH_PARAMETERS;
+
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.annotation.PathVariable;
public class PathParametersSnippet extends AbstractParameterSnippet {
- public static final String PATH_PARAMETERS = "auto-path-parameters";
private final boolean failOnUndocumentedParams;
public PathParametersSnippet() {
@@ -32,7 +33,7 @@ public PathParametersSnippet() {
}
public PathParametersSnippet(boolean failOnUndocumentedParams) {
- super(PATH_PARAMETERS, null);
+ super(AUTO_PATH_PARAMETERS, null);
this.failOnUndocumentedParams = failOnUndocumentedParams;
}
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/RequestHeaderSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/RequestHeaderSnippet.java
index a2f87be5..b055cfa6 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/RequestHeaderSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/RequestHeaderSnippet.java
@@ -19,12 +19,13 @@
*/
package capital.scalable.restdocs.request;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_REQUEST_HEADERS;
+
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.annotation.RequestHeader;
public class RequestHeaderSnippet extends AbstractParameterSnippet {
- public static final String REQUEST_HEADERS = "auto-request-headers";
private final boolean failOnUndocumentedParams;
public RequestHeaderSnippet() {
@@ -32,7 +33,7 @@ public RequestHeaderSnippet() {
}
public RequestHeaderSnippet(boolean failOnUndocumentedParams) {
- super(REQUEST_HEADERS, null);
+ super(AUTO_REQUEST_HEADERS, null);
this.failOnUndocumentedParams = failOnUndocumentedParams;
}
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/RequestParametersSnippet.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/RequestParametersSnippet.java
index 15ab71e4..040f2d04 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/RequestParametersSnippet.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/request/RequestParametersSnippet.java
@@ -19,6 +19,8 @@
*/
package capital.scalable.restdocs.request;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_REQUEST_PARAMETERS;
+
import java.util.Map;
import org.springframework.core.MethodParameter;
@@ -28,7 +30,6 @@
public class RequestParametersSnippet extends AbstractParameterSnippet {
- public static final String REQUEST_PARAMETERS = "auto-request-parameters";
public static final String SPRING_DATA_PAGEABLE_CLASS =
"org.springframework.data.domain.Pageable";
@@ -39,7 +40,7 @@ public RequestParametersSnippet() {
}
public RequestParametersSnippet(boolean failOnUndocumentedParams) {
- super(REQUEST_PARAMETERS, null);
+ super(AUTO_REQUEST_PARAMETERS, null);
this.failOnUndocumentedParams = failOnUndocumentedParams;
}
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/section/SectionBuilder.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/section/SectionBuilder.java
index b80d012d..5c35f23b 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/section/SectionBuilder.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/section/SectionBuilder.java
@@ -31,13 +31,13 @@
public class SectionBuilder {
public static final Collection DEFAULT_SNIPPETS = Arrays.asList(
- SnippetRegistry.AUTHORIZATION,
- SnippetRegistry.PATH_PARAMETERS,
- SnippetRegistry.REQUEST_PARAMETERS,
- SnippetRegistry.REQUEST_FIELDS,
- SnippetRegistry.RESPONSE_FIELDS,
- SnippetRegistry.LINKS,
- SnippetRegistry.EMBEDDED,
+ SnippetRegistry.AUTO_AUTHORIZATION,
+ SnippetRegistry.AUTO_PATH_PARAMETERS,
+ SnippetRegistry.AUTO_REQUEST_PARAMETERS,
+ SnippetRegistry.AUTO_REQUEST_FIELDS,
+ SnippetRegistry.AUTO_RESPONSE_FIELDS,
+ SnippetRegistry.AUTO_LINKS,
+ SnippetRegistry.AUTO_EMBEDDED,
SnippetRegistry.CURL_REQUEST,
SnippetRegistry.HTTP_RESPONSE
);
diff --git a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/util/FormatUtil.java b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/util/FormatUtil.java
index 0e262e86..6d12003c 100644
--- a/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/util/FormatUtil.java
+++ b/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/util/FormatUtil.java
@@ -58,4 +58,8 @@ public static String join(String delimiter, Object... texts) {
return result.toString();
}
}
+
+ public static String fixLineSeparator(String str) {
+ return str.replace("\n", System.lineSeparator());
+ }
}
diff --git a/spring-auto-restdocs-core/src/main/resources/capital/scalable/restdocs/i18n/DefaultSnippetMessages.properties b/spring-auto-restdocs-core/src/main/resources/capital/scalable/restdocs/i18n/DefaultSnippetMessages.properties
index 3f016ca7..3b2f52f6 100644
--- a/spring-auto-restdocs-core/src/main/resources/capital/scalable/restdocs/i18n/DefaultSnippetMessages.properties
+++ b/spring-auto-restdocs-core/src/main/resources/capital/scalable/restdocs/i18n/DefaultSnippetMessages.properties
@@ -2,10 +2,16 @@ authorization=Authorization
path-parameters=Path parameters
request-parameters=Query parameters
request-headers=Request headers
+response-headers=Response headers
request-fields=Request fields
response-fields=Response fields
example-request=Example request
example-response=Example response
+request-body=Request Body
+response-body=Response Body
+request-parts=Request Parts
+response-parts=Response Parts
+request-part-fields=Request Part Fields
th-parameter=Parameter
th-path=Path
th-header=Header
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippetTest.java
index 2cd5249e..df85c894 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippetTest.java
@@ -19,7 +19,7 @@
*/
package capital.scalable.restdocs.hypermedia;
-import static capital.scalable.restdocs.hypermedia.EmbeddedSnippet.EMBEDDED;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_EMBEDDED;
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
@@ -69,7 +69,7 @@ public void embedded() throws Exception {
mockFieldComment(EmbeddedDocs.class, "embedded1", "Resource 1");
mockFieldComment(EmbeddedDocs.class, "embedded2", "Resource 2");
- this.snippets.expect(EMBEDDED).withContents(
+ this.snippets.expect(AUTO_EMBEDDED).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("embedded1", "Array[Object]", "true", "Resource 1.")
.row("embedded2", "Object", "true", "Resource 2."));
@@ -84,7 +84,7 @@ public void embedded() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(EMBEDDED).withContents(equalTo("No embedded resources."));
+ this.snippets.expect(AUTO_EMBEDDED).withContents(equalTo("No embedded resources."));
new EmbeddedSnippet().document(operationBuilder
.attribute(ObjectMapper.class.getName(), mapper)
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/LinksSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/LinksSnippetTest.java
index bfac8953..b04fcacd 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/LinksSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/LinksSnippetTest.java
@@ -19,7 +19,7 @@
*/
package capital.scalable.restdocs.hypermedia;
-import static capital.scalable.restdocs.hypermedia.LinksSnippet.LINKS;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_LINKS;
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
@@ -67,7 +67,7 @@ public void links() throws Exception {
mockFieldComment(LinksDocs.class, "link1", "Link 1");
mockFieldComment(LinksDocs.class, "link2", "Link 2");
- this.snippets.expect(LINKS).withContents(
+ this.snippets.expect(AUTO_LINKS).withContents(
tableWithHeader("Path", "Optional", "Description")
.row("link1", "true", "Link 1.")
.row("link2", "true", "Link 2."));
@@ -82,7 +82,7 @@ public void links() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(LINKS).withContents(equalTo("No links."));
+ this.snippets.expect(AUTO_LINKS).withContents(equalTo("No links."));
new LinksSnippet().document(operationBuilder
.attribute(ObjectMapper.class.getName(), mapper)
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/AuthorizationSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/AuthorizationSnippetTest.java
index 36ae8b7c..5e13ece9 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/AuthorizationSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/AuthorizationSnippetTest.java
@@ -19,8 +19,7 @@
*/
package capital.scalable.restdocs.misc;
-
-import static capital.scalable.restdocs.misc.AuthorizationSnippet.AUTHORIZATION;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_AUTHORIZATION;
import static org.hamcrest.CoreMatchers.equalTo;
import org.junit.Test;
@@ -37,7 +36,7 @@ public AuthorizationSnippetTest(String name, TemplateFormat templateFormat) {
public void authorization() throws Exception {
String authorization = "User access token required.";
- this.snippets.expect(AUTHORIZATION)
+ this.snippets.expect(AUTO_AUTHORIZATION)
.withContents(equalTo(authorization));
new AuthorizationSnippet("Resource is public.")
@@ -51,7 +50,7 @@ public void authorization() throws Exception {
public void defaultAuthorization() throws Exception {
String defaultAuthorization = "Resource is public.";
- this.snippets.expect(AUTHORIZATION)
+ this.snippets.expect(AUTO_AUTHORIZATION)
.withContents(equalTo(defaultAuthorization));
new AuthorizationSnippet(defaultAuthorization)
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/DescriptionSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/DescriptionSnippetTest.java
index fcce53a5..0346e126 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/DescriptionSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/DescriptionSnippetTest.java
@@ -19,7 +19,7 @@
*/
package capital.scalable.restdocs.misc;
-import static capital.scalable.restdocs.misc.DescriptionSnippet.DESCRIPTION;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_DESCRIPTION;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -43,7 +43,7 @@ public void description() throws Exception {
mockMethodComment(TestResource.class, "testDescription", "sample method comment");
mockMethodTag(TestResource.class, "testDescription", "deprecated", "");
- this.snippets.expect(DESCRIPTION).withContents(equalTo("Sample method comment."));
+ this.snippets.expect(AUTO_DESCRIPTION).withContents(equalTo("Sample method comment."));
new DescriptionSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -58,7 +58,7 @@ public void descriptionWithDeprecated() throws Exception {
mockMethodComment(TestResource.class, "testDescription", "sample method comment");
mockMethodTag(TestResource.class, "testDescription", "deprecated", "use different one");
- this.snippets.expect(DESCRIPTION).withContents(equalTo(
+ this.snippets.expect(AUTO_DESCRIPTION).withContents(equalTo(
"**Deprecated.** Use different one.\n\nSample method comment."));
new DescriptionSnippet().document(operationBuilder
@@ -74,7 +74,7 @@ public void descriptionWithSeeTag() throws Exception {
mockMethodComment(TestResource.class, "testDescription", "sample method comment");
mockMethodTag(TestResource.class, "testDescription", "see", "something");
- this.snippets.expect(DESCRIPTION).withContents(equalTo(
+ this.snippets.expect(AUTO_DESCRIPTION).withContents(equalTo(
"Sample method comment.\n\nSee something."));
new DescriptionSnippet().document(operationBuilder
@@ -86,7 +86,7 @@ public void descriptionWithSeeTag() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(DESCRIPTION).withContents(equalTo(""));
+ this.snippets.expect(AUTO_DESCRIPTION).withContents(equalTo(""));
new DescriptionSnippet().document(operationBuilder
.request("http://localhost/test")
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java
index 91b4c4b3..f948f7ca 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java
@@ -20,7 +20,7 @@
package capital.scalable.restdocs.misc;
import static capital.scalable.restdocs.OperationAttributeHelper.REQUEST_PATTERN;
-import static capital.scalable.restdocs.misc.MethodAndPathSnippet.METHOD_PATH;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_METHOD_PATH;
import static org.hamcrest.CoreMatchers.equalTo;
import org.junit.Test;
@@ -38,7 +38,7 @@ public MethodAndPathSnippetTest(String name, TemplateFormat templateFormat) {
public void simpleRequest() throws Exception {
HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "testMethod");
- this.snippets.expect(METHOD_PATH).withContents(equalTo("`POST /test`"));
+ this.snippets.expect(AUTO_METHOD_PATH).withContents(equalTo("`POST /test`"));
new MethodAndPathSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -50,7 +50,7 @@ public void simpleRequest() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(METHOD_PATH).withContents(equalTo("`POST /test`"));
+ this.snippets.expect(AUTO_METHOD_PATH).withContents(equalTo("`POST /test`"));
new MethodAndPathSnippet().document(operationBuilder
.attribute(REQUEST_PATTERN, "/test")
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippetTest.java
index 0f8d05cb..bf6926af 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippetTest.java
@@ -19,7 +19,7 @@
*/
package capital.scalable.restdocs.payload;
-import static capital.scalable.restdocs.payload.JacksonRequestFieldSnippet.REQUEST_FIELDS;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_REQUEST_FIELDS;
import static com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY;
import static com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME;
import static java.util.Collections.singletonList;
@@ -79,7 +79,7 @@ public void simpleRequest() throws Exception {
mockOptionalMessage(Item.class, "field1", "false");
mockConstraintMessage(Item.class, "field2", "A constraint");
- this.snippets.expect(REQUEST_FIELDS).withContents(
+ this.snippets.expect(AUTO_REQUEST_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("field1", "String", "false", "A string.")
.row("field2", "Integer", "true", "An integer.\n\nA constraint."));
@@ -99,7 +99,7 @@ public void simpleRequestWithEnum() throws Exception {
mockFieldComment(ItemWithWeight.class, "weight", "An enum");
mockConstraintMessage(ItemWithWeight.class, "weight", "Must be one of [LIGHT, HEAVY]");
- this.snippets.expect(REQUEST_FIELDS).withContents(
+ this.snippets.expect(AUTO_REQUEST_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("weight", "String", "true",
"An enum.\n\nMust be one of [LIGHT, HEAVY]."));
@@ -116,7 +116,7 @@ public void simpleRequestWithEnum() throws Exception {
public void noRequestBody() throws Exception {
HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "addItem2");
- this.snippets.expect(REQUEST_FIELDS).withContents(equalTo("No request body."));
+ this.snippets.expect(AUTO_REQUEST_FIELDS).withContents(equalTo("No request body."));
new JacksonRequestFieldSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -126,7 +126,7 @@ public void noRequestBody() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(REQUEST_FIELDS).withContents(equalTo("No request body."));
+ this.snippets.expect(AUTO_REQUEST_FIELDS).withContents(equalTo("No request body."));
new JacksonRequestFieldSnippet().document(operationBuilder
.attribute(ObjectMapper.class.getName(), mapper)
@@ -139,7 +139,7 @@ public void listRequest() throws Exception {
mockFieldComment(Item.class, "field1", "A string");
mockFieldComment(Item.class, "field2", "An integer");
- this.snippets.expect(REQUEST_FIELDS).withContents(
+ this.snippets.expect(AUTO_REQUEST_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("[].field1", "String", "true", "A string.")
.row("[].field2", "Integer", "true", "An integer."));
@@ -160,7 +160,7 @@ public void jsonSubTypesRequest() throws Exception {
mockFieldComment(SubItem1.class, "subItem1Field", "A sub item 1 field");
mockFieldComment(SubItem2.class, "subItem2Field", "A sub item 2 field");
- this.snippets.expect(REQUEST_FIELDS).withContents(
+ this.snippets.expect(AUTO_REQUEST_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("type", "String", "true", "A type.")
.row("commonField", "String", "true", "A common field.")
@@ -180,7 +180,7 @@ public void exactRequestType() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("processItem", String.class);
mockFieldComment(ProcessingCommand.class, "command", "A command");
- this.snippets.expect(REQUEST_FIELDS).withContents(
+ this.snippets.expect(AUTO_REQUEST_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("command", "String", "true", "A command."));
@@ -244,7 +244,7 @@ public void deprecated() throws Exception {
mockFieldComment(DeprecatedItem.class, "index", "item's index");
mockDeprecated(DeprecatedItem.class, "index", "use index2");
- this.snippets.expect(REQUEST_FIELDS).withContents(
+ this.snippets.expect(AUTO_REQUEST_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("index", "Integer", "true",
"**Deprecated.** Use index2.\n\nItem's index."));
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippetTest.java
index 0043ffb8..648d7763 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippetTest.java
@@ -19,8 +19,9 @@
*/
package capital.scalable.restdocs.payload;
-import static capital.scalable.restdocs.payload.JacksonResponseFieldSnippet.RESPONSE_FIELDS;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_RESPONSE_FIELDS;
import static capital.scalable.restdocs.payload.TableWithPrefixMatcher.tableWithPrefix;
+import static capital.scalable.restdocs.util.FormatUtil.fixLineSeparator;
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
@@ -56,7 +57,6 @@
public class JacksonResponseFieldSnippetTest extends AbstractSnippetTests {
- private static final String LINE_SEPERATOR = System.lineSeparator();
private ObjectMapper mapper;
private JavadocReader javadocReader;
private ConstraintReader constraintReader;
@@ -85,7 +85,7 @@ public void simpleResponse() throws Exception {
mockOptionalMessage(Item.class, "field1", "false");
mockConstraintMessage(Item.class, "field2", "A constraint");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("field1", "String", "false", "A string.")
.row("field2", "Decimal", "true",
@@ -105,7 +105,7 @@ public void listResponse() throws Exception {
mockFieldComment(Item.class, "field1", "A string");
mockFieldComment(Item.class, "field2", "A decimal");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("[].field1", "String", "true", "A string.")
.row("[].field2", "Decimal", "true", "A decimal."));
@@ -124,7 +124,7 @@ public void streamResponse() throws Exception {
mockFieldComment(Item.class, "field1", "A string");
mockFieldComment(Item.class, "field2", "A decimal");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("[].field1", "String", "true", "A string.")
.row("[].field2", "Decimal", "true", "A decimal."));
@@ -141,7 +141,7 @@ public void streamResponse() throws Exception {
public void noResponseBody() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("noItem");
- this.snippets.expect(RESPONSE_FIELDS).withContents(equalTo("No response body."));
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(equalTo("No response body."));
new JacksonResponseFieldSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -151,7 +151,7 @@ public void noResponseBody() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(RESPONSE_FIELDS).withContents(equalTo("No response body."));
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(equalTo("No response body."));
new JacksonResponseFieldSnippet().document(operationBuilder
.attribute(ObjectMapper.class.getName(), mapper)
@@ -166,7 +166,7 @@ public void pageResponse() throws Exception {
mockOptionalMessage(Item.class, "field1", "false");
mockConstraintMessage(Item.class, "field2", "A constraint");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithPrefix(paginationPrefix(),
tableWithHeader("Path", "Type", "Optional", "Description")
.row("field1", "String", "false", "A string.")
@@ -189,7 +189,7 @@ public void responseEntityResponse() throws Exception {
mockOptionalMessage(Item.class, "field1", "false");
mockConstraintMessage(Item.class, "field2", "A constraint");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("field1", "String", "false", "A string.")
.row("field2", "Decimal", "true",
@@ -207,7 +207,7 @@ public void responseEntityResponse() throws Exception {
public void responseEntityResponseWithoutGenerics() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("responseEntityItem2");
- this.snippets.expect(RESPONSE_FIELDS).withContents(equalTo("No response body."));
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(equalTo("No response body."));
new JacksonResponseFieldSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -225,11 +225,11 @@ public void monoResponse() throws Exception {
mockOptionalMessage(Item.class, "field1", "false");
mockConstraintMessage(Item.class, "field2", "A constraint");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
- tableWithHeader("Path", "Type", "Optional", "Description")
- .row("field1", "String", "false", "A string.")
- .row("field2", "Decimal", "true",
- "A decimal.\n\nA constraint."));
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
+ tableWithHeader("Path", "Type", "Optional", "Description")
+ .row("field1", "String", "false", "A string.")
+ .row("field2", "Decimal", "true",
+ "A decimal.\n\nA constraint."));
new JacksonResponseFieldSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -245,7 +245,7 @@ public void fluxResponse() throws Exception {
mockFieldComment(Item.class, "field1", "A string");
mockFieldComment(Item.class, "field2", "A decimal");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("[].field1", "String", "true", "A string.")
.row("[].field2", "Decimal", "true", "A decimal."));
@@ -263,7 +263,7 @@ public void exactResponseType() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("processItem");
mockFieldComment(ProcessingResponse.class, "output", "An output");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("output", "String", "true", "An output."));
@@ -316,7 +316,7 @@ public void escaping() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("processItem");
mockFieldComment(ProcessingResponse.class, "output", "An output | result");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("output", "String", "true", "An output \\| result."));
@@ -343,7 +343,7 @@ public void deprecated() throws Exception {
mockDeprecatedField(DeprecatedItem.class, "index2", "use something else");
mockDeprecatedMethod(DeprecatedItem.class, "getIndex4", "use something else");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("index", "Integer", "true",
"**Deprecated.**\n\nItem's index.")
@@ -375,7 +375,7 @@ public void comment() throws Exception {
mockMethodComment(CommentedItem.class, "getField3", "method 3"); // preferred
mockMethodComment(CommentedItem.class, "getField4", "method 4");
- this.snippets.expect(RESPONSE_FIELDS).withContents(
+ this.snippets.expect(AUTO_RESPONSE_FIELDS).withContents(
tableWithHeader("Path", "Type", "Optional", "Description")
.row("field", "String", "true", "Field.")
.row("field2", "String", "true", "Field 2.")
@@ -422,11 +422,11 @@ private void mockDeprecatedField(Class> type, String fieldName, String comment
private String paginationPrefix() {
if ("adoc".equals(templateFormat.getFileExtension())) {
- return "Standard <> response where `content` field is"
- + " list of following objects:" + LINE_SEPERATOR + LINE_SEPERATOR;
+ return fixLineSeparator("Standard <> response where `content` field is"
+ + " list of following objects:\n\n");
} else {
- return "Standard [paging](#overview-pagination) response where `content` field is"
- + " list of following objects:" + LINE_SEPERATOR + LINE_SEPERATOR;
+ return fixLineSeparator("Standard [paging](#overview-pagination) response where `content` field is"
+ + " list of following objects:\n\n");
}
}
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/PathParametersSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/PathParametersSnippetTest.java
index cc4492ff..3a8a91be 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/PathParametersSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/PathParametersSnippetTest.java
@@ -19,8 +19,7 @@
*/
package capital.scalable.restdocs.request;
-
-import static capital.scalable.restdocs.request.PathParametersSnippet.PATH_PARAMETERS;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_PATH_PARAMETERS;
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.mockito.Mockito.mock;
@@ -73,7 +72,7 @@ public void simpleRequest() throws Exception {
mockParamComment("addItem", "yetAnotherId", "Another string");
mockParamComment("addItem", "optionalId", "Optional string");
- this.snippets.expect(PATH_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_PATH_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("id", "Integer", "false", "An integer.")
.row("subid", "String", "false", "A string.")
@@ -97,7 +96,7 @@ public void simpleRequestWithEnum() throws Exception {
mockConstraintMessage(handlerMethod.getMethodParameters()[0],
"Must be one of [SPHERIC, SQUARE]");
- this.snippets.expect(PATH_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_PATH_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("shape", "String", "false",
"An enum.\n\nMust be one of [SPHERIC, SQUARE]."));
@@ -113,7 +112,7 @@ public void simpleRequestWithEnum() throws Exception {
public void noParameters() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("addItem");
- this.snippets.expect(PATH_PARAMETERS).withContents(equalTo("No parameters."));
+ this.snippets.expect(AUTO_PATH_PARAMETERS).withContents(equalTo("No parameters."));
new PathParametersSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -122,7 +121,7 @@ public void noParameters() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(PATH_PARAMETERS).withContents(equalTo("No parameters."));
+ this.snippets.expect(AUTO_PATH_PARAMETERS).withContents(equalTo("No parameters."));
new PathParametersSnippet().document(operationBuilder
.build());
@@ -151,7 +150,7 @@ public void deprecated() throws Exception {
initParameters(handlerMethod);
mockParamComment("removeItem", "index", "item's index");
- this.snippets.expect(PATH_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_PATH_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("index", "Integer", "false", "**Deprecated.**\n\nItem's index."));
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestHeaderSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestHeaderSnippetTest.java
index 6ca6ec98..e6e56e5d 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestHeaderSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestHeaderSnippetTest.java
@@ -19,8 +19,7 @@
*/
package capital.scalable.restdocs.request;
-
-import static capital.scalable.restdocs.request.RequestHeaderSnippet.REQUEST_HEADERS;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_REQUEST_HEADERS;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -71,7 +70,7 @@ public void simpleRequest() throws Exception {
mockParamComment("updateItem", "yetAnotherId", "A string");
mockParamComment("updateItem", "optionalId", "Optional string");
- this.snippets.expect(REQUEST_HEADERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_HEADERS).withContents(
tableWithHeader("Header", "Type", "Optional", "Description")
.row("id", "Integer", "false", "An integer.")
.row("subId", "String", "false", "A string.")
@@ -97,7 +96,7 @@ public void simpleRequestDefaultValueParameterNotDocumented() throws Exception {
mockParamComment("updateItem", "partId", "An integer");
// yetAnotherId will have an automatic description about its default value
- this.snippets.expect(REQUEST_HEADERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_HEADERS).withContents(
tableWithHeader("Header", "Type", "Optional", "Description")
.row("id", "Integer", "false", "An integer.")
.row("subId", "String", "false", "A string.")
@@ -116,7 +115,7 @@ public void simpleRequestDefaultValueParameterNotDocumented() throws Exception {
public void noHeaders() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("updateItem");
- this.snippets.expect(REQUEST_HEADERS).withContents(equalTo("No headers."));
+ this.snippets.expect(AUTO_REQUEST_HEADERS).withContents(equalTo("No headers."));
new RequestHeaderSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -125,7 +124,7 @@ public void noHeaders() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(REQUEST_HEADERS).withContents(equalTo("No headers."));
+ this.snippets.expect(AUTO_REQUEST_HEADERS).withContents(equalTo("No headers."));
new RequestHeaderSnippet().document(operationBuilder
.build());
@@ -154,7 +153,7 @@ public void deprecated() throws Exception {
initParameters(handlerMethod);
mockParamComment("removeItem", "index", "item's index");
- this.snippets.expect(REQUEST_HEADERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_HEADERS).withContents(
tableWithHeader("Header", "Type", "Optional", "Description")
.row("index", "Integer", "false", "**Deprecated.**\n\nItem's index."));
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestParametersSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestParametersSnippetTest.java
index ff6a3f79..157673e5 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestParametersSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestParametersSnippetTest.java
@@ -19,9 +19,9 @@
*/
package capital.scalable.restdocs.request;
-
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_REQUEST_PARAMETERS;
import static capital.scalable.restdocs.payload.TableWithPrefixMatcher.tableWithPrefix;
-import static capital.scalable.restdocs.request.RequestParametersSnippet.REQUEST_PARAMETERS;
+import static capital.scalable.restdocs.util.FormatUtil.fixLineSeparator;
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.mockito.Mockito.mock;
@@ -46,7 +46,6 @@
import org.springframework.web.method.HandlerMethod;
public class RequestParametersSnippetTest extends AbstractSnippetTests {
- private static final String LINE_SEPERATOR = System.lineSeparator();
private JavadocReader javadocReader;
private ConstraintReader constraintReader;
@@ -71,7 +70,7 @@ public void simpleRequest() throws Exception {
mockParamComment("searchItem", "type", "An integer");
mockParamComment("searchItem", "description", "A string");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("type", "Integer", "false", "An integer.")
.row("text", "String", "true", "A string."));
@@ -92,7 +91,7 @@ public void simpleRequestWithPrimitives() throws Exception {
mockParamComment("searchItem2", "param2", "A boolean");
mockParamComment("searchItem2", "param3", "An integer");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("param1", "Decimal", "false", "A decimal.")
.row("param2", "Boolean", "false", "A boolean.")
@@ -113,7 +112,7 @@ public void simpleRequestWithPrimitivesDefaultValueParameterNotDocumented() thro
mockParamComment("searchItem2", "param1", "A decimal");
mockParamComment("searchItem2", "param2", "A boolean");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("param1", "Decimal", "false", "A decimal.")
.row("param2", "Boolean", "false", "A boolean.")
@@ -135,7 +134,7 @@ public void simpleRequestWithStringDefaultValueParameter() throws Exception {
mockParamComment("searchItem2String", "param2", "A boolean");
mockParamComment("searchItem2String", "param3", "A String");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("param1", "Decimal", "false", "A decimal.")
.row("param2", "Boolean", "false", "A boolean.")
@@ -154,7 +153,7 @@ public void simpleRequestWithCustomTypes() throws Exception {
initParameters(handlerMethod);
mockParamComment("searchItem5", "locale", "A locale");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("locale", "String", "false", "A locale."));
@@ -174,7 +173,7 @@ public void simpleRequestWithEnum() throws Exception {
mockConstraintMessage(handlerMethod.getMethodParameters()[0],
"Must be one of [SMALL, LARGE]");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("size", "String", "false",
"An enum.\n\nMust be one of [SMALL, LARGE]."));
@@ -192,7 +191,7 @@ public void simpleRequestWithOptional() throws Exception {
initParameters(handlerMethod);
mockParamComment("searchItemOptional", "param1", "An optional string");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("param1", "String", "true", "An optional string."));
@@ -207,7 +206,7 @@ public void simpleRequestWithOptional() throws Exception {
public void noParameters() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("items");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(equalTo("No parameters."));
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(equalTo("No parameters."));
new RequestParametersSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -216,7 +215,7 @@ public void noParameters() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
- this.snippets.expect(REQUEST_PARAMETERS).withContents(equalTo("No parameters."));
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(equalTo("No parameters."));
new RequestParametersSnippet().document(operationBuilder
.build());
@@ -243,7 +242,7 @@ public void pageRequest_noParams() throws Exception {
HandlerMethod handlerMethod = createHandlerMethod("searchItem3", Pageable.class);
initParameters(handlerMethod);
- this.snippets.expect(REQUEST_PARAMETERS).withContents(equalTo(paginationPrefix()));
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(equalTo(paginationPrefix()));
new RequestParametersSnippet().document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -258,7 +257,7 @@ public void pageRequest_withParams() throws Exception {
initParameters(handlerMethod);
mockParamComment("searchItem4", "text", "A text");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithPrefix(paginationPrefix(),
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("text", "Integer", "false", "A text.")));
@@ -276,7 +275,7 @@ public void deprecated() throws Exception {
initParameters(handlerMethod);
mockParamComment("removeItem", "index", "item's index");
- this.snippets.expect(REQUEST_PARAMETERS).withContents(
+ this.snippets.expect(AUTO_REQUEST_PARAMETERS).withContents(
tableWithHeader("Parameter", "Type", "Optional", "Description")
.row("index", "Integer", "false", "**Deprecated.**\n\nItem's index."));
@@ -310,9 +309,9 @@ private HandlerMethod createHandlerMethod(String name, Class>... parameterType
private String paginationPrefix() {
if ("adoc".equals(templateFormat.getFileExtension())) {
- return "Supports standard <> query parameters." + LINE_SEPERATOR + LINE_SEPERATOR;
+ return fixLineSeparator("Supports standard <> query parameters.\n\n");
} else {
- return "Supports standard [paging](#overview-pagination) query parameters." + LINE_SEPERATOR + LINE_SEPERATOR;
+ return fixLineSeparator("Supports standard [paging](#overview-pagination) query parameters.\n\n");
}
}
diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/section/SectionSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/section/SectionSnippetTest.java
index 504e0a8e..68ad5db1 100644
--- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/section/SectionSnippetTest.java
+++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/section/SectionSnippetTest.java
@@ -24,29 +24,38 @@
import static capital.scalable.restdocs.AutoDocumentation.requestFields;
import static capital.scalable.restdocs.AutoDocumentation.requestParameters;
import static capital.scalable.restdocs.AutoDocumentation.responseFields;
+import static capital.scalable.restdocs.SnippetRegistry.AUTO_RESPONSE_FIELDS;
+import static capital.scalable.restdocs.SnippetRegistry.CURL_REQUEST;
+import static capital.scalable.restdocs.SnippetRegistry.HTTPIE_REQUEST;
import static capital.scalable.restdocs.SnippetRegistry.HTTP_REQUEST;
import static capital.scalable.restdocs.SnippetRegistry.HTTP_RESPONSE;
+import static capital.scalable.restdocs.SnippetRegistry.LINKS;
+import static capital.scalable.restdocs.SnippetRegistry.PATH_PARAMETERS;
+import static capital.scalable.restdocs.SnippetRegistry.REQUEST_BODY_SNIPPET;
+import static capital.scalable.restdocs.SnippetRegistry.REQUEST_FIELDS;
+import static capital.scalable.restdocs.SnippetRegistry.REQUEST_HEADERS;
+import static capital.scalable.restdocs.SnippetRegistry.REQUEST_PARAMETERS;
+import static capital.scalable.restdocs.SnippetRegistry.REQUEST_PARTS;
+import static capital.scalable.restdocs.SnippetRegistry.REQUEST_PART_FIELDS;
+import static capital.scalable.restdocs.SnippetRegistry.RESPONSE_BODY;
import static capital.scalable.restdocs.SnippetRegistry.RESPONSE_FIELDS;
+import static capital.scalable.restdocs.SnippetRegistry.RESPONSE_HEADERS;
import static capital.scalable.restdocs.section.SectionSnippet.SECTION;
+import static capital.scalable.restdocs.util.FormatUtil.fixLineSeparator;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.springframework.restdocs.cli.CliDocumentation.curlRequest;
-import static org.springframework.restdocs.generate.RestDocumentationGenerator
- .ATTRIBUTE_NAME_DEFAULT_SNIPPETS;
+import static org.springframework.restdocs.generate.RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
import capital.scalable.restdocs.i18n.TranslationRule;
import capital.scalable.restdocs.javadoc.JavadocReader;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.runners.Parameterized;
-import org.springframework.restdocs.AbstractSnippetTests;
import org.springframework.restdocs.http.HttpDocumentation;
import org.springframework.restdocs.templates.TemplateFormat;
import org.springframework.restdocs.templates.TemplateFormats;
@@ -56,7 +65,6 @@
public class SectionSnippetTest {
- private static final String LINE_SEPERATOR = System.lineSeparator();
private JavadocReader javadocReader;
@Rule
@@ -86,10 +94,11 @@ public void noSnippets() throws Exception {
mockMethodTitle(TestResource.class, "getItemById", "");
this.snippets.expect(SECTION)
- .withContents(equalTo("[[resources-noSnippets]]" + LINE_SEPERATOR +
- "=== Get Item By Id" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-method-path.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-description.adoc[]" + LINE_SEPERATOR));
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-noSnippets]]\n" +
+ "=== Get Item By Id\n\n" +
+ "include::auto-method-path.adoc[]\n\n" +
+ "include::auto-description.adoc[]\n")));
new SectionBuilder()
.snippetNames()
@@ -105,10 +114,11 @@ public void noSnippets() throws Exception {
@Test
public void noHandlerMethod() throws Exception {
this.snippets.expect(SECTION)
- .withContents(equalTo("[[resources-noHandlerMethod]]" + LINE_SEPERATOR +
- "=== No Handler Method" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-method-path.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-description.adoc[]" + LINE_SEPERATOR));
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-noHandlerMethod]]\n" +
+ "=== No Handler Method\n\n" +
+ "include::auto-method-path.adoc[]\n\n" +
+ "include::auto-description.adoc[]\n")));
new SectionBuilder()
.snippetNames()
@@ -126,24 +136,25 @@ public void defaultSnippets() throws Exception {
mockMethodTitle(TestResource.class, "getItemById", "");
this.snippets.expect(SECTION)
- .withContents(equalTo("[[resources-defaultSnippets]]" + LINE_SEPERATOR +
- "=== Get Item By Id" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-method-path.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-description.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Authorization" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-authorization.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Path parameters" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-path-parameters.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Query parameters" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-request-parameters.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Request fields" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-request-fields.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Response fields" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-response-fields.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Example request" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::curl-request.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Example response" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::http-response.adoc[]" + LINE_SEPERATOR));
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-defaultSnippets]]\n" +
+ "=== Get Item By Id\n\n" +
+ "include::auto-method-path.adoc[]\n\n" +
+ "include::auto-description.adoc[]\n\n" +
+ "==== Authorization\n\n" +
+ "include::auto-authorization.adoc[]\n\n" +
+ "==== Path parameters\n\n" +
+ "include::auto-path-parameters.adoc[]\n\n" +
+ "==== Query parameters\n\n" +
+ "include::auto-request-parameters.adoc[]\n\n" +
+ "==== Request fields\n\n" +
+ "include::auto-request-fields.adoc[]\n\n" +
+ "==== Response fields\n\n" +
+ "include::auto-response-fields.adoc[]\n\n" +
+ "==== Example request\n\n" +
+ "include::curl-request.adoc[]\n\n" +
+ "==== Example response\n\n" +
+ "include::http-response.adoc[]\n")));
new SectionBuilder().build()
.document(operationBuilder
@@ -163,19 +174,78 @@ public void customSnippets() throws Exception {
mockMethodTitle(TestResource.class, "getItemById", "");
this.snippets.expect(SECTION)
- .withContents(equalTo("[[resources-customSnippets]]" + LINE_SEPERATOR +
- "=== Get Item By Id" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-method-path.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-description.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Example response" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::http-response.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Response fields" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-response-fields.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Example request" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::http-request.adoc[]" + LINE_SEPERATOR));
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-customSnippets]]\n" +
+ "=== Get Item By Id\n\n" +
+ "include::auto-method-path.adoc[]\n\n" +
+ "include::auto-description.adoc[]\n\n" +
+ "==== Example response\n\n" +
+ "include::http-response.adoc[]\n\n" +
+ "==== Response fields\n\n" +
+ "include::auto-response-fields.adoc[]\n\n" +
+ "==== Example request\n\n" +
+ "include::http-request.adoc[]\n")));
new SectionBuilder()
- .snippetNames(HTTP_RESPONSE, RESPONSE_FIELDS, HTTP_REQUEST)
+ .snippetNames(HTTP_RESPONSE, AUTO_RESPONSE_FIELDS, HTTP_REQUEST)
+ .build()
+ .document(operationBuilder
+ .attribute(HandlerMethod.class.getName(), handlerMethod)
+ .attribute(JavadocReader.class.getName(), javadocReader)
+ .attribute(ATTRIBUTE_NAME_DEFAULT_SNIPPETS, Arrays.asList(
+ pathParameters(), requestParameters(),
+ requestFields(), responseFields(), curlRequest(),
+ HttpDocumentation.httpRequest(), HttpDocumentation.httpResponse()))
+ .request("http://localhost/items/1")
+ .build());
+ }
+
+ @Test
+ public void allClassicSnippets() throws Exception {
+ HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "getItemById");
+ mockMethodTitle(TestResource.class, "getItemById", "");
+
+ this.snippets.expect(SECTION)
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-allClassicSnippets]]\n"
+ + "=== Get Item By Id\n\n"
+ + "include::auto-method-path.adoc[]\n\n"
+ + "include::auto-description.adoc[]\n\n"
+ + "==== Example request\n\n"
+ + "include::curl-request.adoc[]\n\n"
+ + "==== Example request\n\n"
+ + "include::http-request.adoc[]\n\n"
+ + "==== Example response\n\n"
+ + "include::http-response.adoc[]\n\n"
+ + "==== Example request\n\n"
+ + "include::httpie-request.adoc[]\n\n"
+ + "==== Path parameters\n\n"
+ + "include::path-parameters.adoc[]\n\n"
+ + "==== Query parameters\n\n"
+ + "include::request-parameters.adoc[]\n\n"
+ + "==== Request fields\n\n"
+ + "include::request-fields.adoc[]\n\n"
+ + "==== Response fields\n\n"
+ + "include::response-fields.adoc[]\n\n"
+ + "==== Request Body\n\n"
+ + "include::request-body.adoc[]\n\n"
+ + "==== Response Body\n\n"
+ + "include::response-body.adoc[]\n\n"
+ + "==== Request headers\n\n"
+ + "include::request-headers.adoc[]\n\n"
+ + "==== Response headers\n\n"
+ + "include::response-headers.adoc[]\n\n"
+ + "==== Request Parts\n\n"
+ + "include::request-parts.adoc[]\n\n"
+ + "==== Request Part Fields\n\n"
+ + "include::request-part-fields.adoc[]\n\n"
+ + "==== Hypermedia links\n\n"
+ + "include::links.adoc[]\n")));
+
+ new SectionBuilder()
+ .snippetNames(CURL_REQUEST, HTTP_REQUEST, HTTP_RESPONSE, HTTPIE_REQUEST, PATH_PARAMETERS,
+ REQUEST_PARAMETERS, REQUEST_FIELDS, RESPONSE_FIELDS, REQUEST_BODY_SNIPPET, RESPONSE_BODY,
+ REQUEST_HEADERS, RESPONSE_HEADERS, REQUEST_PARTS, REQUEST_PART_FIELDS, LINKS)
.build()
.document(operationBuilder
.attribute(HandlerMethod.class.getName(), handlerMethod)
@@ -194,16 +264,17 @@ public void skipEmpty() throws Exception {
mockMethodTitle(TestResource.class, "getItemById", "");
this.snippets.expect(SECTION)
- .withContents(equalTo("[[resources-skipEmpty]]" + LINE_SEPERATOR +
- "=== Get Item By Id" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-method-path.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-description.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Authorization" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-authorization.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Example request" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::curl-request.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== Example response" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::http-response.adoc[]" + LINE_SEPERATOR));
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-skipEmpty]]\n" +
+ "=== Get Item By Id\n\n" +
+ "include::auto-method-path.adoc[]\n\n" +
+ "include::auto-description.adoc[]\n\n" +
+ "==== Authorization\n\n" +
+ "include::auto-authorization.adoc[]\n\n" +
+ "==== Example request\n\n" +
+ "include::curl-request.adoc[]\n\n" +
+ "==== Example response\n\n" +
+ "include::http-response.adoc[]\n")));
new SectionBuilder()
.skipEmpty(true)
@@ -225,10 +296,11 @@ public void customTitle() throws Exception {
mockMethodTitle(TestResource.class, "getItemById", "Custom title");
this.snippets.expect(SECTION)
- .withContents(equalTo("[[resources-customTitle]]" + LINE_SEPERATOR +
- "=== Custom title" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-method-path.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-description.adoc[]" + LINE_SEPERATOR));
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-customTitle]]\n" +
+ "=== Custom title\n\n" +
+ "include::auto-method-path.adoc[]\n\n" +
+ "include::auto-description.adoc[]\n")));
new SectionBuilder()
.snippetNames()
@@ -248,12 +320,12 @@ public void deprecated() throws Exception {
when(javadocReader.resolveMethodTag(TestResource.class, "getItemById", "deprecated"))
.thenReturn("it is");
-
this.snippets.expect(SECTION)
- .withContents(equalTo("[[resources-deprecated]]" + LINE_SEPERATOR +
- "=== Get Item By Id (deprecated)" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-method-path.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-description.adoc[]" + LINE_SEPERATOR));
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-deprecated]]\n" +
+ "=== Get Item By Id (deprecated)\n\n" +
+ "include::auto-method-path.adoc[]\n\n" +
+ "include::auto-description.adoc[]\n")));
new SectionBuilder()
.snippetNames()
@@ -274,24 +346,25 @@ public void translation() throws Exception {
mockMethodTitle(TestResource.class, "getItemById", "");
this.snippets.expect(SECTION)
- .withContents(equalTo("[[resources-translation]]" + LINE_SEPERATOR +
- "=== Get Item By Id" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-method-path.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-description.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== XAuthorization" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-authorization.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== XPath parameters" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-path-parameters.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== XQuery parameters" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-request-parameters.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== XRequest fields" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-request-fields.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== XResponse fields" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::auto-response-fields.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== XExample request" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::curl-request.adoc[]" + LINE_SEPERATOR + LINE_SEPERATOR +
- "==== XExample response" + LINE_SEPERATOR + LINE_SEPERATOR +
- "include::http-response.adoc[]" + LINE_SEPERATOR));
+ .withContents(equalTo(fixLineSeparator(
+ "[[resources-translation]]\n" +
+ "=== Get Item By Id\n\n" +
+ "include::auto-method-path.adoc[]\n\n" +
+ "include::auto-description.adoc[]\n\n" +
+ "==== XAuthorization\n\n" +
+ "include::auto-authorization.adoc[]\n\n" +
+ "==== XPath parameters\n\n" +
+ "include::auto-path-parameters.adoc[]\n\n" +
+ "==== XQuery parameters\n\n" +
+ "include::auto-request-parameters.adoc[]\n\n" +
+ "==== XRequest fields\n\n" +
+ "include::auto-request-fields.adoc[]\n\n" +
+ "==== XResponse fields\n\n" +
+ "include::auto-response-fields.adoc[]\n\n" +
+ "==== XExample request\n\n" +
+ "include::curl-request.adoc[]\n\n" +
+ "==== XExample response\n\n" +
+ "include::http-response.adoc[]\n")));
new SectionBuilder().build()
.document(operationBuilder
@@ -312,7 +385,6 @@ private void mockMethodTitle(Class> javaBaseClass, String methodName, String t
private static class TestResource {
-
public void getItemById() {
// NOOP
}