Skip to content

Reactive endpoints using RouterFunction.nested with version predicate only supports one nested route #3282

Description

@s5jonathan

Describe the bug

Using RequestPredicates.version as a predicate for RouterFunctions.nest only works for the first nested route. I think the issue stems from the fact that AbstractRouterFunctionVisitor::commonRoute sets this.version = null causing the version to work for the first nested route but not to be set for future nested routes.

To Reproduce

public RouterFunction<ServerResponse> router3() {
    HandlerFunction<ServerResponse> handler = request -> ServerResponse.accepted().build();
    return RouterFunctions.nest(path("/api/{version}"),
            RouterFunctions.nest(version("v1"),
                route().GET("/foo", handler, ops -> ops.operationId("getFooV1")).build()
                .and(route().GET("/bar", handler, ops -> ops.operationId("getBarV1")).build())
            .andNest(version("v2"),
                route().GET("/foo", handler, ops -> ops.operationId("getFooV2")).build()
                .and(route().GET("/bar", handler, ops -> ops.operationId("getBarV2")).build()))));
}

With path segment routing, this currently generates the following:

/api/v1/foo
/api/v2/foo
/api/{version}/bar

Expected behavior

/api/v1/foo
/api/v1/bar
/api/v2/foo
/api/v2/bar
  • What version of spring-boot you are using? 4.0.5
  • What modules and versions of springdoc-openapi are you using? springdoc-openapi-starter-webflux-ui 3.0.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions