Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dzoech opened this issue Dec 18, 2024 · 0 comments

Comments

@dzoech
Copy link

dzoech commented Dec 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant