Skip to content

Authorize button not show up when I add securitySchemes #623

Description

@hinewwiner

Describe the bug

  • If you are reporting a bug, please help to speed up problem diagnosis by providing as much information as possible:
  • A clear and concise description of what the bug is: the title of an issue is not enough

When written in SwaggerHub, adding "securitySchemes" automatically enable "Authorize" button for user to get access token. However, Springdoc does not show such button.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? 2.2.6.RELEASE
  • What modules and versions of springdoc-openapi are you using? springdoc-openapi-ui and springdoc-openapi-security both running on 1.3.4
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
  • Provide with a sample code (HelloController) or Test that reproduces the problem

Below is code that I use.

`
@bean
public SecurityScheme oauth() {

return new SecurityScheme()
    .name("user_grant")
    .type(Type.OAUTH2)
    .in(In.HEADER)
    .bearerFormat("jwt")
    .flows(
        new OAuthFlows()
            .password(
                new OAuthFlow()
                    .authorizationUrl(authServer + "/token")
                    .scopes(new Scopes().addString("CLIENT", "for client operations"))));

}

@bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.components(new Components())
.info(
new Info()
.title("Message service")
.description("This documents message-service API")
.version(buildProperties.getVersion()));
}
}
`

Expected behavior

  • A clear and concise description of what you expected to happen.
  • What is the expected result using OpenAPI Description (yml or json)?

Expected from SwaggerHub : expected

Actual from SpringDoc-ui : actual

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

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions