Quarkus: how to test secured API endpoints with swagger-ui
Asked Answered
R

1

3

We have a Quarkus application with some secured endpoints. For development and easy testing without much effort, we would like to use Swagger UI as described at https://quarkus.io/guides/openapi-swaggerui. But this seems to only work for unprotected endpoints.

Is there a way to also make request to protected endpoints in Swagger UI?

Radically answered 23/9, 2020 at 23:40 Comment(0)
I
5

You need to add a security scheme to your specification:

One way to do it is by using annotations:

@OpenAPIDefinition(info = @Info(title = "My API", version = "v1"))
@SecurityScheme(
    name = "basicAuth",
    type = SecuritySchemeType.HTTP,
    scheme = "basic"
)
public class ExampleApiApplication extends Application {
}

After you enable security scheme, authorize button will appear on swagger ui. Securirty scheme can be basic, bearer etc..

Authorize button

Ironworker answered 24/9, 2020 at 20:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.