Browse Source

Consistently indent code with tabs in reference manual

pull/35405/head
Sam Brannen 8 months ago
parent
commit
f27382cfb6
  1. 91
      framework-docs/modules/ROOT/pages/integration/rest-clients.adoc
  2. 2
      framework-docs/modules/ROOT/pages/languages/kotlin/coroutines.adoc
  3. 22
      framework-docs/modules/ROOT/pages/languages/kotlin/spring-projects-in.adoc
  4. 33
      framework-docs/modules/ROOT/pages/languages/kotlin/web.adoc
  5. 8
      framework-docs/modules/ROOT/pages/web/webflux-webclient/client-body.adoc
  6. 8
      framework-docs/modules/ROOT/pages/web/webflux-webclient/client-filter.adoc
  7. 2
      framework-docs/modules/ROOT/pages/web/websocket/stomp/enable.adoc

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

@ -30,9 +30,9 @@ Java:: @@ -30,9 +30,9 @@ Java::
+
[source,java,indent=0,subs="verbatim"]
----
RestClient defaultClient = RestClient.create();
RestClient defaultClient = RestClient.create();
RestClient customClient = RestClient.builder()
RestClient customClient = RestClient.builder()
.requestFactory(new HttpComponentsClientHttpRequestFactory())
.messageConverters(converters -> converters.add(new MyCustomMessageConverter()))
.baseUrl("https://example.com")
@ -48,9 +48,9 @@ Kotlin:: @@ -48,9 +48,9 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim"]
----
val defaultClient = RestClient.create()
val defaultClient = RestClient.create()
val customClient = RestClient.builder()
val customClient = RestClient.builder()
.requestFactory(HttpComponentsClientHttpRequestFactory())
.messageConverters { converters -> converters.add(MyCustomMessageConverter()) }
.baseUrl("https://example.com")
@ -81,20 +81,20 @@ Java:: @@ -81,20 +81,20 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
int id = 42;
restClient.get()
int id = 42;
restClient.get()
.uri("https://example.com/orders/{id}", id)
....
// ...
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
val id = 42
restClient.get()
val id = 42
restClient.get()
.uri("https://example.com/orders/{id}", id)
...
// ...
----
======
@ -133,12 +133,12 @@ Java:: @@ -133,12 +133,12 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
String result = restClient.get() <1>
String result = restClient.get() <1>
.uri("https://example.com") <2>
.retrieve() <3>
.body(String.class); <4>
System.out.println(result); <5>
System.out.println(result); <5>
----
<1> Set up a GET request
<2> Specify the URL to connect to
@ -150,12 +150,12 @@ Kotlin:: @@ -150,12 +150,12 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
val result= restClient.get() <1>
val result= restClient.get() <1>
.uri("https://example.com") <2>
.retrieve() <3>
.body<String>() <4>
println(result) <5>
println(result) <5>
----
<1> Set up a GET request
<2> Specify the URL to connect to
@ -172,14 +172,14 @@ Java:: @@ -172,14 +172,14 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
ResponseEntity<String> result = restClient.get() <1>
ResponseEntity<String> result = restClient.get() <1>
.uri("https://example.com") <1>
.retrieve()
.toEntity(String.class); <2>
System.out.println("Response status: " + result.getStatusCode()); <3>
System.out.println("Response headers: " + result.getHeaders()); <3>
System.out.println("Contents: " + result.getBody()); <3>
System.out.println("Response status: " + result.getStatusCode()); <3>
System.out.println("Response headers: " + result.getHeaders()); <3>
System.out.println("Contents: " + result.getBody()); <3>
----
<1> Set up a GET request for the specified URL
<2> Convert the response into a `ResponseEntity`
@ -189,14 +189,14 @@ Kotlin:: @@ -189,14 +189,14 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
val result = restClient.get() <1>
val result = restClient.get() <1>
.uri("https://example.com") <1>
.retrieve()
.toEntity<String>() <2>
println("Response status: " + result.statusCode) <3>
println("Response headers: " + result.headers) <3>
println("Contents: " + result.body) <3>
println("Response status: " + result.statusCode) <3>
println("Response headers: " + result.headers) <3>
println("Contents: " + result.body) <3>
----
<1> Set up a GET request for the specified URL
<2> Convert the response into a `ResponseEntity`
@ -212,8 +212,8 @@ Java:: @@ -212,8 +212,8 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
int id = ...;
Pet pet = restClient.get()
int id = ...;
Pet pet = restClient.get()
.uri("https://petclinic.example.com/pets/{id}", id) <1>
.accept(APPLICATION_JSON) <2>
.retrieve()
@ -227,8 +227,8 @@ Kotlin:: @@ -227,8 +227,8 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
val id = ...
val pet = restClient.get()
val id = ...
val pet = restClient.get()
.uri("https://petclinic.example.com/pets/{id}", id) <1>
.accept(APPLICATION_JSON) <2>
.retrieve()
@ -247,8 +247,8 @@ Java:: @@ -247,8 +247,8 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
Pet pet = ... <1>
ResponseEntity<Void> response = restClient.post() <2>
Pet pet = ... <1>
ResponseEntity<Void> response = restClient.post() <2>
.uri("https://petclinic.example.com/pets/new") <2>
.contentType(APPLICATION_JSON) <3>
.body(pet) <4>
@ -265,8 +265,8 @@ Kotlin:: @@ -265,8 +265,8 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
val pet: Pet = ... <1>
val response = restClient.post() <2>
val pet: Pet = ... <1>
val response = restClient.post() <2>
.uri("https://petclinic.example.com/pets/new") <2>
.contentType(APPLICATION_JSON) <3>
.body(pet) <4>
@ -291,7 +291,7 @@ Java:: @@ -291,7 +291,7 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
String result = restClient.get() <1>
String result = restClient.get() <1>
.uri("https://example.com/this-url-does-not-exist") <1>
.retrieve()
.onStatus(HttpStatusCode::is4xxClientError, (request, response) -> { <2>
@ -307,7 +307,7 @@ Kotlin:: @@ -307,7 +307,7 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
val result = restClient.get() <1>
val result = restClient.get() <1>
.uri("https://example.com/this-url-does-not-exist") <1>
.retrieve()
.onStatus(HttpStatusCode::is4xxClientError) { _, response -> <2>
@ -330,7 +330,7 @@ Java:: @@ -330,7 +330,7 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
Pet result = restClient.get()
Pet result = restClient.get()
.uri("https://petclinic.example.com/pets/{id}", id)
.accept(APPLICATION_JSON)
.exchange((request, response) -> { <1>
@ -351,7 +351,7 @@ Kotlin:: @@ -351,7 +351,7 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
val result = restClient.get()
val result = restClient.get()
.uri("https://petclinic.example.com/pets/{id}", id)
.accept(MediaType.APPLICATION_JSON)
.exchange { request, response -> <1>
@ -380,15 +380,14 @@ To serialize only a subset of the object properties, you can specify a {baeldung @@ -380,15 +380,14 @@ To serialize only a subset of the object properties, you can specify a {baeldung
[source,java,indent=0,subs="verbatim"]
----
MappingJacksonValue value = new MappingJacksonValue(new User("eric", "7!jd#h23"));
value.setSerializationView(User.WithoutPasswordView.class);
MappingJacksonValue value = new MappingJacksonValue(new User("eric", "7!jd#h23"));
value.setSerializationView(User.WithoutPasswordView.class);
ResponseEntity<Void> response = restClient.post() // or RestTemplate.postForEntity
ResponseEntity<Void> response = restClient.post() // or RestTemplate.postForEntity
.contentType(APPLICATION_JSON)
.body(value)
.retrieve()
.toBodilessEntity();
----
==== Multipart
@ -398,17 +397,17 @@ For example: @@ -398,17 +397,17 @@ For example:
[source,java,indent=0,subs="verbatim"]
----
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
parts.add("fieldPart", "fieldValue");
parts.add("filePart", new FileSystemResource("...logo.png"));
parts.add("jsonPart", new Person("Jason"));
parts.add("fieldPart", "fieldValue");
parts.add("filePart", new FileSystemResource("...logo.png"));
parts.add("jsonPart", new Person("Jason"));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_XML);
parts.add("xmlPart", new HttpEntity<>(myBean, headers));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_XML);
parts.add("xmlPart", new HttpEntity<>(myBean, headers));
// send using RestClient.post or RestTemplate.postForEntity
// send using RestClient.post or RestTemplate.postForEntity
----
In most cases, you do not have to specify the `Content-Type` for each part.

2
framework-docs/modules/ROOT/pages/languages/kotlin/coroutines.adoc

@ -255,5 +255,3 @@ For Kotlin `Flow`, a `Flow<T>.transactional` extension is provided. @@ -255,5 +255,3 @@ For Kotlin `Flow`, a `Flow<T>.transactional` extension is provided.
----

22
framework-docs/modules/ROOT/pages/languages/kotlin/spring-projects-in.adoc

@ -296,17 +296,17 @@ for example when writing a `org.springframework.core.convert.converter.Converter @@ -296,17 +296,17 @@ for example when writing a `org.springframework.core.convert.converter.Converter
[source,kotlin,indent=0]
----
class ListOfFooConverter : Converter<List<Foo>, CustomJavaList<out Foo>> {
class ListOfFooConverter : Converter<List<Foo>, CustomJavaList<out Foo>> {
// ...
}
}
----
When converting any kind of objects, star projection with `*` can be used instead of `out Any`.
[source,kotlin,indent=0]
----
class ListOfAnyConverter : Converter<List<*>, CustomJavaList<*>> {
class ListOfAnyConverter : Converter<List<*>, CustomJavaList<*>> {
// ...
}
}
----
NOTE: Spring Framework does not leverage yet declaration-site variance type information for injecting beans,
@ -340,13 +340,14 @@ file with a `spring.test.constructor.autowire.mode = all` property. @@ -340,13 +340,14 @@ file with a `spring.test.constructor.autowire.mode = all` property.
[source,kotlin,indent=0]
----
@SpringJUnitConfig(TestConfig::class)
@TestConstructor(autowireMode = AutowireMode.ALL)
class OrderServiceIntegrationTests(val orderService: OrderService,
@SpringJUnitConfig(TestConfig::class)
@TestConstructor(autowireMode = AutowireMode.ALL)
class OrderServiceIntegrationTests(
val orderService: OrderService,
val customerService: CustomerService) {
// tests that use the injected OrderService and CustomerService
}
}
----
@ -403,11 +404,12 @@ The following example shows how to do so: @@ -403,11 +404,12 @@ The following example shows how to do so:
[source,kotlin,indent=0]
----
class SpecificationLikeTests {
class SpecificationLikeTests {
@Nested
@DisplayName("a calculator")
inner class Calculator {
val calculator = SampleCalculator()
@Test
@ -422,7 +424,7 @@ class SpecificationLikeTests { @@ -422,7 +424,7 @@ class SpecificationLikeTests {
assertEquals(2, subtract)
}
}
}
}
----

33
framework-docs/modules/ROOT/pages/languages/kotlin/web.adoc

@ -1,8 +1,6 @@ @@ -1,8 +1,6 @@
[[kotlin-web]]
= Web
[[router-dsl]]
== Router DSL
@ -16,8 +14,8 @@ These DSL let you write clean and idiomatic Kotlin code to build a `RouterFuncti @@ -16,8 +14,8 @@ These DSL let you write clean and idiomatic Kotlin code to build a `RouterFuncti
[source,kotlin,indent=0]
----
@Configuration
class RouterRouterConfiguration {
@Configuration
class RouterRouterConfiguration {
@Bean
fun mainRouter(userHandler: UserHandler) = router {
@ -36,7 +34,7 @@ class RouterRouterConfiguration { @@ -36,7 +34,7 @@ class RouterRouterConfiguration {
}
resources("/**", ClassPathResource("static/"))
}
}
}
----
NOTE: This DSL is programmatic, meaning that it allows custom registration logic of beans
@ -55,22 +53,22 @@ idiomatic Kotlin API and to allow better discoverability (no usage of static met @@ -55,22 +53,22 @@ idiomatic Kotlin API and to allow better discoverability (no usage of static met
[source,kotlin,indent=0]
----
val mockMvc: MockMvc = ...
mockMvc.get("/person/{name}", "Lee") {
val mockMvc: MockMvc = ...
mockMvc.get("/person/{name}", "Lee") {
secure = true
accept = APPLICATION_JSON
headers {
contentLanguage = Locale.FRANCE
}
principal = Principal { "foo" }
}.andExpect {
}.andExpect {
status { isOk }
content { contentType(APPLICATION_JSON) }
jsonPath("$.name") { value("Lee") }
content { json("""{"someBoolean": false}""", false) }
}.andDo {
}.andDo {
print()
}
}
----
@ -89,9 +87,9 @@ is possible to use such feature to render Kotlin-based templates with @@ -89,9 +87,9 @@ is possible to use such feature to render Kotlin-based templates with
`build.gradle.kts`
[source,kotlin,indent=0]
----
dependencies {
dependencies {
runtime("org.jetbrains.kotlin:kotlin-scripting-jsr223:${kotlinVersion}")
}
}
----
Configuration is usually done with `ScriptTemplateConfigurer` and `ScriptTemplateViewResolver` beans.
@ -99,8 +97,8 @@ Configuration is usually done with `ScriptTemplateConfigurer` and `ScriptTemplat @@ -99,8 +97,8 @@ Configuration is usually done with `ScriptTemplateConfigurer` and `ScriptTemplat
`KotlinScriptConfiguration.kt`
[source,kotlin,indent=0]
----
@Configuration
class KotlinScriptConfiguration {
@Configuration
class KotlinScriptConfiguration {
@Bean
fun kotlinScriptConfigurer() = ScriptTemplateConfigurer().apply {
@ -115,7 +113,7 @@ class KotlinScriptConfiguration { @@ -115,7 +113,7 @@ class KotlinScriptConfiguration {
setPrefix("templates/")
setSuffix(".kts")
}
}
}
----
See the https://github.com/sdeleuze/kotlin-script-templating[kotlin-script-templating] example
@ -127,7 +125,7 @@ project for more details. @@ -127,7 +125,7 @@ project for more details.
== Kotlin multiplatform serialization
{kotlin-github-org}/kotlinx.serialization[Kotlin multiplatform serialization] is
supported in Spring MVC, Spring WebFlux and Spring Messaging (RSocket). The builtin support currently targets CBOR, JSON, and ProtoBuf formats.
supported in Spring MVC, Spring WebFlux and Spring Messaging (RSocket). The built-in support currently targets CBOR, JSON, and ProtoBuf formats.
To enable it, follow {kotlin-github-org}/kotlinx.serialization#setup[those instructions] to add the related dependency and plugin.
With Spring MVC and WebFlux, both Kotlin serialization and Jackson will be configured by default if they are in the classpath since
@ -135,6 +133,3 @@ Kotlin serialization is designed to serialize only Kotlin classes annotated with @@ -135,6 +133,3 @@ Kotlin serialization is designed to serialize only Kotlin classes annotated with
With Spring Messaging (RSocket), make sure that neither Jackson, GSON or JSONB are in the classpath if you want automatic configuration,
if Jackson is needed configure `KotlinSerializationJsonMessageConverter` manually.

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

@ -306,8 +306,8 @@ Java:: @@ -306,8 +306,8 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
Resource resource = ...
Mono<String> result = webClient
Resource resource = ...
Mono<String> result = webClient
.post()
.uri("https://example.com")
.body(Flux.concat(
@ -322,8 +322,8 @@ Kotlin:: @@ -322,8 +322,8 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
var resource: Resource = ...
var result: Mono<String> = webClient
var resource: Resource = ...
var result: Mono<String> = webClient
.post()
.uri("https://example.com")
.body(

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

@ -158,7 +158,7 @@ Java:: @@ -158,7 +158,7 @@ Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
public class MultipartExchangeFilterFunction implements ExchangeFilterFunction {
public class MultipartExchangeFilterFunction implements ExchangeFilterFunction {
@Override
public Mono<ClientResponse> filter(ClientRequest request, ExchangeFunction next) {
@ -186,14 +186,14 @@ public class MultipartExchangeFilterFunction implements ExchangeFilterFunction { @@ -186,14 +186,14 @@ public class MultipartExchangeFilterFunction implements ExchangeFilterFunction {
});
}
}
}
}
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
class MultipartExchangeFilterFunction : ExchangeFilterFunction {
class MultipartExchangeFilterFunction : ExchangeFilterFunction {
override fun filter(request: ClientRequest, next: ExchangeFunction): Mono<ClientResponse> {
return if (MediaType.MULTIPART_FORM_DATA.includes(request.headers().getContentType())
@ -217,6 +217,6 @@ class MultipartExchangeFilterFunction : ExchangeFilterFunction { @@ -217,6 +217,6 @@ class MultipartExchangeFilterFunction : ExchangeFilterFunction {
}
}
}
}
}
----
======

2
framework-docs/modules/ROOT/pages/web/websocket/stomp/enable.adoc

@ -47,5 +47,3 @@ interactive web application] -- a getting started guide. @@ -47,5 +47,3 @@ interactive web application] -- a getting started guide.
* https://github.com/rstoyanchev/spring-websocket-portfolio[Stock Portfolio] -- a sample
application.

Loading…
Cancel
Save