|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2024 the original author or authors. |
| 2 | + * Copyright 2012-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
47 | 47 | import org.springframework.test.web.reactive.server.WebTestClient;
|
48 | 48 | import org.springframework.web.bind.annotation.PostMapping;
|
49 | 49 | import org.springframework.web.bind.annotation.RestController;
|
| 50 | +import org.springframework.web.servlet.function.RouterFunction; |
| 51 | +import org.springframework.web.servlet.function.RouterFunctions; |
| 52 | +import org.springframework.web.servlet.function.ServerResponse; |
50 | 53 |
|
51 | 54 | import static org.springframework.restdocs.payload.PayloadDocumentation.beneathPath;
|
52 | 55 | import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
53 | 56 | import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
54 | 57 | import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
|
55 | 58 | import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
|
56 | 59 | import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
|
| 60 | +import static org.springframework.web.servlet.function.RequestPredicates.GET; |
57 | 61 |
|
58 | 62 | /**
|
59 | 63 | * Tests for generating documentation describing {@link MappingsEndpoint}.
|
@@ -130,6 +134,13 @@ void mappings() {
|
130 | 134 | fieldWithPath("*.[].details.handlerMethod.name").description("Name of the method."),
|
131 | 135 | fieldWithPath("*.[].details.handlerMethod.descriptor")
|
132 | 136 | .description("Descriptor of the method as specified in the Java Language Specification."));
|
| 137 | + List<FieldDescriptor> handlerFunction = List.of( |
| 138 | + fieldWithPath("*.[].details.handlerFunction").optional() |
| 139 | + .type(JsonFieldType.OBJECT) |
| 140 | + .description("Details of the function, if any, that will handle requests to this mapping."), |
| 141 | + fieldWithPath("*.[].details.handlerFunction.className").type(JsonFieldType.STRING) |
| 142 | + .description("Fully qualified name of the class of the function.")); |
| 143 | + dispatcherServletFields.addAll(handlerFunction); |
133 | 144 | dispatcherServletFields.addAll(handlerMethod);
|
134 | 145 | dispatcherServletFields.addAll(requestMappingConditions);
|
135 | 146 | this.client.get()
|
@@ -192,6 +203,11 @@ ExampleController exampleController() {
|
192 | 203 | return new ExampleController();
|
193 | 204 | }
|
194 | 205 |
|
| 206 | + @Bean |
| 207 | + RouterFunction<ServerResponse> exampleRouter() { |
| 208 | + return RouterFunctions.route(GET("/foo"), (request) -> ServerResponse.ok().build()); |
| 209 | + } |
| 210 | + |
195 | 211 | }
|
196 | 212 |
|
197 | 213 | @RestController
|
|
0 commit comments