Closed
Description
Im trying SpringDoc version 1.4.7 (with only springdoc-openapi-webflux-core module) with Spring Boot 2.3.4.RELEASE and Webflux Functional Endpoints.
I mapped the routes definition bean with RouterOperations as shown in this example:
@Bean
@RouterOperations({
@RouterOperation(path = "/greeter/namedHello", beanClass = HelloHandler.class, beanMethod = "namedHello"),
@RouterOperation(path = "/greeter/hello", beanClass = HelloHandler.class, beanMethod = "hello"),
})
public RouterFunction<ServerResponse> helloRoutes() {
return nest(path("/greeter"),
route(GET("/namedHello"), helloHandler::namedHello)
.andRoute(GET("/hello"), helloHandler::hello)
);
}
However the output of calling http://localhost:8080/v3/api-docs shows an empty definition:
{
"openapi":"3.0.1",
"info":{
"title":"OpenAPI definition",
"version":"v0"
},
"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],
"paths":{},
"components":{}}
If I remove the prefix path from RouterOperation path, like this
@Bean
@RouterOperations({
@RouterOperation(path = "/namedHello", beanClass = HelloHandler.class, beanMethod = "namedHello"),
@RouterOperation(path = "/hello", beanClass = HelloHandler.class, beanMethod = "hello"),
})
public RouterFunction<ServerResponse> helloRoutes() {
return nest(path("/greeter"),
route(GET("/namedHello"), helloHandler::namedHello)
.andRoute(GET("/hello"), helloHandler::hello)
);
}
Something seems to change, however the path in the OpenAPI definition is wrong:
{
"openapi":"3.0.1",
"info":{
"title":"OpenAPI definition",
"version":"v0"
},
"servers":[
{
"url":"http://localhost:8080",
"description":"Generated server url"
}
],
"paths":{
"/hello":{
"get":{
"tags":[
"hello-handler"
],
"operationId":"hello",
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/HelloResponseDef"
}
}
}
}
}
}
},
"/namedHello":{
"get":{
"tags":[
"hello-handler"
],
"operationId":"namedHello",
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/ServerResponse"
}
}
}
}
}
}
}
},
// JSON truncated
Here is the expected output:
{
"openapi":"3.0.1",
"info":{
"title":"OpenAPI definition",
"version":"v0"
},
"servers":[
{
"url":"http://localhost:8080",
"description":"Generated server url"
}
],
"paths":{
"/greeter/hello":{
"get":{
"tags":[
"hello-handler"
],
"operationId":"hello",
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/HelloResponseDef"
}
}
}
}
}
}
},
"/greeter/namedHello":{
"get":{
"tags":[
"hello-handler"
],
"operationId":"namedHello",
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/ServerResponse"
}
}
}
}
}
}
}
},
// JSON truncated
Am I missing something?