Skip to content

Functional DSL incorrect path mapping #980

Closed
@Sam-Kruglov

Description

@Sam-Kruglov

Describe the bug
When I try to do deep nesting (deeper than 1 level), the path mappings "go wild".

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    2.4.0
  • What modules and versions of springdoc-openapi are you using?
    1.5.0 of webflux-ui, kotlin, and security
  • Provide with a sample code (HelloController) or Test that reproduces the problem
class Handler{
  suspend fun getUsers(request: ServerRequest) = ServerResponse.ok().buildAndAwait()
  suspend fun getUserGroups(request: ServerRequest) = ServerResponse.ok().buildAndAwait()
}

@Bean
fun routeDocs(): RouterFunction<ServerResponse> = Handler().let{ handler ->
  RouterFunctions.nest(
    path("/users"),
    SpringdocRouteBuilder.route()
        .GET("", asHandlerFunction(handler::getUsers), {it.operationId("get-users")})
        .POST("/special", asHandlerFunction(handler::getUsers), {it.operationId("create-user-special")})
        .nest(
            path("/groups"),
            Supplier {
              SpringdocRouteBuilder.route()
                  .GET("", asHandlerFunction(handler::getUserGroups), {it.operationId("get-user-groups")})
                  .POST("/special", asHandlerFunction(handler::getUserGroups), {it.operationId("create-user-group-special")})
                  .build()
            },
            {}
        ).build()
)}
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    actual:
paths:
  /users:
    get:
      operationId: get-users_1
      responses: {}
  /users/groups:
    post:
      operationId: create-user-special
      responses: {}
  /users/special:
    post:
      operationId: create-user-group-special
      responses: {}

expected:

paths:
  /users:
    get:
      operationId: get-users #DIFF
      responses: {}
  /users/special: #DIFF
    post:
      operationId: create-user-special
      responses: {}
  /users/groups: #DIFF
    get: #DIFF
      operationId: get-user-groups #DIFF
      responses: {} #DIFF
  /users/groups/special: #DIFF
    post:
      operationId: create-user-group-special
      responses: {}

Expected behavior

  • A clear and concise description of what you expected to happen.
    The paths are way off as you can see, also, operation id gets changed for some reason.
  • What is the expected result using OpenAPI Description (yml or json)?
    above

Additional context
Add any other context about the problem here.
I also tried to call these requests and WebFlux resolves all paths correctly, so the error is only displayed in the open API, the requests work fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions