Skip to content

Multiple @SecurityScheme inside a @SecuritySchemes are not present in the openapi spec #1125

Closed
@ajeans

Description

@ajeans

Describe the bug

  • I need to declare two @SecurityScheme on my REST API. Declaring either @SecurityScheme works fine (I see a "securitySchemes" node in the spec), but declaring both inside a @SecuritySchemes does not work

To Reproduce
Steps to reproduce the behavior:

$ curl -s http://localhost:8080/v3/api-docs | jq ".components"
{
  "securitySchemes": {
    "bearerToken": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "JWT"
    }
  }
}
  • Modify ./src/main/java/com/quicksign/springdoc/security/multiplesecurityrequirements/OpenApiConfiguration.java (comment the single security declaration, uncomment the multiple security declaration), and restart the application
  • Check that two declarations don't work by doing curl -s http://localhost:8080/v3/api-docs | jq ".components"
$ curl -s http://localhost:8080/v3/api-docs | jq ".components"
{}
  • What version of spring-boot you are using? 2.4.4
  • What modules and versions of springdoc-openapi are you using? 1.5.6

Expected behavior

  • I would expect both security schemes to appear in the openapi spec
$ curl -s http://localhost:8080/v3/api-docs | jq ".components"
{
  "securitySchemes": {
    "bearerToken": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "JWT"
    },
    "basicAuth": {
      "type": "http",
      "scheme": "basic"
    }
  }
}

Screenshots
N/A

Additional context
This seems to have been reported already with #249 which was closed as "works for me", hence the reproducer :)

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