40
40
import static org .springframework .web .reactive .function .server .RequestPredicates .GET ;
41
41
import static org .springframework .web .reactive .function .server .RequestPredicates .POST ;
42
42
import static org .springframework .web .reactive .function .server .RequestPredicates .PUT ;
43
+ import static org .springframework .web .reactive .function .server .RequestPredicates .queryParam ;
43
44
import static org .springframework .web .reactive .function .server .RouterFunctions .route ;
44
45
45
46
@ Configuration
46
47
class PostRouter {
47
48
48
- @ RouterOperations ({ @ RouterOperation (path = "/posts" , method = RequestMethod .GET , operation = @ Operation (operationId = "all" ,
49
+ @ RouterOperations ({ @ RouterOperation (path = "/posts" , method = RequestMethod .GET , headers = {"x-header1=test1" ,"x-header2=test2" }, operation = @ Operation (operationId = "all" ,
50
+ parameters = { @ Parameter (name = "key" , description = "sample description" ),@ Parameter (name = "test" , description = "sample desc" )},
49
51
responses = @ ApiResponse (responseCode = "200" , content = @ Content (array = @ ArraySchema (schema = @ Schema (implementation = Post .class )))))),
50
52
@ RouterOperation (path = "/posts" , method = RequestMethod .POST , operation = @ Operation (operationId = "create" ,
51
53
requestBody = @ RequestBody (content = @ Content (schema = @ Schema (implementation = Post .class ))), responses = @ ApiResponse (responseCode = "201" ))),
@@ -57,7 +59,7 @@ class PostRouter {
57
59
responses = @ ApiResponse (responseCode = "202" , content = @ Content (schema = @ Schema (implementation = Post .class ))))) })
58
60
@ Bean
59
61
public RouterFunction <ServerResponse > routes (PostHandler postController ) {
60
- return route (GET ("/posts" ), postController ::all )
62
+ return route (GET ("/posts" ). and ( queryParam ( "key" , "value" )) , postController ::all )
61
63
.andRoute (POST ("/posts" ), postController ::create )
62
64
.andRoute (GET ("/posts/{id}" ), postController ::get )
63
65
.andRoute (PUT ("/posts/{id}" ), postController ::update );
0 commit comments