Skip to content

Commit e04de95

Browse files
committed
Update API versioning ref docs for client side
Closes: gh-34569
1 parent 5cb3ea2 commit e04de95

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

framework-docs/modules/ROOT/pages/integration/rest-clients.adoc

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ It also exposes a `builder()` with further options:
2323
- select the HTTP library to use, see <<rest-request-factories>>
2424
- configure message converters, see <<rest-message-conversion>>
2525
- set a baseUrl
26-
- set default request headers, cookies, path variables
26+
- set default request headers, cookies, path variables, API version
27+
- configure an `ApiVersionInserter`
2728
- register interceptors
2829
- register request initializers
2930

@@ -46,6 +47,8 @@ Java::
4647
.defaultUriVariables(Map.of("variable", "foo"))
4748
.defaultHeader("My-Header", "Foo")
4849
.defaultCookie("My-Cookie", "Bar")
50+
.defaultVersion("1.2")
51+
.apiVersionInserter(ApiVersionInserter.fromHeader("API-Version").build())
4952
.requestInterceptor(myCustomInterceptor)
5053
.requestInitializer(myCustomInitializer)
5154
.build();
@@ -64,6 +67,8 @@ Kotlin::
6467
.defaultUriVariables(mapOf("variable" to "foo"))
6568
.defaultHeader("My-Header", "Foo")
6669
.defaultCookie("My-Cookie", "Bar")
70+
.defaultVersion("1.2")
71+
.apiVersionInserter(ApiVersionInserter.fromHeader("API-Version").build())
6772
.requestInterceptor(myCustomInterceptor)
6873
.requestInitializer(myCustomInitializer)
6974
.build()
@@ -115,6 +120,7 @@ For more details on working with and encoding URIs, see xref:web/webmvc/mvc-uri-
115120

116121
If necessary, the HTTP request can be manipulated by adding request headers with `header(String, String)`, `headers(Consumer<HttpHeaders>`, or with the convenience methods `accept(MediaType...)`, `acceptCharset(Charset...)` and so on.
117122
For HTTP requests that can contain a body (`POST`, `PUT`, and `PATCH`), additional methods are available: `contentType(MediaType)`, and `contentLength(long)`.
123+
You can set an API version for the request if the client is configured with `ApiVersionInserter`.
118124

119125
The request body itself can be set by `body(Object)`, which internally uses <<rest-message-conversion>>.
120126
Alternatively, the request body can be set using a `ParameterizedTypeReference`, allowing you to use generics.

framework-docs/modules/ROOT/pages/testing/webtestclient.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ Java::
265265
client = WebTestClient.bindToController(new TestController())
266266
.configureClient()
267267
.baseUrl("/test")
268+
.apiVersionInserter(ApiVersionInserter.fromHeader("API-Version").build())
268269
.build();
269270
----
270271
@@ -275,6 +276,7 @@ Kotlin::
275276
client = WebTestClient.bindToController(TestController())
276277
.configureClient()
277278
.baseUrl("/test")
279+
.apiVersionInserter(ApiVersionInserter.fromHeader("API-Version").build())
278280
.build()
279281
----
280282
======

framework-docs/modules/ROOT/pages/web/webflux-versioning.adoc

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ Please, see also related content in:
1313
to map requests to annotated controller methods
1414
- Configure API versioning in xref:web/webflux/config.adoc#webflux-config-api-version[WebFlux Config]
1515

16+
TIP: API versioning is also supported on the client side in `RestClient`, `WebClient`, and
17+
xref:integration/rest-clients.adoc#rest-http-interface[HTTP Service] clients, as well as
18+
for testing with `WebTestClient`.
19+
20+
1621

1722

1823
[[webflux-versioning-strategy]]

framework-docs/modules/ROOT/pages/web/webflux-webclient/client-builder.adoc

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[[webflux-client-builder]]
22
= Configuration
33

4-
The simplest way to create a `WebClient` is through one of the static factory methods:
4+
The simplest way to create `WebClient` is through one of the static factory methods:
55

66
* `WebClient.create()`
77
* `WebClient.create(String baseUrl)`
@@ -12,10 +12,12 @@ You can also use `WebClient.builder()` with further options:
1212
* `defaultUriVariables`: default values to use when expanding URI templates.
1313
* `defaultHeader`: Headers for every request.
1414
* `defaultCookie`: Cookies for every request.
15+
* `defaultApiVersion`: API version for every request.
1516
* `defaultRequest`: `Consumer` to customize every request.
1617
* `filter`: Client filter for every request.
1718
* `exchangeStrategies`: HTTP message reader/writer customizations.
1819
* `clientConnector`: HTTP client library settings.
20+
* `apiVersionInserter`: to insert API version values in the request
1921
* `observationRegistry`: the registry to use for enabling xref:integration/observability.adoc#http-client.webclient[Observability support].
2022
* `observationConvention`: xref:integration/observability.adoc#config[an optional, custom convention to extract metadata] for recorded observations.
2123

framework-docs/modules/ROOT/pages/web/webmvc-versioning.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Please, see also related content in:
1313
to map requests to annotated controller methods
1414
- Configure API versioning in xref:web/webmvc/mvc-config/api-version.adoc[MVC Config]
1515

16+
TIP: API versioning is also supported on the client side in `RestClient`, `WebClient`, and
17+
xref:integration/rest-clients.adoc#rest-http-interface[HTTP Service] clients, as well as
18+
for testing with `WebTestClient`.
19+
1620

1721

1822

0 commit comments

Comments
 (0)