Commit Graph

39 Commits

Author SHA1 Message Date
Andy Wilkinson
920ced0755 Preserve cookies when preprocessing a request to modify its URIs
Closes gh-523
2018-07-16 10:48:50 +01:00
Pierre-Jean Vardanega
586de30212 Convert query parameters list as param=1&param=2 instead of param=1,2
Closes gh-477
2018-03-27 14:25:33 +01:00
Johnny Lim
da64c55fce Add HTTP method option unconditionally in curl command
Closes gh-488
2018-03-27 14:07:47 +01:00
Andy Wilkinson
95c4234c99 Format core code with Eclipse Oxygen's formatter 2018-03-27 12:53:34 +01:00
Andy Wilkinson
7c6c2e7523 Polish 2017-09-23 17:20:03 +01:00
Andy Wilkinson
214c068ece Remove Accept: */* header from REST Assured requests
Closes gh-404
2017-07-01 16:05:31 +01:00
Andy Wilkinson
704257e93b Align generated Set-Cookie header with RFC 6265
Closes gh-378
2017-04-07 16:59:49 +01:00
Andy Wilkinson
78982cf515 Add support for REST Assured 3
Closes gh-262
2017-03-20 21:39:25 +00:00
Andy Wilkinson
a6d322007b Polish "Provide more control of formatting of curl and HTTPie commands"
See gh-348
Closes gh-260
2017-03-20 20:11:31 +00:00
Tomasz Kopczynski
2cb9d36ef1 Line breaks in cURL and HTTPie snippets
Closes gh-260
2017-03-20 20:11:31 +00:00
Andy Wilkinson
1b5e75ff2c Polish "Include cookies in the HTTP response snippet"
See gh-340
Closes gh-305
2017-03-13 20:46:05 +00:00
Tomasz Kopczynski
46190535f7 Include cookies in the HTTP response snippet
See gh-305
Closes gh-340
2017-03-13 20:44:33 +00:00
Andy Wilkinson
e9ceeacd66 Merge branch '1.1.x' 2017-03-04 21:05:07 +00:00
Andy Wilkinson
7cb91f9963 Remove use of Spring Boot from REST Assured module's integration tests
Closes gh-360
2017-03-04 20:40:42 +00:00
Andy Wilkinson
722048e20f Introduce RequestCookie to avoid core depending on the Servlet API
Closes gh-345
2017-02-03 14:55:18 +00:00
Andy Wilkinson
a9c1e04081 Polish "Include cookies in request snippets"
See gh-336

Closes gh-302
Closes gh-303
Closes gh-304
2017-02-02 14:50:22 +00:00
Tomasz Kopczynski
25bc6c37da Include cookies in request snippets
Closes gh-336
See gh-302, gh-303, gh-304
2017-02-02 14:49:45 +00:00
Andy Wilkinson
1393182182 Upgrade Spring Boot-based samples and integration tests to use 1.4
Closes gh-327
2016-10-28 21:25:30 +01:00
Andy Wilkinson
cbd96f301d Update field snippets to no longer document whole subsection by default
Previously, when a field was documented it would implicitly document
the whole subsection of the payload identified by that field. This
could lead to users inadvertently failing to document part of the
payload. Arguably, this was a bug as it violated REST Docs' principle
of producing accurate, detail documentation. However, fixing it
requires a breaking change as people may also be relying on this
behaviour. A balance needed to be struck so the fix is being made in
a minor release.

This commit introduces a new subsectionWithPath method which returns a
SubsectionDescriptor; a specialisation of FieldDescriptor. Users
that were intentionally relying on the old behaviour will have to
replace some usage of fieldWithPath with subsectionWithPath instead.
Users who were unintentionally relying on the old behaviour will have
to add some additional descriptors produced using fieldWithPath and
will receive more accurate documentation in return.

Closes gh-274
2016-10-28 16:12:07 +01:00
Gerrit Meier
3ac4a1acad Provide a default output directory for snippets based on build tool
Rather than requiring an output directory to be explcitly configured,
a default is now automatically configured based on the build tool
that's being used. When using Gradle, snippets will be generated in
build/generated-snippets. When using Maven, snippets will be
generated in target/generated-snippets.

See gh-297
2016-10-21 22:26:58 +01:00
Andy Wilkinson
f2717363f0 Raise the minimum Spring Framework version to 4.3.x
Closes gh-284
2016-07-26 12:09:20 +01:00
Johnny Lim
19d7337e26 Remove unnecessary Host header set in UriModifyingOperationPreprocessor
Closes gh-280
2016-07-22 10:17:58 +01:00
Andy Wilkinson
417547e61a Support more types of content in RestAssuredRequestConverter
Previously, RestAssuredRequestConverter only supported request and
request part content that was null, a String or a byte[]. This was
particularly problematic for multipart requests as RestAssured performs
some internal conversion which meant that, no matter what the when a
byte[] was provided it was wrapped in a ByteArrayInputStream meaning
that the converter could not read it.

The commit improves RestAssuredRequestConverter so that it will now
convert File content and InputStream content where the stream supported
reset().

Closes gh-252
2016-06-28 11:17:37 +01:00
Andy Wilkinson
a4298b29e7 Include request URI’s port, if any, in default Host header
Previously, OperationRequestFactory would add a Host header if one did
not already exist in the request’s headers, however it did not include
the port. This meant that when the request was being made to a
non-standard port (a port other than 80 for an HTTP request and 443 for
an HTTPS request) the Host header was incorrect.

This commit updates OperationRequestFactory to check the URI for a port
and, if it has one, include it in the Host header.
UriModifyingOperationPreprocessor has also been updated to correctly
include the port in the Host header.

Closes gh-269
2016-06-23 15:45:11 +01:00
Andy Wilkinson
41b7fd63f6 Fix RestAssuredRestDocumentationConfigurerTests.nextFilterIsCalled
The test wasn’t actually verifying that the next filter was being
called. This commit corrects that.
2016-06-16 13:14:43 +01:00
Andy Wilkinson
0446c99a10 Polishing
- Correct copyright years
- Add `@since` to javadoc of new public classes
- Make new classes final where appropriate
2016-05-25 11:26:02 +01:00
Andy Wilkinson
42353a0b5f Improve the API for generating additional snippets
Previously, if alwaysDo was used and the user wanted to generate
one or more additional snippets when calling perform a separate call
to `snippets` was made prior to calling `perform`. This had two
problems:

 - it required the result handler to be stateful (see gh-243)
 - it wasn't clear that the additional snippets would be produced when
   a subsequent call to perform was made

This commit introduces a new API that allows the additional snippets
to be specified within the MockMvc call. The old API has been
deprecated and will be removed in 2.0.

Closes gh-249
2016-05-25 11:01:48 +01:00
Andy Wilkinson
fc3ae3b4a2 Add support for documenting the parts of a multipart request
Closes gh-161
2016-05-12 16:30:36 +01:00
Andy Wilkinson
c4b7438708 Derive a link's description from its title
Previously, a LinkDescriptor had to be created with both a rel and a
description. If a description was not provided a failure would occur.

This commit relaxes the above-described restriction by allowing a
link's title to be used as its default description. If a descriptor
has a description, it will always be used irrespective of whether or
not the link has a title. If the descriptor does not have a
description and the link does have a title, the link's title will be
used. If the descriptor does not have a description and the link does
not have a title a failure will occur.

Closes gh-105
2016-04-13 16:16:15 +01:00
Andy Wilkinson
488d36d4bf Do not double-encode URIs when they are being modified
Previously, when UriModifyingOperationPreprocessor modified a URI it
would always encode it. However, the URIs being modified will always
have been encoded, resulting in double-encoding of the URI.

This commit updates UriModifyingOperationPreprocessor to tell
UriComponentsBuilder that the components have already been encoded.
This ensures that they are not encoded for a second time when the URI
is being built.

Closes gh-211
2016-04-04 10:51:23 +01:00
Andy Wilkinson
4e996e2cdb Merge branch '1.0.x' 2016-02-15 12:25:49 +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
83b72f7962 Introduce constants for common attribute names
Closes gh-193
2016-02-08 12:21:25 +00:00
Andy Wilkinson
cb9e10bf5a Break the package cycle caused by the introduction of SnippetFormat 2016-02-08 11:41:47 +00:00
Andy Wilkinson
c0fac14fdf Break cycle caused by introduction of RestDocumentationHandler 2016-02-06 10:17:27 +00:00
Andy Wilkinson
a9c9bad15e Reduce duplication by introducing RestDocumentationHandler
Previously, logic for creating an Operation, determining the snippets
to call, and calling them was duplicated in both the MockMvc and
REST Assured modules. This commit introduces a new core class,
RestDocumentationHandler, that now does the bulk of the work in a
reusable manner. The MockMvc and REST Assured modules have been
updated to delegate to RestDocumentationHandler.

Closes gh-194
2016-02-04 11:33:40 +00:00
Andy Wilkinson
28476c2d08 Polish RestDocumentationConfigurer and improve its test coverage 2016-02-02 14:09:20 +00:00
Andy Wilkinson
4d37dea1d6 Add support for generating snippets in Markdown
This commit introduces support for generating snippets formatted
using Markdown. Asciidoctor remains the default.

A new SnippetFormat abstraction has been introduced with Asciidoctor
and Markdown implementations provided out of the box.
Markdown-formatted templates are also provided for all of the default
snippets.

Please refer to the updated reference documentation for further
details.

Closes gh-150
Closes gh-19
2016-02-02 12:55:58 +00:00
Andy Wilkinson
130b411e2a Add support for using REST Assured to generate documentation snippets
This commit adds a new module, spring-restdocs-restassured, that
can be used to generate documentation snippets when testing a service
with REST Assured.

Please refer to the updated reference documentation for details.

Thanks to Johan Haleby for making a change to REST Assured so that
path parameters could be documented.

Closes gh-102
2016-01-29 12:31:37 +00:00