Skip to content

Global headers aren't appearing in the Swagger UI #466

@keith-miller

Description

@keith-miller

Describe the bug
Following the steps in the FAQ and here to add a global header. The header isn't added to every endpoint.

To Reproduce

  • Spring boot version: 2.2.2.RELEASE
  • Springdoc OpenApi UI version: 1.2.32

Enter the following somewhere Spring Boot will pick it up:

@Bean
public OpenAPI openAPI() {
    return new OpenAPI()
            .components(new Components()
                    .addSecuritySchemes("spring_oauth", new SecurityScheme()
                            .type(SecurityScheme.Type.OAUTH2)
                            .description("Oauth2 flow")
                            .flows(new OAuthFlows()
                                    .authorizationCode(new OAuthFlow()
                                            .authorizationUrl(authUrl + "/auth")
                                            .refreshUrl(authUrl + "/token")
                                            .tokenUrl(authUrl + "/token")
                                            .scopes(new Scopes())
                                    )))
                    .addSecuritySchemes("api_key", new SecurityScheme()
                            .type(SecurityScheme.Type.APIKEY)
                            .description("Api Key access")
                            .in(SecurityScheme.In.HEADER)
                            .name("API-KEY")
                    )
                    .addHeaders("Version", new Header()
                            .description("version header")
                            .required(true)
                            .schema(new StringSchema())))
            .security(Arrays.asList(
                    new SecurityRequirement().addList("spring_oauth"),
                    new SecurityRequirement().addList("api_key")));
}

Expected behavior
Header Version should appear in the Swagger UI under every endpoint, but it does not.

Additional context
I could be misunderstanding the FAQ, if so I apologize.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions