Commit Graph

28 Commits

Author SHA1 Message Date
Andy Wilkinson
8b2174cb84 Provide build status in the README 2015-01-08 18:11:40 +00:00
Andy Wilkinson
af93a32bde Reflect snapshots being available from https://repo.spring.io/snapshot
Update the README and the samples’ build.gradle and pom.xml files to
reflect snapshots now being available from
https://repo.spring.io/snapshot.

Closes #5
2015-01-08 18:06:38 +00:00
Andy Wilkinson
6ec522069a Make things less Gradle-specific and provide Maven config in samples
Previously, the project provided a Gradle plugin and was only really
intended for use with Gradle. This had influenced a number of design
choices that have proven to be less than ideal when attempting to
use the project with Maven.

This commit backs off from a number of design decisions that worked
well with Gradle but less so with Maven. Part of this is that the
Gradle plugin is (temporarily?) no more. It's been removed in favour
of configuring things directly in build.gradle. While this slightly
increases the amount of configuration required it makes things far
more flexible.

Both samples have been updated with modified Gradle configuration and
new Maven configuration. The README has also been updated to reflect
these changes.
2015-01-08 16:51:47 +00:00
Andy Wilkinson
f67b74304c Merge branch 'documentation-resulthandler'
Closes #3
2014-12-02 12:21:20 +00:00
Andy Wilkinson
23e8ad3dae Update the README to reflect the changes to how document is used 2014-12-02 12:20:40 +00:00
Rob Winch
ff7119ec54 RestDocumentationResultActions->RestDocumentationResultHandler
Previously documentation was handled by using a ResultActions
implementation that had custom methods added to it.

Now documentation is handled using a ResultHandler. This has a few
advantages:

- Fit better with the MockMvc programming model. This is similar to
  andDo(print())
- Support for using alwaysDo
2014-11-17 12:28:11 -06:00
Rossen Stoyanchev
e98658266c Update README.md to include link to presentation
Rework the opening paragraph and include a link to the Documenting
RESTful APIs presentation given at Spring Exchange 2014.

Closes gh-2
2014-11-13 15:17:29 +00:00
Andy Wilkinson
bd9597a933 Work around AsciiDoctor problem with absolute path includes on Windows
There's a bug in AsciiDoctor that causes it to handle includes of
absolute paths on Windows incorrectly. This results in the included
document being linked to rather than being included inline in the
document. See [1] for more details.

This commit introduces a work around for the problem. Rather than
using a file path for the includes a URI is now used instead. To
allow the URIs to be read the allow-uri-read attribute is also set.
See [2] for details of the work around.

Closes gh-1

[1] https://github.com/asciidoctor/asciidoctor/issues/1144
[2] http://discuss.asciidoctor.org/Including-a-file-using-an-absolute-path-under-Windows-1-5-0-tp2244p2245.html
2014-11-13 15:01:37 +00:00
Andy Wilkinson
5ccd7365cb Reinstate Java 7 compatibility 2014-11-13 13:45:34 +00:00
Andy Wilkinson
e9ac3ad709 Support link formats other than HAL by using a strategy to extract links 2014-11-05 14:33:39 +00:00
Andy Wilkinson
2b858c5cd9 Add support for automating the documentation of HAL Links 2014-11-04 21:22:26 +00:00
Andy Wilkinson
d06095ee72 Provide API guide examples alongside existing getting started guides 2014-11-04 17:23:12 +00:00
Andy Wilkinson
5168fcf93e Enable JSON pretty printing in the Spring HATEOAS-based sample 2014-11-04 11:40:35 +00:00
Andy Wilkinson
64d05fd76f Remove unnecessary escaping of newline characters in generated snippets 2014-11-04 11:40:16 +00:00
Andy Wilkinson
91498bb5b6 Improve rels in Spring-HATEOAS based sample and update the docs to match 2014-11-04 11:09:33 +00:00
Andy Wilkinson
57dd861958 Work around flow analysis bug in javac (JDK-8054569)
https://bugs.openjdk.java.net/browse/JDK-8054569
2014-11-04 10:46:47 +00:00
Andy Wilkinson
adddb1471a Improve error handling in the Spring HATEOAS-based sample 2014-11-04 10:32:55 +00:00
Andy Wilkinson
4cb6536d61 Uniquely name the main class of the two sample apps 2014-11-03 15:34:11 +00:00
Andy Wilkinson
42f4280687 Use unique rels in the Spring Hateoas variant of the sample app 2014-11-03 15:27:54 +00:00
Andy Wilkinson
0574699fad Use HAL in the Spring HATEOAS-based sample 2014-10-29 12:35:54 +00:00
Andy Wilkinson
34dcef2201 Add request method constraints to some request mappings
Some request mappings that were only intended to handle GET requests
were unconstrained. The commit adds a method = GET constraint to those
mappings to prevent them from handling other HTTP request methods
2014-10-29 10:38:16 +00:00
Andy Wilkinson
3ac27976ea Fix indentation in the README 2014-10-28 15:27:56 +00:00
Andy Wilkinson
44d6dfa2c0 Include language in snippets so that their syntax can be highlighted
cURL requests are marked as being bash and cURL responses are marked as
being http. This allows their syntax to be highlighted in the resulting
HTML.
2014-10-28 15:24:50 +00:00
Andy Wilkinson
01e37f1e4f Remove CGLib proxy “magic” in favour of an explicit document method
Previously, the name of an output file was automatically determined
by the name of the method from which the mockMvc.perform call was made.
While (somewhat) clever, to support this for non @Test methods, this
required the use of a CGLib proxy to push and pop some context that
kept track of the name of the current method. This meant it only worked
for non-private methods. It also made it hard to look at the code and
see what would and would not be documented.

This commit updates the library to provide an explicit document method
instead. This method takes the path of an output directory and a
MockMvc ResultActions instance, typically returned from a call to
mockMvc.perform. For example:

document("index",
        this.mockMvc.perform(get("/").accept(MediaTypes.HAL_JSON))
		.andExpect(status().isOk()));

This will perform a GET request to "/", assert that the response is
200 OK and write documentation snippets for the request and response
to a directory named index.
2014-10-28 15:10:56 +00:00
Andy Wilkinson
aa81f348d7 Fix error in README's markup 2014-10-23 15:47:14 +01:00
Andy Wilkinson
d5afc5d6f2 Update the README to reflect new functionality 2014-10-23 13:43:19 +01:00
Andy Wilkinson
c823296db0 Remove the need for manual documentCurlRequest/Response calls
Previously, whenever a MockMvc perform call was made and the request
and response were to be documented, calls to documentCurlRequest and
documentCurlResponse had to be made.

This commit updates the REST documentation framework to make the
documentation of the request and response automatic. It makes use of
MockMvc’s MockMvcConfigurer that was introduced in Spring 4.1. Applying
RestDocumentationConfiguration once will cause all requests and
responses to be documented:

this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
		.apply(new RestDocumentationConfiguration()).build();

The path to which the requests and response documentation snippets will
be written is determined by the class and method in which the MockMvc
perform call is made and is currently of the form
shortClassName/methodName(Request|Response|RequestResponse).asciidoc
where shortClassName is the name of the documentation class without its
package. This works for both @Test methods and any non-private methods
that are called from the test method. The methods must be non-private as
a CGLib proxy is used to intercept the calls and configure the output
path.
2014-10-23 11:37:24 +01:00
Andy Wilkinson
b7904bcad7 Initial commit 2014-10-08 14:04:52 +01:00