Skip to content

Commit 1675795

Browse files
committed
Merge pull request #575 from Jay Bryant
* gh-575: Improve style and consistency of the documentation
2 parents bc02ee0 + 6a2d30a commit 1675795

9 files changed

+722
-571
lines changed
+59-42
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
[[configuration]]
22
== Configuration
33

4-
4+
This section covers how to configure Spring REST Docs.
55

66
[[configuration-uris]]
77
=== Documented URIs
88

9-
9+
This section covers configuring documented URIs.
1010

1111
[[configuration-uris-mockmvc]]
12-
==== MockMvc URI customization
12+
==== MockMvc URI Customization
1313

14-
When using MockMvc, the default configuration for URIs documented by Spring REST Docs is:
14+
When using MockMvc, the default configuration for URIs documented by Spring REST Docs is
15+
as follows:
1516

1617
|===
1718
|Setting |Default
@@ -26,54 +27,63 @@ When using MockMvc, the default configuration for URIs documented by Spring REST
2627
|`8080`
2728
|===
2829

29-
This configuration is applied by `MockMvcRestDocumentationConfigurer`. You can use its API
30-
to change one or more of the defaults to suit your needs:
30+
This configuration is applied by `MockMvcRestDocumentationConfigurer`. You can use its
31+
API to change one or more of the defaults to suit your needs. The following example shows
32+
how to do so:
3133

34+
====
3235
[source,java,indent=0]
3336
----
3437
include::{examples-dir}/com/example/mockmvc/CustomUriConfiguration.java[tags=custom-uri-configuration]
3538
----
39+
====
3640

3741
NOTE: If the port is set to the default for the configured scheme (port 80 for HTTP or
38-
port 443 for HTTPS), it will be omitted from any URIs in the generated snippets.
42+
port 443 for HTTPS), it is omitted from any URIs in the generated snippets.
3943

4044
TIP: To configure a request's context path, use the `contextPath` method on
4145
`MockHttpServletRequestBuilder`.
4246

4347

4448

4549
[[configuration-uris-rest-assured]]
46-
==== REST Assured URI customization
50+
==== REST Assured URI Customization
4751

4852
REST Assured tests a service by making actual HTTP requests. As a result, URIs must be
4953
customized once the operation on the service has been performed but before it is
50-
documented. A <<customizing-requests-and-responses-preprocessors-modify-uris, REST-Assured
51-
specific preprocessor>> is provided for this purpose.
54+
documented. A
55+
<<customizing-requests-and-responses-preprocessors-modify-uris, REST-Assured-specific
56+
preprocessor>> is provided for this purpose.
5257

5358

5459

5560
[[configuration-uris-webtestclient]]
56-
==== WebTestClient URI customization
61+
==== WebTestClient URI Customization
5762

5863
When using WebTestClient, the default base for URIs documented by Spring REST
59-
Docs is `http://localhost:8080`. This base can be customized using the
64+
Docs is `http://localhost:8080`. You can customize this base by using the
6065
{spring-framework-api}/org/springframework/test/web/reactive/server/WebTestClient.Builder.html#baseUrl-java.lang.String-[
61-
`baseUrl(String)` method on `WebTestClient.Builder`]:
66+
`baseUrl(String)` method on `WebTestClient.Builder`]. The following example shows how to
67+
do so:
6268

69+
====
6370
[source,java,indent=0]
6471
----
6572
include::{examples-dir}/com/example/webtestclient/CustomUriConfiguration.java[tags=custom-uri-configuration]
6673
----
6774
<1> Configure the base of documented URIs to be `https://api.example.com`.
75+
====
6876

6977

7078

7179
[[configuration-snippet-encoding]]
72-
=== Snippet encoding
80+
=== Snippet Encoding
7381

74-
The default snippet encoding is `UTF-8`. You can change the default snippet encoding
75-
using the `RestDocumentationConfigurer` API. For example, to use `ISO-8859-1`:
82+
The default snippet encoding is `UTF-8`. You can change the default snippet encoding by
83+
using the `RestDocumentationConfigurer` API. For example, the following examples use
84+
`ISO-8859-1`:
7685

