The plugin for building the samples assumed that the current working
directory would be the directory containing the project’s build.gradle.
While this is generally true on the command line (it isn’t if
-project-dir is used), it isn’t true in Gradle’s IDE integration. This
was leading to an NPE as the sampleBuild task was being configured
to depend on a null task as a result of not finding the sample’s pom.xml
or build.grade file.
This commit corrects the main build.gradle to configure each sample’s
working directory relative to the root project’s directory, rather
than relying on the working directory. It also improves
SampleBuildConfigurer so that it will throw an exception if it fails to
find a sample’s build.gradle or pom.xml rather than continuing
and triggering an NPE inside Gradle.
Closes gh-185
Documenting an XML attribute in the XML payload leads to a
NullPointerException since no parent nodes exists for an XML
attribute. Rather than always trying to remove a node from its parent,
this commit changes the logic to apply special treament to nodes that
are attributes and remove the attribute from its owning element
instead.
Closes gh-167
Previously, when the XML pretty printer attempted to pretty print
the content of a request or response it would output an error to
System.err if the content was not valid XML. While, benign, this
output was distracting.
This commit updates the XML pretty printer to suppress its output to
System.err by configuring it with an ErrorHandler and an ErrorListener
that swallow any errors of which they are notified.
Closes gh-153
Previously both samples supported Maven and Gradle. Due to the different
default locations between the two build systems, the Gradle-based sample
was configured to use Maven’s default location for its .adoc files.
The samples have now been updated so that one sample uses Maven and the
other uses Gradle. However, when this change was made, the customization
of the Gradle-based sample’s .adoc file location wasn’t removed.
This commit updates the Gradle-based sample to use the default location,
src/docs/asciidoc, for its .adoc source files.
Closes gh-145
Previously, it was necessary to document every payload field, link,
path parameter, or request. If an item was not documented a failure
would occur. This has proven to be too restrictive for some use cases,
for example splitting up the documentation of a payload’s fields. While
it was possible to use a preprocessor to modify the operation prior to
documentation to remove the items that should not be documented, this
was more difficult than it needed to be.
This commit adds support for marking a descriptor as ignored. Ignored
descriptors count when checking that everything has been documented but
do not actually appear in the generated documentation.
Closes gh-143
The main changes are:
- Update javadoc to align with changes made in 5a01016
- Update documentation with details of the new support for documenting
HTTP headers
- Add tests to verify that HTTP headers are matched case-insensitively
Closes gh-71
Previously, if a request had no content and it was a POST or a PUT
request, the curl request snippet would use the request's parameters
as application/x-www-form-urlencoded data sent using the -d option.
This resulted in the wrong snippet being produced if those parameters
had actually come from the request's query string.
This commit enhances CurlRequestSnippet so that, when it's using the
request's parameter's to create its content, it only includes
parameters that are not specified in the query string. With these
changes in place, this MockMvc request:
post("/?foo=bar").param("foo", "bar").param("a", "alpha")
Will produce a curl snippet with the following command:
$ curl 'http://localhost:8080/?foo=bar' -i -X POST -d 'a=alpha'
foo=bar only appears in the command's query string, despite also
being a general request parameter, and a=alpha only appears in the
request's data.
Closes gh-139
Previously, the Host header was treated specially in the HTTP request
snippet. If no Host header was specified, one would always be added
prior to producing the snippet. This ensured that the snippet was
valid (an HTTP 1.1 request must include a Host header), but came at
the cost of some confusion about why a preprocessor could not remove
it.
This commit updates the special treatment of the Host header so that
it's now performed in a central location so that all of the snippets
can benefit from a Host header being added if one isn't provided.
The handling of the Content-Length header has also been reworked so
that it's performed in the same location. The curl request snippet
has been updated so that it doesn't include setting the Host header
on the command line; it's unnecessary as curl will automatically
include a Host header in the request. The documentation of the
Host header's special treatment (made in 2fc0420) that noted that it
was unaffected by preprocessing has been reverted.
Closes gh-134
Previously, some MockMvc-specific logic would add a Content-Length
header to every request that had content. This led to the curl request
snippet containing a -H option for the Content-Length header. This is
unnecessary as curl will automatically generate a Content-Length
header based on the data that's being sent to the server. A secondary
problem was the inconsistent automatic addition of a Content-Length
header; the header was not automatically added to responses.
This commit remove the MockMvc-specific logic in favour of some new
logic in the core project to automatically add a Content-Length header
to both requests and responses. The curl request snippet has been
updated to supress the header in favour of curl's automatic
generation.
Closes gh-111