Skip to content

Commit

Permalink
swagger - set api scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
chinnawatsut committed Mar 23, 2024
1 parent e9cb896 commit 244ec90
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.kampus.kbazaar.swagger;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

private SecurityScheme createAPIKeyScheme() {
return new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.bearerFormat("JWT")
.scheme("bearer");
}

@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.addSecurityItem(new SecurityRequirement().addList("Bearer Authentication"))
.components(
new Components()
.addSecuritySchemes("Bearer Authentication", createAPIKeyScheme()))
.info(new Info().title("KBazaar"));
}
}

0 comments on commit 244ec90

Please sign in to comment.