Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/Added authorization bottom to Swagger #43

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/main/java/com/ua/accommodation/config/OpenApiConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.ua.accommodation.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
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 OpenApiConfig {
public static final String BEARER_AUTH = "BearerAuth";
public static final String BEARER = "bearer";
public static final String JWT = "JWT";

@Bean
public OpenAPI customOpenApi() {
return new OpenAPI()
.components(new Components().addSecuritySchemes(BEARER_AUTH,
new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme(BEARER)
.bearerFormat(JWT)))
.addSecurityItem(new SecurityRequirement().addList(BEARER_AUTH));
}
}
Loading