Commit Graph

53 Commits

Author SHA1 Message Date
Andy Wilkinson
d919238023 Update the samples following the release of 1.1.1.RELEASE 2016-07-25 11:06:49 +01:00
Andy Wilkinson
6c6054178e Upgrade tests and samples to use Spring Boot 1.3.6.RELEASE 2016-07-22 14:41:45 +01:00
Jennifer Strater
42613bf3f9 Add README to Grails sample
Closes gh-254
Closes gh-268
2016-06-27 16:25:04 +01:00
Andy Wilkinson
857525954b Update samples following the release of 1.1.0.RELEASE 2016-06-23 15:41:36 +01:00
Andy Wilkinson
686914071a Configure Grails sample to run tests using a random server port
See gh-250
2016-05-31 10:20:19 +01:00
Andy Wilkinson
d5a2dff210 Update the samples to use Spring Boot 1.3.5.RELEASE 2016-05-31 10:07:19 +01:00
Andy Wilkinson
34ec9d523d Polish "Add Grails sample app" (1338df9)
The sole structural change is to rearrange the build slightly so that,
like the other samples, the version of the Grails sample's REST Docs
dependency is automatically updated.

See gh-250
2016-05-31 10:00:52 +01:00
Jennifer Strater
64803b5fae Add Grails sample app
Closes gh-250
2016-05-31 10:00:40 +01:00
Andy Wilkinson
26ff2ec8a5 Update HATEOAS sample to use new API for generating extra snippets
See gh-249
2016-05-25 12:02:53 +01:00
Andy Wilkinson
5e2552f8c4 Merge branch '1.0.x' 2016-05-05 12:48:23 +01:00
Andy Wilkinson
6a5fd53910 Update Asciidoctor dependencies 2016-05-05 12:47:22 +01:00
Andy Wilkinson
9e84922e09 Upgrade samples to Spring Boot 1.3.3.RELEASE
Closes gh-222
2016-05-05 11:29:45 +01:00
Andy Wilkinson
ba76c2f843 Add a sample showing how to use Spring REST Docs with Slate
Closes gh-124
2016-02-15 17:52:08 +00:00
Andy Wilkinson
b224333c97 Upgrade to Gradle 2.11 2016-02-15 17:17:36 +00:00
Andy Wilkinson
c8ecd25591 Add a sample demonstrating how to use REST Assured
Closes gh-198
2016-02-15 17:12:16 +00:00
Andy Wilkinson
0ef9307481 Add support for manually managing the RestDocumentationContext
In 1.0, the reliance on JUnit was more widespread than it should have
been. It should have been isolated to the JUnit TestRule implementation,
RestDocumentation. Unfortunately, RestDocumentation was also an argument
to MockMvcRestDocumentation.documentationConfiguration which made it
impossible to use Spring REST Docs without having JUnit on the
classpath.

This commit introduces JUnitRestDocumentation and
ManualRestDocumentation. The format is a direct replacement for
RestDocumentation which has been reworked to delegate to
JUnitRestDocumentation. The latter allows manual management of the
RestDocumentationContext, primarily for use with TestNG.

A new interface, RestDocumentationContextProvider, has been introduced.
It is implemented by RestDocumentation, JUnitRestDocumentation and
ManualRestDocumentation.
MockMvcRestDocumentation.documentationConfiguration has been overridden
to also accept a RestDocumentationContextProvider. The method that
accepts a RestDocumentation has been deprecated, as has
RestDocumentation itself.

The documentation has been updated to encourage the use of
JUnitRestDocumentation and a sample illustrating the use of Spring REST
Docs with TestNG has been added.

Closes gh-171
2016-02-09 17:31:32 +00:00
Andy Wilkinson
99a2e4f0e0 Update the samples to build against 1.0.2 snapshots 2015-12-10 09:55:36 +00:00
Andy Wilkinson
504ba8c29c Merge branch '1.0.x' 2015-12-09 21:05:33 +00:00
Andy Wilkinson
f6f4b77331 Upgrade the samples to use the latest Asciidoctor plugins 2015-12-09 10:52:19 +00:00
Andy Wilkinson
939769db11 Upgrade the samples to Spring Boot 1.2.7.RELEASE 2015-12-09 10:50:20 +00:00
Andy Wilkinson
9a3e4c5f70 Update the samples to build against 1.0.1 snapshots 2015-10-22 10:04:56 +01:00
Andy Wilkinson
697275f347 Begin development of 1.1.0 2015-10-15 17:51:17 +01:00
Andy Wilkinson
f07f23ec85 Update versions of various dependencies 2015-10-06 16:49:07 +01:00
Andy Wilkinson
c97efcce2e Use the Maven Wrapper in the Spring Data REST-based sample
Closes gh-146
2015-10-06 16:41:34 +01:00
Andy Wilkinson
723b7a284f Use default location for .adoc source in Gradle-based sample
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
2015-10-05 10:22:55 +01:00
andreasevers
48f4d1343a Add support for documenting HTTP headers
This commit adds support for documenting HTTP headers in both requests
and responses.

