Previously, missing field detection worked correctly for paths
containing a single array, but if the path contained multiple arrays
the extracted value would be a list containing a single empty list.
In this case the field would not be considered missing when, in fact
it should have been.
This commit updates the missing field detection logic to recursively
examine the extracted value and, when it's a collection, the values
that it contains. As a result, a field will be considered to be
missing if it isn't present, if it's an empty collection, or if it's
a collection that only contains empty collections or, to any depth,
collections of empty collections.
Closes gh-519
Previously, FieldDoesNotExistException was caught when extracting
a field to determine whether or not it is missing (absent or an
empty collection). The handling is redundant due to an earlier call
to hasField so this commit removes it.
Closes gh-525
Previously, when a field's type was automatically determined, the
type of the passed-in descriptor was changed. This could cause
problems if the descriptor was reused in another test.
This commit updates AbstractFieldsSnippet to create a copy of each
descriptor so that setting the determined type does not affect the
type of the original descriptor.
Closes gh-511
Previously, when generating Asciidoctor snipppets, the title of the
path parameter table was interpolated. The title of the table is the
path including its parameters. The parameters are typically surrounded
by { and }. This is the same syntax used for attributes in
Asciidoctor. With interpolation enabled this caused Asciidoctor to
interpret the parameter as an attribute reference and attempt to
replace it. This would either result in unwanted replacement of the
parameter with the value of the attribute or it would result in a
warning about a missing attribute.
This commit surrounds the title of the table with + characters. This
disables all interpolation for the title, thereby preventing
unwanted replacement or attempted replacement of the path's
parameters.
Closes gh-527
The changes made in 7476562d inadvertently caused a field that is
an descendant of an array and a child of an optional field to be
considered missing when its parent is only sometimes present. Due to
the parent being optional, the parent’s absence should not cause the
absent child to be considered to be missing.
Closes gh-519
Previously if a request body contained form URL encoded content,
parameters would be duplicated in the request body and in the
request URL in the curl, HTTPie, and HTTP request snippets.
This commit updates the affected snippets so that parameters are not
added to the URL when they will also be represented in the request
body.
Closes gh-514
Previously, if text enclosed in ` characters contained multiple *
characters, the *s would be removed and the characters they enclosed
would become bold.
This commit escapes the text by enclosing it in + characters in
addition to the existing, enclosing ` characters. The `+text+`
arrangement retains the monospace formatting be disables any further
formatting of the text.
Closes gh-474
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