From bad44d91acd3b28c26eefe373422c238a18a04d7 Mon Sep 17 00:00:00 2001 From: Juraj Misur Date: Mon, 6 May 2019 10:07:00 +0200 Subject: [PATCH] 2.0.5 release (#319) * 2.0.5 RELEASE * regenerated docs --- README.md | 2 +- docs/index.html | 199 ++++++++++--- pom.xml | 2 +- .../java-webflux/generated-docs/index.html | 69 +++-- samples/java-webflux/pom.xml | 2 +- samples/java-webmvc/build.gradle | 2 +- samples/java-webmvc/generated-docs/index.html | 261 ++++++++++++------ samples/java-webmvc/pom.xml | 2 +- samples/kotlin-webmvc/build.gradle | 2 +- .../kotlin-webmvc/generated-docs/index.html | 90 +++--- samples/kotlin-webmvc/pom.xml | 2 +- samples/shared/pom.xml | 2 +- .../ConstraintDescriptions.properties | 6 +- spring-auto-restdocs-annotations/pom.xml | 2 +- spring-auto-restdocs-core/pom.xml | 2 +- spring-auto-restdocs-docs/index.adoc | 2 +- spring-auto-restdocs-docs/other.adoc | 58 ++++ spring-auto-restdocs-docs/pom.xml | 4 +- spring-auto-restdocs-dokka-json/pom.xml | 2 +- spring-auto-restdocs-json-doclet-jdk9/pom.xml | 4 +- spring-auto-restdocs-json-doclet/pom.xml | 2 +- 21 files changed, 495 insertions(+), 222 deletions(-) diff --git a/README.md b/README.md index b18883d8..09e21420 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ from the Introducing Spring Auto REST Docs talk at Spring IO 2017 are also avail [Current 1.0.14 release](https://htmlpreview.github.io/?https://github.com/ScaCap/spring-auto-restdocs/blob/v1.0.14/docs/index.html) reference guide (based on Spring REST Docs 1.x). -Latest master [2.0.5-SNAPSHOT](https://scacap.github.io/spring-auto-restdocs) reference guide. +Latest master [2.0.5](https://scacap.github.io/spring-auto-restdocs) reference guide. Older releases: [2.0.3](https://htmlpreview.github.io/?https://github.com/ScaCap/spring-auto-restdocs/blob/v2.0.3/docs/index.html), diff --git a/docs/index.html b/docs/index.html index 985aad56..04c729d5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -437,7 +437,7 @@

Spring Auto REST Docs

Scalable Capital
- version 2.0.4 +version 2.0.5
Table of Contents
@@ -485,6 +485,13 @@

Spring Auto REST Docs

  • Deprecation support
  • See tag support
  • Localization support
  • +
  • Recursive structures support
  • +
  • Subtypes
  • + + +
  • Integrations +
  • Contributing @@ -559,8 +566,8 @@

    FAQ

    example.

  • -

    Is Java 9 supported?

    -

    Yes, see Getting Started.

    +

    Is Java 9/10/11 supported?

    +

    Yes, see Getting Started.

  • Does it work with REST Assured tests?

    @@ -616,7 +623,7 @@

    documentation)

    +

    Spring REST Docs 2.0.3.RELEASE (see documentation)

  • Jackson has to be used for creating and parsing JSON

    @@ -628,7 +635,7 @@

    -

    For Java 9 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.

    +

    For Java 9/10/11 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.

  • @@ -636,7 +643,7 @@

    Usage
    1. -

      Setup project for Spring REST Docs

      +

      Setup project for Spring REST Docs

    2. Additional configuration for this extension:

      @@ -646,8 +653,8 @@

      Usage
      <dependency>
           <groupId>capital.scalable</groupId>
           <artifactId>spring-auto-restdocs-core</artifactId>
      -    <version>2.0.4</version>
      -    <scope>test</scope> (1)
      +    <version>2.0.5</version>
      +    <scope>test</scope>
       </dependency>
       
       <build>
      @@ -660,10 +667,10 @@ 

      Usage </includes> <systemPropertyVariables> <org.springframework.restdocs.outputDir> - ${project.build.directory}/generated-snippets (2) + ${project.build.directory}/generated-snippets (1) </org.springframework.restdocs.outputDir> <org.springframework.restdocs.javadocJsonDir> - ${project.build.directory}/generated-javadoc-json (3) + ${project.build.directory}/generated-javadoc-json (2) </org.springframework.restdocs.javadocJsonDir> </systemPropertyVariables> </configuration> @@ -682,11 +689,11 @@

      Usage <doclet>capital.scalable.restdocs.jsondoclet.ExtractDocumentationAsJsonDoclet</doclet> <docletArtifact> <groupId>capital.scalable</groupId> - <artifactId>spring-auto-restdocs-json-doclet</artifactId> (4) - <version>2.0.4</version> + <artifactId>spring-auto-restdocs-json-doclet</artifactId> (3) + <version>2.0.5</version> </docletArtifact> - <destDir>generated-javadoc-json</destDir> (3) - <reportOutputDirectory>${project.build.directory}</reportOutputDirectory> (3) + <destDir>generated-javadoc-json</destDir> (2) + <reportOutputDirectory>${project.build.directory}</reportOutputDirectory> (2) <useStandardDocletOptions>false</useStandardDocletOptions> <show>package</show> </configuration> @@ -702,21 +709,17 @@

      Usage - - - - - + - - + +
      1Has to be removed if @RestdocsNotExpanded is used.
      2 (Optional) Determines directory where snippets are saved. Defaults to generated-snippets in build directory.
      32 (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.
      4For Java 9 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.3For Java 9/10/11 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.

    @@ -728,26 +731,26 @@

    Usage } ext { - javadocJsonDir = file("$buildDir/generated-javadoc-json") (3) + javadocJsonDir = file("$buildDir/generated-javadoc-json") (2) } dependencies { - testCompile group: 'capital.scalable', name: 'spring-auto-restdocs-core', version: '2.0.4' (1) - jsondoclet group: 'capital.scalable', name: 'spring-auto-restdocs-json-doclet', version: '2.0.4' (4) + testCompile group: 'capital.scalable', name: 'spring-auto-restdocs-core', version: '2.0.5' + jsondoclet group: 'capital.scalable', name: 'spring-auto-restdocs-json-doclet', version: '2.0.5' (3) } task jsonDoclet(type: Javadoc, dependsOn: compileJava) { source = sourceSets.main.allJava classpath = sourceSets.main.compileClasspath - destinationDir = javadocJsonDir (3) + destinationDir = javadocJsonDir (2) options.docletpath = configurations.jsondoclet.files.asType(List) options.doclet = 'capital.scalable.restdocs.jsondoclet.ExtractDocumentationAsJsonDoclet' options.memberLevel = JavadocMemberLevel.PACKAGE } test { - systemProperty 'org.springframework.restdocs.outputDir', snippetsDir (2) - systemProperty 'org.springframework.restdocs.javadocJsonDir', javadocJsonDir (3) + systemProperty 'org.springframework.restdocs.outputDir', snippetsDir (1) + systemProperty 'org.springframework.restdocs.javadocJsonDir', javadocJsonDir (2) dependsOn jsonDoclet } @@ -761,22 +764,18 @@

    Usage - - - - - + - - + +
    1Has 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.
    32 (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.
    4For Java 9 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.3For Java 9/10/11 support, use spring-auto-restdocs-json-doclet-jdk9 as doclet dependency.

    @@ -2008,10 +2007,10 @@

    Custom snippet<

    Snippet customization

    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.

    +See also original documentation for additional details.

    @@ -2107,7 +2106,7 @@

    Custom co Each description is a property where the key is the full class name of the annotation suffixed with .description. The value is the description and can contain placeholders for annotation methods, e.g. ${value} to get the content of value(). -For more details, see original documentation of here.

    +For more details, see original documentation of here.

    Example for the constraint annotation myproject.constraints.OneOf:

    @@ -2315,11 +2314,119 @@

    Localization support<

    Create a file SnippetMessages.properties in capital.scalable.restdocs.i18n package.

  • -

    Add translations to the file using keys from DefaultSnippetMessages.

    +

    Add translations to the file using keys from DefaultSnippetMessages.

  • +
    +

    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

    +
    +

    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
    +
    +
    @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
    +
    +
    .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, +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)
    +
    +
    +
    +
    + + +
    +

    Integrations

    +
    +
    +

    WireMock

    +
    +

    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.

    +
    +
    +
    WireMock snippet registration example
    +
    +
    public void setUp() {
    +     this.mockMvc = MockMvcBuilders
    +                .webAppContextSetup(context)
    +                .alwaysDo(prepareJackson(objectMapper))
    +                .alwaysDo(document("{class-name}/{method-name}",
    +                                   preprocessRequest(), commonResponsePreprocessor()))
    +                .apply(documentationConfiguration(restDocumentation)
    +                               .uris()
    +                               .and().snippets()
    +                               .withDefaults(curlRequest(), httpRequest(), httpResponse(),
    +                                             requestFields(), responseFields(), pathParameters(),
    +                                             requestParameters(), description(), methodAndPath(),
    +                                             section(), new WireMockSnippet()))
    +                .build();
    +}
    +
    +
    +
    @@ -2350,7 +2457,7 @@

    -

    We use version 2.0.2.RELEASE of Spring REST Docs in this example.

    +

    We use version 2.0.3.RELEASE of Spring REST Docs in this example.

    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.

    @@ -2401,8 +2508,8 @@

    diff --git a/pom.xml b/pom.xml index a11c5463..00f2a604 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ capital.scalable spring-auto-restdocs-parent - 2.0.5-SNAPSHOT + 2.0.5 pom Spring Auto REST Docs Parent POM diff --git a/samples/java-webflux/generated-docs/index.html b/samples/java-webflux/generated-docs/index.html index f01b6985..bf2c8ff8 100644 --- a/samples/java-webflux/generated-docs/index.html +++ b/samples/java-webflux/generated-docs/index.html @@ -553,14 +553,20 @@

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    meta.sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    attributes

    @@ -644,13 +650,14 @@

    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -Content-Length: 459
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
     Expires: 0
    -X-Content-Type-Options: nosniff
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
    +Referrer-Policy: no-referrer
    +Content-Length: 459
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     X-XSS-Protection: 1 ; mode=block
     
     {
    @@ -758,14 +765,20 @@ 

    [].meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    [].meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    [].meta.sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    [].attributes

    @@ -849,12 +862,13 @@

    <
    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
     Expires: 0
    -X-Content-Type-Options: nosniff
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
    +Referrer-Policy: no-referrer
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     X-XSS-Protection: 1 ; mode=block
     Content-Length: 598
     
    @@ -1026,14 +1040,20 @@ 

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    meta.sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    attributes

    @@ -1119,14 +1139,15 @@

    <
    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -Content-Length: 124
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
     Expires: 0
    -X-Content-Type-Options: nosniff
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
    +Referrer-Policy: no-referrer
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     X-XSS-Protection: 1 ; mode=block
    +Content-Length: 124
     
     {
       "id" : "1",
    @@ -1145,7 +1166,7 @@ 

    <

    diff --git a/samples/java-webflux/pom.xml b/samples/java-webflux/pom.xml index b1784480..66c89875 100644 --- a/samples/java-webflux/pom.xml +++ b/samples/java-webflux/pom.xml @@ -35,7 +35,7 @@ UTF-8 capital.scalable.restdocs.example.Application 2.0.3.RELEASE - 2.0.5-SNAPSHOT + 2.0.5 diff --git a/samples/java-webmvc/build.gradle b/samples/java-webmvc/build.gradle index 8fb8fd02..2f316869 100644 --- a/samples/java-webmvc/build.gradle +++ b/samples/java-webmvc/build.gradle @@ -1,6 +1,6 @@ buildscript { ext { - springAutoRestDocsVersion = "2.0.5-SNAPSHOT" + springAutoRestDocsVersion = "2.0.5" springRestDocsVersion = "2.0.3.RELEASE" springBootVersion = "2.1.3.RELEASE" } diff --git a/samples/java-webmvc/generated-docs/index.html b/samples/java-webmvc/generated-docs/index.html index 4873f68d..68323c9e 100644 --- a/samples/java-webmvc/generated-docs/index.html +++ b/samples/java-webmvc/generated-docs/index.html @@ -732,14 +732,28 @@

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)
    +true (Available in specific conditions)

    +

    Tag attribute. (Available if metadata type=1)
    +Tag attribute. (Available in specific conditions).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    meta.sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    + + +

    meta.info

    +

    String

    +

    true (Available in specific conditions)

    +

    Info attribute. (Available in specific conditions).

    attributes

    @@ -820,14 +834,14 @@

    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
     Content-Length: 459
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     
     {
       "id" : "1",
    @@ -938,14 +952,28 @@ 

    [].meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)
    +true (Available in specific conditions)

    +

    Tag attribute. (Available if metadata type=1)
    +Tag attribute. (Available in specific conditions).

    [].meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    [].meta.sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    + + +

    [].meta.info

    +

    String

    +

    true (Available in specific conditions)

    +

    Info attribute. (Available in specific conditions).

    [].attributes

    @@ -1029,13 +1057,13 @@

    @@ -1177,13 +1205,13 @@

    HTTP/1.1 201 Created
    -Location: /items/2
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
    -X-Frame-Options: DENY
    +X-Frame-Options: DENY +X-Content-Type-Options: nosniff +Location: /items/2 +Cache-Control: no-cache, no-store, max-age=0, must-revalidate

    @@ -1320,14 +1348,28 @@

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)
    +true (Available in specific conditions)

    +

    Tag attribute. (Available if metadata type=1)
    +Tag attribute. (Available in specific conditions).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    meta.sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    + + +

    meta.info

    +

    String

    +

    true (Available in specific conditions)

    +

    Info attribute. (Available in specific conditions).

    attributes

    @@ -1416,7 +1458,7 @@

    $ curl 'http://localhost:8080/items/1' -i -X PUT \
         -H 'Content-Type: application/json' \
    -    -H 'Authorization: Bearer d1c9b00e-97e2-46a4-ab14-eecf930a3377' \
    +    -H 'Authorization: Bearer 904105cb-7a6d-4513-ada1-cc27ab84508e' \
         -d '{"description":"Hot News"}'
    @@ -1426,13 +1468,13 @@

    <
    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Content-Length: 124
     
     {
    @@ -1534,7 +1576,7 @@ 

    $ curl 'http://localhost:8080/items/1' -i -X DELETE \
    -    -H 'Authorization: Bearer d1c9b00e-97e2-46a4-ab14-eecf930a3377'
    + -H 'Authorization: Bearer 904105cb-7a6d-4513-ada1-cc27ab84508e'

    @@ -1543,12 +1585,12 @@

    <
    HTTP/1.1 200 OK
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
    -X-Frame-Options: DENY
    +X-Frame-Options: DENY +X-Content-Type-Options: nosniff +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
    @@ -1662,14 +1704,28 @@

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)
    +true (Available in specific conditions)

    +

    Tag attribute. (Available if metadata type=1)
    +Tag attribute. (Available in specific conditions).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    meta.sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    + + +

    meta.info

    +

    String

    +

    true (Available in specific conditions)

    +

    Info attribute. (Available in specific conditions).

    attributes

    @@ -1765,13 +1821,13 @@

    <
    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Content-Length: 133
     
     {
    @@ -1901,14 +1957,28 @@ 

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)
    +true (Available in specific conditions)

    +

    Tag attribute. (Available if metadata type=1)
    +Tag attribute. (Available in specific conditions).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    meta.sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    + + +

    meta.info

    +

    String

    +

    true (Available in specific conditions)

    +

    Info attribute. (Available in specific conditions).

    attributes

    @@ -2004,14 +2074,14 @@

    <
    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +Content-Length: 1072
    +X-XSS-Protection: 1; mode=block
     Expires: 0
     X-Frame-Options: DENY
    -Content-Length: 1011
    +X-Content-Type-Options: nosniff
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     
     {
       "content" : [ {
    @@ -2045,7 +2115,8 @@ 

    < "sort" : { "orders" : [ ], "sorted" : false, - "unsorted" : true + "unsorted" : true, + "empty" : true }, "offset" : 0, "pageSize" : 20, @@ -2054,9 +2125,9 @@

    < "unpaged" : false }, "total" : 1, - "last" : true, "totalPages" : 1, "totalElements" : 1, + "last" : true, "size" : 20, "number" : 0, "numberOfElements" : 1, @@ -2064,8 +2135,10 @@

    < "sort" : { "orders" : [ ], "sorted" : false, - "unsorted" : true - } + "unsorted" : true, + "empty" : true + }, + "empty" : false }

    @@ -2181,14 +2254,14 @@

    <
    HTTP/1.1 200 OK
    -Content-Type: text/plain;charset=UTF-8
    -Content-Length: 28
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
    +Content-Length: 28
    +Content-Type: text/plain;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     
     {
       "output" : "processed"
    @@ -2342,14 +2415,14 @@ 

    <
    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
    +Content-Length: 55
     Expires: 0
     X-Frame-Options: DENY
    -Content-Length: 55
    +X-Content-Type-Options: nosniff
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     
     {
       "output" : "Command executed on item 1: increase"
    @@ -2414,14 +2487,28 @@ 

    tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)
    +true (Available in specific conditions)

    +

    Tag attribute. (Available if metadata type=1)
    +Tag attribute. (Available in specific conditions).

    order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    + + +

    sub

    +

    Object

    +

    true (Available if metadata type=2)

    +

    Sub metadata (recursive). Not expanded as client should not see it. (Available if metadata type=2).

    + + +

    info

    +

    String

    +

    true (Available in specific conditions)

    +

    Info attribute. (Available in specific conditions).

    @@ -2459,12 +2546,12 @@

    <
    HTTP/1.1 200 OK
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
    -X-Frame-Options: DENY
    +X-Frame-Options: DENY +X-Content-Type-Options: nosniff +Cache-Control: no-cache, no-store, max-age=0, must-revalidate

    @@ -2562,12 +2649,12 @@

    <
    HTTP/1.1 200 OK
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
    -X-Frame-Options: DENY
    +X-Frame-Options: DENY +X-Content-Type-Options: nosniff +Cache-Control: no-cache, no-store, max-age=0, must-revalidate

    @@ -2770,14 +2857,14 @@

    HTTP/1.1 200 OK
    -Content-Type: application/hal+json;charset=UTF-8
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
    +Content-Type: application/hal+json;charset=UTF-8
     Content-Length: 756
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     
     {
       "id" : "1",
    @@ -2920,14 +3007,14 @@ 

    HTTP/1.1 200 OK
    -Content-Type: application/json;charset=UTF-8
    -X-Content-Type-Options: nosniff
    -X-XSS-Protection: 1; mode=block
    -Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     Pragma: no-cache
    +X-XSS-Protection: 1; mode=block
     Expires: 0
     X-Frame-Options: DENY
    +X-Content-Type-Options: nosniff
     Content-Length: 459
    +Content-Type: application/json;charset=UTF-8
    +Cache-Control: no-cache, no-store, max-age=0, must-revalidate
     
     {
       "id" : "1",
    diff --git a/samples/java-webmvc/pom.xml b/samples/java-webmvc/pom.xml
    index dc12b060..d7f4c612 100644
    --- a/samples/java-webmvc/pom.xml
    +++ b/samples/java-webmvc/pom.xml
    @@ -35,7 +35,7 @@
             UTF-8
             capital.scalable.restdocs.example.Application
             2.0.3.RELEASE
    -        2.0.5-SNAPSHOT
    +        2.0.5
         
     
         
    diff --git a/samples/kotlin-webmvc/build.gradle b/samples/kotlin-webmvc/build.gradle
    index 9b1d57a6..e99d7840 100644
    --- a/samples/kotlin-webmvc/build.gradle
    +++ b/samples/kotlin-webmvc/build.gradle
    @@ -1,7 +1,7 @@
     buildscript {
         ext {
             kotlinVersion = "1.3.21"
    -        springAutoRestDocsVersion = "2.0.5-SNAPSHOT"
    +        springAutoRestDocsVersion = "2.0.5"
             springRestDocsVersion = "2.0.3.RELEASE"
             springBootVersion = "2.1.3.RELEASE"
             dokkaVersion = "0.9.18"
    diff --git a/samples/kotlin-webmvc/generated-docs/index.html b/samples/kotlin-webmvc/generated-docs/index.html
    index f11082e5..13e2b3d6 100644
    --- a/samples/kotlin-webmvc/generated-docs/index.html
    +++ b/samples/kotlin-webmvc/generated-docs/index.html
    @@ -728,20 +728,20 @@ 

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    meta.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).

    attributes

    @@ -925,20 +925,20 @@

    [].meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    [].meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    [].meta.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).

    [].attributes

    @@ -1146,7 +1146,7 @@

    $ curl 'http://localhost:8080/items' -i -X POST \
    -    -H 'Authorization: Bearer 8a772ec6-56cd-4ca0-9331-bbf2672e769e' \
    +    -H 'Authorization: Bearer 73c2231c-2c16-4523-8160-ef14f96cc797' \
         -H 'Content-Type: application/json' \
         -d '{"description":"Hot News"}'
    @@ -1300,20 +1300,20 @@

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    meta.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).

    attributes

    @@ -1389,7 +1389,7 @@

    $ curl 'http://localhost:8080/items/1' -i -X PUT \
    -    -H 'Authorization: Bearer 8a772ec6-56cd-4ca0-9331-bbf2672e769e' \
    +    -H 'Authorization: Bearer 73c2231c-2c16-4523-8160-ef14f96cc797' \
         -H 'Content-Type: application/json' \
         -d '{"description":"Hot News"}'
    @@ -1492,7 +1492,7 @@

    $ curl 'http://localhost:8080/items/1' -i -X DELETE \
    -    -H 'Authorization: Bearer 8a772ec6-56cd-4ca0-9331-bbf2672e769e'
    + -H 'Authorization: Bearer 73c2231c-2c16-4523-8160-ef14f96cc797'

    @@ -1618,20 +1618,20 @@

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    meta.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).

    attributes

    @@ -1849,20 +1849,20 @@

    meta.tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    meta.order

    Integer

    -

    true

    -

    Order attribute. Available only if metadata type=2.

    +

    true (Available if metadata type=2)

    +

    Order attribute. (Available if metadata type=2).

    meta.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).

    attributes

    @@ -1990,26 +1990,26 @@

    < "unsorted" : true, "empty" : true }, + "offset" : 0, "pageSize" : 20, "pageNumber" : 0, - "offset" : 0, "unpaged" : false, "paged" : true }, "total" : 1, + "last" : true, "totalPages" : 1, "totalElements" : 1, - "last" : true, + "size" : 20, + "number" : 0, "first" : true, + "numberOfElements" : 1, "sort" : { "orders" : [ ], "sorted" : false, "unsorted" : true, "empty" : true }, - "numberOfElements" : 1, - "size" : 20, - "number" : 0, "empty" : false } @@ -2334,20 +2334,20 @@

    tag

    String

    -

    true

    -

    Tag attribute. Available only if metadata type=1.

    +

    true (Available if metadata type=1)

    +

    Tag attribute. (Available if metadata type=1).

    order

    Integer

    -

    true

    -

    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-8 2.0.3.RELEASE - 2.0.5-SNAPSHOT + 2.0.5 1.3.21 0.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.scalable spring-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.scalable spring-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.scalable spring-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.scalable spring-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.scalable spring-auto-restdocs-parent - 2.0.5-SNAPSHOT + 2.0.5 .. spring-auto-restdocs-json-doclet-jdk9 - 2.0.5-SNAPSHOT + 2.0.5 jar Spring 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.scalable spring-auto-restdocs-parent - 2.0.5-SNAPSHOT + 2.0.5 ..