Closes gh-140
2015-09-29 12:55:26 +01:00
Andy Wilkinson
130a230105 Configure checkstyle and update code to comply
This commit configures Checkstyle and updates the build to comply with
that configuration. The Eclipse JDT metadata has also been updated
so that the output of Eclipse’s code formatting and clean-up is
compliant with Checkstyle.

The use of the latest version (6.10.1) of Checkstyle has required an
upgrade to Gradle 2.7. Gradle hardcode’s the name of the Checkstyle’s
main class which has changed between version 5 (Gradle’s default) and
version 6.

Closes gh-119
2015-09-23 15:50:42 +01:00
Oliver Trosien
387257ba6f Fix typos in sample asciidoc
Closes gh-129
2015-09-18 21:21:12 -04:00
Andy Wilkinson
11c0945d10 Polish the documentation produced by the samples
- Correct the location of the Git repository
- Correct the location of the sample within the repository
- Update the build instructions for the Data REST sample to use Maven
- Move the table of contents to the left
- Add section links

Closes gh-113
2015-09-10 10:00:18 +01:00
Andy Wilkinson
1e53502958 Make milestone builds are available to the samples 2015-09-08 16:07:15 +01:00
Andy Wilkinson
fece9547ea Automatically align version of samples' dependency with main version
This commit enhances the tasks that build the samples to
automatically update the version of their spring-restdocs dependency
to match the version of the main project.
2015-09-08 11:25:06 +01:00
Andy Wilkinson
7b1d9e714c Allow preprocessing to be applied to every test
Following the reworking of the API, it was no longer possible to
apply preprocessing to every test and to still customize the snippets
used by that test.

This commit adds a new snippets() method to
RestDocumentationResultHandler that allows additional snippets to be
configured once the result handler has been created. The documentation
has been updated to describe how to apply preprocessing to every
test and Spring HATEOAS sample has been updated to illustrate the
approach.

Closes gh-88
2015-09-07 11:44:12 +01:00
Andy Wilkinson
2b2b6fcd25 Isolate and reduce Spring Test dependencies
This commit splits Spring REST Docs into two projects –
spring-restdocs-core and spring-restdocs-mockmvc.

spring-restdocs-core contains the vast majority of the code but does not
depend on a specific test framework other than JUnit. The use of a
Spring Test TestExecutionListener has been replaced with a JUnit test
rule. The rule is declared once per test class and configured with
the output directory to which the generated snippets should be written.
This simplifies the implementation as thread local storage is no longer
required to transfer information about the test that’s running into
Spring REST Docs. Instead, this transfer is now handled by the new test
rule. It has also simplified the configuration as it’s no longer
necessary for users to provide a system property that configures the
output directory.

spring-restdocs-mockmvc contains code that’s specific to using Spring
REST Docs with Spring MVC Test’s MockMvc. This is currently the only
testing framework that’s supported, but it paves the way for adding
support for additional frameworks. REST Assured is one that users seem
particularly interested in (see gh-80 and gh-102).

Closes gh-107
2015-09-03 14:19:32 +01:00
Andy Wilkinson
ff822bd88d Provide an API to ease documenting a request field’s constraints
Previously, users that wanted to document a request field’s constraints
had to roll their own solution. This commit introduces a new API that
makes it easier to document constraints. Support is provided for
discovering Bean Validation constraints and resolving descriptions for
them. The constraint descriptions can then be used as required. For
example, they can included in a field’s description or in an additional
constraints attribute that’s included in an additional table column via
the use of a custom snippet template.

Closes gh-42
2015-08-25 15:00:40 +01:00
Andy Wilkinson
bc5a9c3714 Update the samples to use Spring Boot 1.2.5 2015-08-19 18:01:25 +01:00
Andy Wilkinson
32bb724a3d Update the samples to align with recent API changes 2015-08-19 17:25:56 +01:00
Andy Wilkinson
0c8a71370b Rework the API to improve readability and extensibility
This commit updates the API to improve its extensibility and
readability.

SnippetWritingResultHandler has been replaced with a  more general
purpose Snippet interface. Snippets are now provided to the main
document method using varargs rather than the various with… methods
that were previously used. As a result a custom Snippet implementation
can now be used in exactly the same way as any of the built-in
snippets:

