Commit Graph

60 Commits

Author SHA1 Message Date
Yann Le Guern
cc54e5d7b0 Consider parameters when performing a POST request
Previously, when producing the curl snippet for a POST request, the
request's parameter map was ignored. This commit updates the snippet
generation to look at the parameter map and POST it to the server
as application/x-www-form-urlencoded data using -d

Closes gh-38
2015-03-23 12:27:56 +00:00
Andy Wilkinson
8b133c7c66 Customize the mvn command based on the OS when building the samples
See gh-33
2015-03-17 14:06:33 +00:00
Andy Wilkinson
45fe87995f Use MAVEN_HOME when calling mvn to build the samples using Maven
See gh-33
2015-03-17 10:42:43 +00:00
Andy Wilkinson
23a6388177 Escape & characaters in curl request URLs
Without escaping, the & will cause bash to truncate the URL and
background the curl process.

Closes gh-35
2015-03-16 14:45:54 +00:00
Yann Le Guern
c3efc4128f Use request parameters to create query string for GET requests
Previously, only the request's query string was considered when
creating the curl command's request URI. This meant that query
parameters configured via request.addParameter where not included in
the URI.

This commit enhances CurlRequestDocumentationAction so that, in the
absence of a query string, it will use a GET request's parameters to
produce the query string include in the curl command's URI.

Closes gh-26
Closes gh-30
2015-03-16 14:31:36 +00:00
Andy Wilkinson
f649e1a170 Add support to DocumentationWriter for producing tables
This commit adds an API to DocumentationWriter for producing
documentation snippets containing tables. The API is intended to be
fairly simple such that it can be implemented for a variety of
different output formats, and not just for Asciidoctor (the only
currently supported format).

Closes gh-34
2015-03-16 13:52:00 +00:00
Yann Le Guern
d6bd4870fd Fix AsciidoctorWriterTests on Windows
Use String.format and %n so that the test's expectations are correct
on Windows and Unix-like platforms.

Fixes gh-29
2015-03-16 11:13:09 +00:00
Andy Wilkinson
7041c2b202 Polish: add missing copyright header 2015-02-25 12:30:17 +00:00
Andy Wilkinson
1eeb605108 Support using alwaysDo to automatically document every MockMvc call
The MVC test framework provides an alwaysDo method which allows the
configuration of a result handler to be that will be invoked for every
call to perform. Previously, this method could not be used for
producing documentation snippets as the snippets would overwrite each
other.

This commit adds support for writing snippets to a parameterized
output directory. Two parameters are supported: method name and step.
Method name is the name of the currently executing test method. Step
is a count of the number of calls to MockMvc.perform that have been
made in that method.

Closes gh-14
2015-02-25 12:22:00 +00:00
Ronald Kurr
289ba57159 Update README to recommend that pretty printing of JSON is enabled
Closes gh-16
2015-02-24 11:54:33 +00:00
Andy Wilkinson
565a57e5da Update the README following rename of RestDocumentationConfiguration 2015-02-24 11:32:22 +00:00
Andy Wilkinson
ea77bd530a Document Spring Framework 4.1 as a requirement
Closes gh-20
2015-02-24 11:30:22 +00:00
Andy Wilkinson
c41542f464 Omit port in curl request snippet if it’s the default for the scheme
Previously an HTTP request to localhost on port 80 or an HTTPS request
to localhost on 443 would generate curl request snippets with the
uris http://localhost:80 and https://localhost:443 respectively. While
specifying the port does no harm, it is unnecessary.

This commit updates CurlDocumentation so that the uri in the request
snippet does not include the port when the port is the default for the
uri’s scheme.

Closes gh-17
2015-02-23 14:25:50 +00:00
andrey
6bdd60cda6 Include query string in curl request snippets 2015-02-23 10:01:53 +00:00
Andreas Evers
35d4bc4d4f Update README after rename of spring-restdocs-core to spring-restdocs
Closes gh-22
2015-02-23 09:46:05 +00:00
Andy Wilkinson
577e59de8f Polishing: remove duplicate call to mkdirs() 2015-02-18 13:33:24 +00:00
Andy Wilkinson
e8243457d0 Improve testing of CurlDocumentation 2015-02-18 13:11:07 +00:00
Andy Wilkinson
3311121f33 Polishing - move test classes into the appropriate packages 2015-02-18 10:16:40 +00:00
Andy Wilkinson
d918304491 Polishing 2015-02-16 20:12:31 +00:00
Andy Wilkinson
81c6e88060 Declare IterableEnumeration final as it only has private constructors 2015-02-16 19:53:47 +00:00
Andy Wilkinson
e464127278 Add Sonar and Jacoco-based test coverage to the build 2015-02-16 17:52:37 +00:00
Andy Wilkinson
cbae38d05d Update README with a link to video recording of the presentation 2015-02-16 17:02:54 +00:00
Andy Wilkinson
326abdaf79 Update README to reflect new location of the samples 2015-02-16 16:56:48 +00:00
Andy Wilkinson
b60888cdc3 Add CONTRIBUTING.md 2015-02-16 16:51:29 +00:00
Andy Wilkinson
42270b127c Improve code structure, javadoc, and build configuration
This commit makes extensive changes to the structure of the code. It
introduces a number of separate packages to provide better separation
of the various areas of functionality. Alongside this change the project
has been renamed from spring-restdocs-core to spring-restdocs.

The build has been improved to provide support for building the samples
from the main build using the buildSamples task. While this change has
been made, the samples remain standalone projects so that their
configuration is not dependent on the main project’s build. Running
buildSamples will build the samples using both Maven and Gradle.

All of the main project’s classes now have javadoc and licence/copyright
headers.
2015-02-16 16:46:56 +00:00
Andy Wilkinson
f405848179 Document Gradle and Maven configuration for self-hosted documentation
Update the README to describe how to include the generated documentation
in a project’s jar file so that it can be served as static content by,
for example, Spring Boot.

Closes gh-12
2015-02-16 11:05:29 +00:00
Andy Wilkinson
530a218ab4 Correct the capitalisation of Asciidoctor in the README 2015-02-03 17:16:32 +00:00
Andy Wilkinson
5f49aa2732 Fix formatting of a code block in the README 2015-02-03 17:13:53 +00:00
Andy Wilkinson
cae7e3fb58 Add support for determining the link extractor from the content type
Previously, when documenting links, it was necessary to provide the
link extractor that should be used to get the links from the response.
This commit improves on this by adding support for determining the
link extractor to use based on the response's content type. Two
content types are currently supported; application/hal+json and
application/json. For other content types, an extractor can be
provided as before when calling withLinks.

Closes #7
2015-01-13 16:41:38 +00:00
Andy Wilkinson
b57eb002dc Consistent use of this when accessing fields in the core project 2015-01-13 16:25:13 +00:00
Andy Wilkinson
78736d6c50 Improve the abstraction that's used for link extraction
Previously, the link extraction abstraction was inadequate as it made
assumptions about the format of the links that did not apply to all
media types. For example, it was suited to the links returned in a
application/hal+json response, but was not suited to the Atom-style
links often found in application/json responses.

This commit improves the abstraction so that the extracted links are
decoupled from the format of the response. In addition to the existing
support for extracting HAL links a new extractor for Atom-style links
has been introduced. Both extractors are now available via static
methods on the new LinkExtractors class. The sample applications have
been updated accordingly.

Closes #6
2015-01-13 12:38:50 +00:00
Andy Wilkinson
bbec60bf8e Apply consistent formatting to the core project 2015-01-13 12:13:48 +00:00
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