86+
====
7787
[source,java,indent=0,role="primary"]
7888
.MockMvc
7989
----
@@ -91,20 +101,23 @@ include::{examples-dir}/com/example/webtestclient/CustomEncoding.java[tags=custo
91101
----
92102
include::{examples-dir}/com/example/restassured/CustomEncoding.java[tags=custom-encoding]
93103
----
104+
====
94105

95-
TIP: When Spring REST Docs converts a request or response's content to a String, the
96-
`charset` specified in the `Content-Type` header will be used if it is available. In its
97-
absence, the JVM's default `Charset` will be used. The JVM's default `Charset` can be
98-
configured using the `file.encoding` system property.
106+
TIP: When Spring REST Docs converts the content of a request or a response to a `String`,
107+
the `charset` specified in the `Content-Type` header is used if it is available. In its
108+
absence, the JVM's default `Charset` is used. You can configure the JVM's default
109+
`Charset` byusing the `file.encoding` system property.
99110

100111

101112

102113
[[configuration-snippet-template-format]]
103-
=== Snippet template format
114+
=== Snippet Template Format
104115

105116
The default snippet template format is Asciidoctor. Markdown is also supported out of the
106-
box. You can change the default format using the `RestDocumentationConfigurer` API:
117+
box. You can change the default format by using the `RestDocumentationConfigurer` API.
118+
The following examples show how to do so:
107119

120+
====
108121
[source,java,indent=0,role="primary"]
109122
.MockMvc
110123
----
@@ -122,25 +135,27 @@ include::{examples-dir}/com/example/webtestclient/CustomFormat.java[tags=custom-
122135
----
123136
include::{examples-dir}/com/example/restassured/CustomFormat.java[tags=custom-format]
124137
----
138+
====
125139

126140

127141

128142
[[configuration-default-snippets]]
129-
=== Default snippets
143+
=== Default Snippets
130144

131145
Six snippets are produced by default:
132146

133-
- `curl-request`
134-
- `http-request`
135-
- `http-response`
136-
- `httpie-request`
137-
- `request-body`
138-
- `response-body`
147+
* `curl-request`
148+
* `http-request`
149+
* `http-response`
150+
* `httpie-request`
151+
* `request-body`
152+
* `response-body`
139153

140-
You can change the default snippet configuration during setup using the
141-
`RestDocumentationConfigurer` API. For example, to only produce the `curl-request`
154+
You can change the default snippet configuration during setup by using the
155+
`RestDocumentationConfigurer` API. The following examples produce only the `curl-request`
142156
snippet by default:
143157

158+
====
144159
[source,java,indent=0,role="primary"]
145160
.MockMvc
146161
----
@@ -158,35 +173,37 @@ include::{examples-dir}/com/example/webtestclient/CustomDefaultSnippets.java[tag
158173
----
159174
include::{examples-dir}/com/example/restassured/CustomDefaultSnippets.java[tags=custom-default-snippets]
160175
----
176+
====
161177

162178
[[configuration-default-preprocessors]]
163-
=== Default operation preprocessors
179+
=== Default Operation Preprocessors
164180

165-
You can configure default request and response preprocessors during setup using the
166-
`RestDocumentationConfigurer` API. For example, to remove the `Foo` headers from all requests
167-
and pretty print all responses:
181+
You can configure default request and response preprocessors during setup by using the
182+
`RestDocumentationConfigurer` API. The following examples remove the `Foo` headers from
183+
all requests and pretty print all responses:
168184

185+
====
169186
[source,java,indent=0,role="primary"]
170187
.MockMvc
171188
----
172189
include::{examples-dir}/com/example/mockmvc/CustomDefaultOperationPreprocessors.java[tags=custom-default-operation-preprocessors]
173190
----
174-
<1> Apply a request preprocessor that will remove the header named `Foo`.
175-
<2> Apply a response preprocessor that will pretty print its content.
191+
<1> Apply a request preprocessor that removes the header named `Foo`.
192+
<2> Apply a response preprocessor that pretty prints its content.
176193
177194
[source,java,indent=0,role="secondary"]
178195
.WebTestClient
179196
----
180197
include::{examples-dir}/com/example/webtestclient/CustomDefaultOperationPreprocessors.java[tags=custom-default-operation-preprocessors]
181198
----
182-
<1> Apply a request preprocessor that will remove the header named `Foo`.
183-
<2> Apply a response preprocessor that will pretty print its content.
199+
<1> Apply a request preprocessor that removes the header named `Foo`.
200+
<2> Apply a response preprocessor that pretty prints its content.
184201
185202
[source,java,indent=0,role="secondary"]
186203
.REST Assured
187204
----
188205
include::{examples-dir}/com/example/restassured/CustomDefaultOperationPreprocessors.java[tags=custom-default-operation-preprocessors]
189206
----
190-
<1> Apply a request preprocessor that will remove the header named `Foo`.
191-
<2> Apply a response preprocessor that will pretty print its content.
192-
207+
<1> Apply a request preprocessor that removes the header named `Foo`.
208+
<2> Apply a response preprocessor that pretty prints its content.
209+
====

docs/src/docs/asciidoc/contributing.adoc

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
[[contributing]]
22
== Contributing
33

4-
Spring REST Docs is intended to make it easy for you to produce high-quality documentation
5-
for your RESTful services. However, we can't achieve that goal without your contributions.
4+
Spring REST Docs is intended to make it easy for you to produce high-quality
5+
documentation for your RESTful services. However, we cannot achieve that goal without
6+
your contributions.
67

78

89

910
[[contributing-questions]]
1011
=== Questions
1112

12-
You can ask questions about Spring REST Docs on http://stackoverflow.com[StackOverflow]
13-
using the `spring-restdocs` tag. Similarly, we encourage you to help your fellow
13+
You can ask questions about Spring REST Docs on http://stackoverflow.com[Stack Overflow]
14+
by using the `spring-restdocs` tag. Similarly, we encourage you to help your fellow
1415
Spring REST Docs users by answering questions.
1516

1617

@@ -28,9 +29,9 @@ ideally, includes a test that reproduces it.
2829
[[contributing-enhancements]]
2930
=== Enhancements
3031

31-
If you'd like an enhancement to be made to Spring REST Docs, pull requests are most
32+
If you would like an enhancement to be made to Spring REST Docs, pull requests are most
3233
welcome. The source code is on {github}[GitHub]. You may want to search the
3334
{github}/issues?q=is%3Aissue[existing issues] and {github}/pulls?q=is%3Apr[pull requests]
34-
to see if the enhancement is already being worked on. You may also want to
35+
to see if the enhancement has already been proprosed. You may also want to
3536
{github}/issues/new[open a new issue] to discuss a possible enhancement before work on it
3637
begins.

0 commit comments

Comments
 (0)