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
{{ message }}
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
<h4id="snippets-section-custom-snippet"><aclass="link" href="#snippets-section-custom-snippet">Custom snippet in section</a></h4>
1263
+
<divclass="paragraph">
1264
+
<p>If you want your custom snippet to be part of section snippet with automatically recognised header and include link (file name),
1265
+
you have to implement <ahref="https://github.com/ScaCap/spring-auto-restdocs/blob/master/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/section/SectionSupport.java">SectionSupport</a> interface.
1266
+
Then, inside MockMvc configuration, add this snippet to the list of snippets using documentation configuration’s
1267
+
builder <code>withDefaults(…​)</code> and include snippet name among SectionBuilder’s <code>snippetNames(…​)</code>.</p>
<p>Custom snippets are created by subclassing the <ahref="https://github.com/spring-projects/spring-restdocs/blob/master/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Snippet.java">Snippet</a> interface
1265
-
(or more conveniently <ahref="https://github.com/spring-projects/spring-restdocs/blob/master/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/TemplatedSnippet.java">TemplatedSnippet</a>). If you want your custom
1266
-
snippet to be part of section snippet with automatically recognised header and include link (file name),
1267
-
you have to implement <ahref="https://github.com/ScaCap/spring-auto-restdocs/blob/master/spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/section/SectionSupport.java">SectionSupport</a> interface.
1268
-
Then, inside MockMvc configuration, add this snippet to the list of snippets using documentation configuration’s
1269
-
builder <code>withDefaults(…​)</code> and include snippet name among SectionBuilder’s <code>snippetNames(…​)</code>.</p>
1275
+
(or more conveniently <ahref="https://github.com/spring-projects/spring-restdocs/blob/master/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/TemplatedSnippet.java">TemplatedSnippet</a>).
1276
+
Template for the snippet must be put into <code>org/springframework/restdocs/templates/asciidoctor</code>
1277
+
(optionally also <code>org/springframework/restdocs/templates/markdown</code>) resource package. The template name
1278
+
must correspond with the snippet name passed to the class constructor.
1279
+
You can also <ahref="#snippets-section-custom-snippet">include your custom snippet in a section</a>.</p>
<p>Provide your own template in <code>org/springframework/restdocs/templates/asciidoctor</code> (or <code>markdown</code>) package of your resources.
1286
+
You can override <ahref="https://github.com/spring-projects/spring-restdocs/tree/v1.2.1.RELEASE/spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates">REST Docs templates</a>
1287
+
and <ahref="https://github.com/ScaCap/spring-auto-restdocs/tree/master/spring-auto-restdocs-core/src/main/resources/org/springframework/restdocs/templates">Auto REST Docs templates</a>.
1288
+
Important is to omit <code>default-</code> part from the template name so that the resolution algorithm will prefer this custom template.
1289
+
See also <ahref="http://docs.spring.io/spring-restdocs/docs/1.2.1.RELEASE/reference/html5/#documenting-your-api-customizing-snippets">original documentation</a> for additional details.</p>
Copy file name to clipboardExpand all lines: spring-auto-restdocs-core/src/main/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippet.java
0 commit comments