The document describes a Java configuration class for Spring Boot that sets up OpenAPI documentation using Swagger 3. It includes annotations for defining the API title, version, and security scheme utilizing JWT Bearer tokens. The class itself is empty, relying on annotations to configure Swagger UI and enable testing of protected endpoints.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
8 views2 pages
New Microsoft Word Document
The document describes a Java configuration class for Spring Boot that sets up OpenAPI documentation using Swagger 3. It includes annotations for defining the API title, version, and security scheme utilizing JWT Bearer tokens. The class itself is empty, relying on annotations to configure Swagger UI and enable testing of protected endpoints.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
// Marks this class as a configuration class in Spring
Boot. // Classes annotated with @Configuration are used to define beans and configurations. @Configuration
// Adds OpenAPI documentation details using Swagger
3 / OpenAPI 3 specification. // This helps generate UI documentation (like Swagger UI) for your REST APIs. @OpenAPIDefinition( info = @Info( title = "Brands Service", // This is the title of the API documentation shown in Swagger UI version = "v1" // This is the version of the API ) )
// Defines the security scheme used by this API for
Swagger documentation. // This tells Swagger that our API is secured using JWT Bearer tokens. @SecurityScheme( name = "bearerAuth", // The name of the security scheme used in Swagger UI (you refer to this in your @SecurityRequirement) type = SecuritySchemeType.HTTP, // Type is HTTP authentication (for Bearer Token) bearerFormat = "JWT", // The format is JWT (JSON Web Token) - means token structure follows JWT standard scheme = "bearer" // The scheme used in Authorization header, like "Authorization: Bearer <token>" )
// This is a Java class used only for configuration.
// It doesn’t contain any methods because all it does is configure OpenAPI and JWT settings for Swagger UI. public class OpenApi3Config {
// Empty class body because all the work is done by
annotations above. // This is enough for SpringDoc to automatically generate Swagger documentation // with JWT security enabled so developers can test protected endpoints from Swagger UI. }