Has to be removed if @RestdocsNotExpanded is used.
-
-
-
2
(Optional) Determines directory where snippets are saved. Defaults to generated-snippets in build directory.
-
3
+
2
(Optional) Determines where JSON files are saved. Defaults to generated-javadoc-json in build directory.
Multiple directories can be listed by separating them with ,.
The directories are processed in order and only the first found JSON file is used.
-
4
-
For Java 9 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.
+
3
+
For Java 9/10/11 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.
Has to be compile instead of testCompile if @RestdocsNotExpanded is used.
-
-
-
2
(Optional) Determines directory where snippets are saved. Defaults to generated-snippets in build directory.
-
3
+
2
(Optional) Determines where JSON files are saved.
Defaults to generated-javadoc-json in build directory.
Multiple directories can be listed by separating them with ,.
The directories are processed in order and only the first found JSON file is used.
-
4
-
For Java 9 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.
+
3
+
For Java 9/10/11 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.
Provide your own template in org/springframework/restdocs/templates/asciidoctor (or markdown) package of your resources.
-You can override REST Docs templates
+You can override REST Docs templates
and Auto REST Docs templates.
Important is to omit default- part from the template name so that the resolution algorithm will prefer this custom template.
-See also original documentation for additional details.
To prevent infinite loop in recursive structures, annotate the recursive field with the @RestdocsNotExpanded annotation
+from the spring-auto-restdocs-annotations maven module.
There are two forms of subtypes supported, automatic via Jackson annotations and manual via MockMvc configuration.
+You can even combine them together if necessary.
If for any reason Jackson annotations are not desired or possible, you can configure completely custom subtypes
+via MockMvc using standard JacksonResultHandlers.prepareJackson result handler with custom TypeMapping.
+
+
+
MockMvc configuration
+
+
.alwaysDo(prepareJackson(objectMapper, new TypeMapping()
+ .mapSubtypes(Parent.class, Sub1.class, Sub2.class)))
For better understanding which field is included when in the final documentation,
+ConstraintDescriptions.properties can be used to provide a message,
+which will be then applied to all fields coming from that particular subtype.
+
+
+
ConstraintDescriptions.properties
+
+
mypackage.Sub1.description=(available when type=2)
WireMock stubs can be generated with Spring REST Docs,
+see Generating Stubs using REST Docs.
+This also works with Spring Auto REST Docs.
+However, the corresponding snippet does not register automatically
+and thus has to be registered manually.
+
+
+
The following code shows how the new WireMockSnippet() can be registered.
Afterwards the test JAR is located at
-spring-restdocs/spring-restdocs-core/build/libs/spring-restdocs-core-2.0.2.RELEASE-test.jar
+spring-restdocs/spring-restdocs-core/build/libs/spring-restdocs-core-2.0.3.RELEASE-test.jar
and has to be installed with the Maven command shown in the section above.
Order attribute. Available only if metadata type=2.
+
true (Available if metadata type=2)
+
Order attribute. (Available if metadata type=2).
sub
Object
-
true
-
Sub metadata (recursive). Not expanded as client should not see it.
+
true (Available if metadata type=2)
+
Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).
@@ -2586,7 +2586,7 @@
diff --git a/samples/kotlin-webmvc/pom.xml b/samples/kotlin-webmvc/pom.xml
index 051c3fad..111b0878 100644
--- a/samples/kotlin-webmvc/pom.xml
+++ b/samples/kotlin-webmvc/pom.xml
@@ -34,7 +34,7 @@
UTF-82.0.3.RELEASE
- 2.0.5-SNAPSHOT
+ 2.0.51.3.210.9.18${project.build.directory}/generated-javadoc-json
diff --git a/samples/shared/pom.xml b/samples/shared/pom.xml
index e5c817b6..aefd7fff 100644
--- a/samples/shared/pom.xml
+++ b/samples/shared/pom.xml
@@ -33,7 +33,7 @@
UTF-8
- 2.0.5-SNAPSHOT
+ 2.0.5
diff --git a/samples/shared/src/main/resources/org/springframework/restdocs/constraints/ConstraintDescriptions.properties b/samples/shared/src/main/resources/org/springframework/restdocs/constraints/ConstraintDescriptions.properties
index 6af55357..7d1760ff 100644
--- a/samples/shared/src/main/resources/org/springframework/restdocs/constraints/ConstraintDescriptions.properties
+++ b/samples/shared/src/main/resources/org/springframework/restdocs/constraints/ConstraintDescriptions.properties
@@ -2,6 +2,6 @@ capital.scalable.restdocs.example.constraints.OneOf.description=Must be one of $
capital.scalable.restdocs.example.constraints.English.description=EN: ${value}
capital.scalable.restdocs.example.constraints.German.description=DE: ${value}
capital.scalable.restdocs.example.constraints.Id.description=Must be a valid ID
-capital.scalable.restdocs.example.items.Metadata1.description=Available if metadata type=1
-capital.scalable.restdocs.example.items.Metadata2.description=Available if metadata type=2
-capital.scalable.restdocs.example.items.Metadata3.description=Available in specific conditions
\ No newline at end of file
+capital.scalable.restdocs.example.items.Metadata1.description=(Available if metadata type=1)
+capital.scalable.restdocs.example.items.Metadata2.description=(Available if metadata type=2)
+capital.scalable.restdocs.example.items.Metadata3.description=(Available in specific conditions)
\ No newline at end of file
diff --git a/spring-auto-restdocs-annotations/pom.xml b/spring-auto-restdocs-annotations/pom.xml
index ef7f889a..b9c89fb0 100644
--- a/spring-auto-restdocs-annotations/pom.xml
+++ b/spring-auto-restdocs-annotations/pom.xml
@@ -7,7 +7,7 @@
capital.scalablespring-auto-restdocs-parent
- 2.0.5-SNAPSHOT
+ 2.0.5..
diff --git a/spring-auto-restdocs-core/pom.xml b/spring-auto-restdocs-core/pom.xml
index 1b0a1c40..27cf641a 100644
--- a/spring-auto-restdocs-core/pom.xml
+++ b/spring-auto-restdocs-core/pom.xml
@@ -7,7 +7,7 @@
capital.scalablespring-auto-restdocs-parent
- 2.0.5-SNAPSHOT
+ 2.0.5..
diff --git a/spring-auto-restdocs-docs/index.adoc b/spring-auto-restdocs-docs/index.adoc
index c445094b..dfd87913 100644
--- a/spring-auto-restdocs-docs/index.adoc
+++ b/spring-auto-restdocs-docs/index.adoc
@@ -50,7 +50,7 @@ Is Kotlin supported?::
but works with both version of Spring Auto REST Docs. Take a look at the
https://github.com/ScaCap/spring-auto-restdocs/tree/master/samples/kotlin-webmvc[example].
Is Java 9/10/11 supported?::
- Yes, see <>.
+ Yes, see <>.
Does it work with REST Assured tests?::
Not yet. We may add support for REST Assured in the future, but your PR is also welcome.
Is Jackson required for automatic field documentation?::
diff --git a/spring-auto-restdocs-docs/other.adoc b/spring-auto-restdocs-docs/other.adoc
index 4161bd00..89741bd6 100644
--- a/spring-auto-restdocs-docs/other.adoc
+++ b/spring-auto-restdocs-docs/other.adoc
@@ -53,7 +53,65 @@ For custom translations of section titles, table headers and other messages:
1. Create a file `SnippetMessages.properties` in `capital.scalable.restdocs.i18n` package.
2. Add translations to the file using keys from link:{master-dir}/spring-auto-restdocs-core/src/test/resources/capital/scalable/restdocs/i18n/DefaultSnippetMessages.properties[DefaultSnippetMessages].[[localization]]
+[[recursive]]
=== Recursive structures support
To prevent infinite loop in recursive structures, annotate the recursive field with the `@RestdocsNotExpanded` annotation
from the `spring-auto-restdocs-annotations` maven module.
+
+[[subtypes]]
+=== Subtypes
+
+There are two forms of subtypes supported, automatic via Jackson annotations and manual via MockMvc configuration.
+You can even combine them together if necessary.
+
+==== Jackson subtypes
+
+Standard `JsonSubTypes` annotation and it's configuration is supported.
+
+.Jackson annotations
+[source,java]
+----
+@JsonTypeInfo(use = NAME, include = PROPERTY, property = "type", visible = true)
+@JsonSubTypes({
+ @JsonSubTypes.Type(value = Sub1.class, name = "1"),
+ @JsonSubTypes.Type(value = Sub2.class, name = "2")
+})
+abstract class Parent {
+ private String type;
+ private String common;
+}
+
+class Sub1 extends Parent {
+ private Boolean sub1;
+}
+
+class Sub2 extends Parent {
+ private Integer sub2;
+}
+----
+
+==== Custom subtypes
+
+If for any reason Jackson annotations are not desired or possible, you can configure completely custom subtypes
+via MockMvc using standard `JacksonResultHandlers.prepareJackson` result handler with custom `TypeMapping`.
+
+.MockMvc configuration
+[source,java]
+----
+.alwaysDo(prepareJackson(objectMapper, new TypeMapping()
+ .mapSubtypes(Parent.class, Sub1.class, Sub2.class)))
+
+----
+
+==== Discriminator text
+
+For better understanding which field is included when in the final documentation,
+<> can be used to provide a message,
+which will be then applied to all fields coming from that particular subtype.
+
+.ConstraintDescriptions.properties
+[source,ini]
+----
+mypackage.Sub1.description=(available when type=2)
+----
diff --git a/spring-auto-restdocs-docs/pom.xml b/spring-auto-restdocs-docs/pom.xml
index 16b42531..9a522eb7 100644
--- a/spring-auto-restdocs-docs/pom.xml
+++ b/spring-auto-restdocs-docs/pom.xml
@@ -6,7 +6,7 @@
capital.scalablespring-auto-restdocs-parent
- 2.0.5-SNAPSHOT
+ 2.0.5..
@@ -18,7 +18,7 @@
${project.basedir}/../docs
- 2.0.4
+ 2.0.5
diff --git a/spring-auto-restdocs-dokka-json/pom.xml b/spring-auto-restdocs-dokka-json/pom.xml
index 19a40a02..033e9a5c 100644
--- a/spring-auto-restdocs-dokka-json/pom.xml
+++ b/spring-auto-restdocs-dokka-json/pom.xml
@@ -5,7 +5,7 @@
capital.scalablespring-auto-restdocs-parent
- 2.0.5-SNAPSHOT
+ 2.0.5..
diff --git a/spring-auto-restdocs-json-doclet-jdk9/pom.xml b/spring-auto-restdocs-json-doclet-jdk9/pom.xml
index 52a5839d..92abfba5 100644
--- a/spring-auto-restdocs-json-doclet-jdk9/pom.xml
+++ b/spring-auto-restdocs-json-doclet-jdk9/pom.xml
@@ -5,12 +5,12 @@
capital.scalablespring-auto-restdocs-parent
- 2.0.5-SNAPSHOT
+ 2.0.5..spring-auto-restdocs-json-doclet-jdk9
- 2.0.5-SNAPSHOT
+ 2.0.5jarSpring Auto REST Docs Json Doclet for JDK9+
diff --git a/spring-auto-restdocs-json-doclet/pom.xml b/spring-auto-restdocs-json-doclet/pom.xml
index 6bced5ff..3fbc6c1b 100644
--- a/spring-auto-restdocs-json-doclet/pom.xml
+++ b/spring-auto-restdocs-json-doclet/pom.xml
@@ -5,7 +5,7 @@
capital.scalablespring-auto-restdocs-parent
- 2.0.5-SNAPSHOT
+ 2.0.5..