this.mockMvc.perform(get("/"))
        .andExpect(status().isOk())
        .andDo(document("index-example",
                links(
                        linkWithRel("notes").description("…"),
                        linkWithRel("tags").description("…")),
                responseFields(
                        fieldWithPath("_links").description("…")),
                yourCustomSnippet()));

Control of the snippets that are generated by default is now available
via RestDocumentationConfigurer:

this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
        .apply(documentationConfiguration().snippets()
               .withDefaults(curlRequest(), yourCustomSnippet()))
        .build();

See gh-73
2015-08-10 12:06:32 +01:00
Andy Wilkinson
8e2fc7f45d Provide support for documenting path parameters
This commit adds support for documenting a request's path parameters.
For example:

mockMvc.perform(
		get("/locations/{latitude}/{longitude}", 51.5072, 0.1275))
			.andExpect(status().isOk())
			.andDo(document("locations").withPathParameters(
					parameterWithName("latitude")
							.description("The location's latitude"),
					parameterWithName("longitude")
							.description("The location's longitude")
			));

Closes gh-86
2015-07-29 14:50:49 +01:00
Andy Wilkinson
cdcddcf91b Update the samples to use Spring Boot 1.2.4.RELEASE 2015-06-24 14:36:47 +01:00
Andy Wilkinson
b6c64dfd26 Update the samples to build against correct version of main project
This should have been done as part of 0e5151e91.
2015-06-23 14:05:07 +01:00
Andy Wilkinson
8307fb5428 Add reference documentation and create docs zip
Add reference documentation for the project and add a docs artifact
that contains both the reference documentation and the javadoc.

See gh-37
2015-06-16 17:14:31 +01:00
Andy Wilkinson
0c0d3b89bd Default snippet encoding to UTF-8 and make it configurable
Previously, snippets were written to disk using the JVM’s default
encoding. While this could be controlled by the file.encoding system
property it was not ideal as, if the proper was not always set, it could
lead to platform-dependent output being generated. Furthermore,
Asciidoctor uses UTF-8 encoding by default so there was a risk of the
snippets being generated in a different encoding to the encoding
expected by Asciidoctor.

This commit updates the configuration so that, by default, snippets are
encoded as UTF-8. The RestDocumentationConfigurer API has been enhanced
to allow this default to be configured as part of building the
MockMvc instance. This enhancement as brought with it a more fluent
configuration API that separates configuration that is related to URIs
from configuration that is related to snippets.

Closes gh-67
2015-05-13 11:18:56 +01:00
Andy Wilkinson
90bbb5ab9e Update samples to make them compatible with Java 7
The main project supports Java 7 or later, but, prior to this commit,
the Spring HATEOAS sample required Java 8. This commit updates updates
the Spring HATEOAS sample to make it compatible with Java 7 and
updates the build configuration of both samples to specify Java 7.

Closes gh-51
2015-05-05 12:09:45 +01:00
Andy Wilkinson
8166c5e3e7 Add a task that verifies the includes in a sample’s .adoc files
Enhance buildSamples such that, once a sample has been built, it looks
at the generated HTML files and checks that they do not contain any
output that's indicative of a malformed include in a source .adoc
file.

This additional verification found another malformed include which
this commit corrects.
2015-04-21 12:32:31 +01:00
Esko Luontola
0e597e9498 Fix broken include in Spring HATEOAS sample's API guide
Closes gh-59
2015-04-21 11:17:31 +01:00
Preben Asmussen
18c7799b8f Fix the artifact id in pom.xml of rest-notes-spring-data-rest
Closes gh-53
2015-04-20 09:50:36 +01:00
Andy Wilkinson
bcda6fe459 Update the main project and Gradle samples to use Gradle 2.3 2015-04-16 12:34:28 +01:00
Andy Wilkinson
f93981fce2 Align with the Asciidoctor team's preferred file extension, .adoc
Closes gh-45
2015-04-16 12:31:29 +01:00
Andy Wilkinson
e00734d693 Add support for generating an HTTP request documentation snippet
Closes gh-13
2015-04-16 12:03:21 +01:00
Andy Wilkinson
2b44452de1 Improve support for documenting fields in req and resp payloads
This commit improves the support for documenting the fields found
in request and response payloads. The improvements include:

 - Using the term "payload" rather than "state" as the latter is
   somewhat HAL-specific
 - Code simplification, including the removal of the Path abstraction
 - Automatically determining the type of a field based on the payload
   that's being tested
 - Updating the samples to use the new API

In addition to these improvements, support for documenting field
constraints has been removed as more thought is required. The
FieldDescriptor abstraction is used to describe both request and
response fields, however it's not clear that contraints apply to both
and they certainly don't apply in the same way. For the time being at
least, users who want to document a field's constraints can do so as
part of its description.

Closes gh-24
2015-03-24 16:31:52 +00:00