Previously, the ordering was:
1. Operation snippets
2. Default snippets
3. Additional snippets
This meant that any operation snippets (those specifically configured
for the documentation of the particular operation) would be
overwritten by the output of the default snippets.
This commit updates the ordering to the following:
1. Default snippets
2. Operation snippets
3. Additional snippets
Closes gh-453
Previously, StandardWriterResolver only replaced placeholders in the
operation name. This meant that the name and location of generated
snippets was unnecessarily limited.
This commit makes things more flexible by updating
StandardWriterResolver to replace placeholders in the snippet name
as well.
Closes gh-403
Previously, if a field nested beneath an optional field was documented
and was required, it would be identified as missing even if its
optional ancestor was missing. This made it impossible to document
required fields of an optional subsection of a payload.
This commit updates JsonContentHandler to consider a field’s ancestors
when determining if it should be reported as missing. If the field
field has an optional ancestor that is not present, the field is not
considered to be missing if it too is not present. If the field has
an optional ancestor that is present then the field is considered to
be missing if it is not present.
Closes gh-429
Previously, if an array contained objects where a field was sometimes
null and sometimes had a value of a consistent type, the type inferred
type was varies. Furthermore, it was not possible for the user to
specify a type other than varies as a mismatch would be detected.
This commit updates JsonFieldTypeResolver so that, when dealing with
an imprecise field path (i.e. a path for a field within an array),
null values that don't match the common type for the field are
ignored. This produces the following behavior when nulls are involved:
- All null fields results in the null type
- A mixture of nulls and a particular type results in the particular
type
- A mixture of nulls and two or more other types results in the varies
type
Closes gh-398
Previously, the document fields in an XML payload, the request or
response had to have an application/xml content type. This prevented
documenting standard XML content types such as text/xml and
application/rss+xml as well as payloads with custom XML content types.
This commit updates the logic that sets up the ContentHandler to
first attempt to parse the content as JSON. If that fails it then
parses it as XML. If that fails an exception is thrown. This allows
any JSON or XML content, irrespective of the actual content type, to
be documented.
Closes gh-393
Previously, if a field was marked as optional and it appeared in a
payload with a null value a failure would occur if the field's type
was configured to be a JsonFieldType other than NULL.
This commit relaxes this restriction so that a null value is tolerated
when a field has been marked as optional.
Closes gh-365
Previously, when a field was documented it would implicitly document
the whole subsection of the payload identified by that field. This
could lead to users inadvertently failing to document part of the
payload. Arguably, this was a bug as it violated REST Docs' principle
of producing accurate, detail documentation. However, fixing it
requires a breaking change as people may also be relying on this
behaviour. A balance needed to be struck so the fix is being made in
a minor release.
This commit introduces a new subsectionWithPath method which returns a
SubsectionDescriptor; a specialisation of FieldDescriptor. Users
that were intentionally relying on the old behaviour will have to
replace some usage of fieldWithPath with subsectionWithPath instead.
Users who were unintentionally relying on the old behaviour will have
to add some additional descriptors produced using fieldWithPath and
will receive more accurate documentation in return.
Closes gh-274
- Rebase on latest code, and make use of new support for the same
TemplatedSnippet producing multiple snippets with different names
from the same template
- Expand the documentation
- Apply code formatting
- Add support for relaxed documentation of a request part's fields
Closes gh-270
Previously a TemplatedSnippet could only write snippets with the
same name as its template. This meant that the same template could
not be used to produce multiple snippets with different names.
This commit separates the snippet name from the template name, thereby
allowing the snippet name to vary while the template name remains the
same. For backwards compatibility, the default behaviour is for the
template name and snippet name to remain the same. The new overloaded
constructor can be used when the names need to differ.
Closes gh-320
Rather than introducing a custom macro, this commit opts to implicitly
configure the snippets attribute instead. The attribute is configured
will the path into which snippets are generated, relative to the
directory that contains the Asciidoctor document that is being
rendered.
The samples and documentation have been updated to use the new
spring-restdocs-asciidoctor module and the implicitly configured
snippets attribute.
Closes gh-297
Rather than requiring an output directory to be explcitly configured,
a default is now automatically configured based on the build tool
that's being used. When using Gradle, snippets will be generated in
build/generated-snippets. When using Maven, snippets will be
generated in target/generated-snippets.
See gh-297
Previously, the logic that determined the field’s type would incorrectly
look at the contents of the array. For example, if the array contained
one or more objects, the field’s type would be resolved as Object rather
than Array.
This commit updates JsonFieldPath to record when a path explicitly
identifies an array so that the array itself is used to determine the
field’s type rather than its contents.
Closes gh-292
QueryStringParser has been moved into the operation page. In the
unlikely event that there were any external users of the class, a
deprecated version remains in the cli package for backwards
compatibility. It will be removed in 1.2.
Closes gh-286