Skip to content

Capturing pattern in identical paths only renders the path element of one method #2823

Closed
@dzoech

Description

@dzoech

Describe the bug

I have one controller with two methods - one GET and one POST - for the same path. When this path contains a capturing pattern (e.g. {*wildcard}), only the GET path is included in the openapi.yaml and thus the Swagger UI.

To Reproduce

  • What version of spring-boot you are using?
    3.4.0 (but also occurs with 3.3.5)
  • What modules and versions of springdoc-openapi are you using?
    2.7.0 (issue not appearing with 2.6.0)
@Validated
@RestController
@RequestMapping("/api")
@Tag(name = "Lorem ipsum")
public class MyDebugController {
    @GetMapping(value = "/debug/{*wildcard}")
    public ResponseEntity<String> getWildcard(String wildcard) {
        return new ResponseEntity<>("", HttpStatus.NO_CONTENT);
    }

    // THIS ONE IS MISSING
    @PostMapping(value = "/debug/{*wildcard}")
    public ResponseEntity<String>  postWildcard(String wildcard) {
        return new ResponseEntity<>("", HttpStatus.NO_CONTENT);
    }

    @GetMapping(value = "/debug/{simple}")
    public ResponseEntity<String> get(String simple) {
        return new ResponseEntity<>("", HttpStatus.NO_CONTENT);
    }

    @PostMapping(value = "/debug/{simple}")
    public ResponseEntity<String>  post(String simple) {
        return new ResponseEntity<>("", HttpStatus.NO_CONTENT);
    }
}

openapi.yaml is missing the post path for /debug/{wildcard}:

openapi: "3.0.1"
# ...
paths:
  /debug/{simple}:
    get:
      tags:
      - "Lorem ipsum"
      operationId: "get"
      parameters:
      - name: "simple"
        in: "query"
        required: true
        schema:
          type: "string"
      responses:
        "200":
          description: "OK"
          content:
            '*/*':
              schema:
                type: "string"
      security:
      - ssoBearerAuth: []
    post:
      tags:
      - "Lorem ipsum"
      operationId: "post"
      parameters:
      - name: "simple"
        in: "query"
        required: true
        schema:
          type: "string"
      responses:
        "200":
          description: "OK"
          content:
            '*/*':
              schema:
                type: "string"
      security:
      - ssoBearerAuth: []
  /debug/{wildcard}:
    get:
      tags:
      - "Lorem ipsum"
      operationId: "getWildcard"
      parameters:
      - name: "wildcard"
        in: "query"
        required: true
        schema:
          type: "string"
      responses:
        "200":
          description: "OK"
          content:
            '*/*':
              schema:
                type: "string"
      security:
      - ssoBearerAuth: []
components:
# ...

Expected behavior

A path for POST /debug/{wildcard}

Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions