Skip to content

Parameters with same name but different locations can't render in UI properly #1816

Closed
@hujj-615

Description

@hujj-615

Describe the bug

Define 2 parameter objects with same name but different location, only one can be shown in swagger UI.

To Reproduce

Env: Springboot 2.5.14 + springdoc-openapi-ui:1.6.11

Steps:

  1. Create a simple REST API which just has header and cookie parameters with same name.
@RequestHeader(value = "access_token", required = false) 
@Parameter(name = "access_token", in = ParameterIn.HEADER, description = "token in header", schema = @Schema(implementation = String.class)) 
String tokenInHeader,

@CookieValue(value = "access_token", required = false)
@Parameter(name = "access_token", in = ParameterIn.COOKIE, description = "token in cookie", schema = @Schema(implementation = String.class)) 
String tokenInCookie
  1. In /swagger-ui/index.html, only header parameter is defined in API, cookie is missing.

Screen Shot 2022-08-25 at 15 07 47

  1. In /v3/api-docs, there is only 1 parameter as well.

Screen Shot 2022-08-25 at 15 09 04

Expected behavior
From openapi-specification:

A unique parameter is defined by a combination of a name and location.

The access_token in header and cookie are in different location, but the cookie is missing.

Note: If changing parameter name to other value (e.g access_token1) for cookie, it shows well.
Screen Shot 2022-08-25 at 15 19 56

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

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