1

Using Swagger UI from Springdoc OpenAPI 1.5.11 in a Spring Boot 2.5.3 web application that exposes a REST API.

The REST API is secured using a bearer provided JWT token.

I successfully configured Springdoc to display the "Authorize" button with bearer authorization, where users can type a valid JWT token, and use that token when calling the REST API.

Hence, using the REST API is properly secured.

But viewing the REST API (endpoints, methods, input and output data structures, etc) must also be secured. This means that the API definition endpoint (the one defined by "springdoc.api-docs.path") called by Swagger UI should also use the token.

So far, I could not make Swagger UI use token to fetch the API definition, see snapshot.

Swagger UI fails loading a secured API definition

Is this possible ?

Florian Beaufumé
  • 1,751
  • 2
  • 22
  • 34
  • You can implement a request interceptor for the openapi endpoint alone. More details [here](https://stackoverflow.com/a/70487379/9269177) – Debargha Roy Dec 29 '21 at 13:48

0 Answers0