Skip to content

OpenAPI: generated yaml/json files missing @SecurityScheme annotation #3652

@bmudda-wpp

Description

@bmudda-wpp

I have the following controller annonated as follows

@SecurityScheme(
        name = "myBearerToken",
        type = SecuritySchemeType.HTTP,
        scheme = "bearer",
        bearerFormat = "JWT",
        in = SecuritySchemeIn.HEADER)
public class UserApi {
    
    ....

  @GET("/{id}")
  @Operation(
          summary = "Find a user by ID",
          description = "Finds a user by ID or throws a 404"
  )
  @SecurityRequirement(name = "myBearerToken", scopes = "user:read")
  public User getUser(@PathParam String id) {
    ....
  }

}

In the generated yaml file, I have

paths:
  /public-api/user/{id}:
    get:
      tags:
      - User
      summary: Find a user by ID
      description: Finds a user by ID or throws a 404
      operationId: getUser
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: object
      security:
      - myBearerToken:
        - user:read

The @SecurityScheme is not generated and added to the components section in the yaml file as described in open api.

components:
  ...

  securitySchemes:
    myBearerToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      in: header

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions