package ru.ulstu.is.sbapp.Configuration;

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;
import ru.ulstu.is.sbapp.Configuration.Jwt.JwtFilter;

@Configuration
public class OpenAPI30Configuration {
    public static final String API_PREFIX = "/api/1.0";

    @Bean
    public OpenAPI customizeOpenAPI() {
        final String securitySchemeName = JwtFilter.TOKEN_BEGIN_STR;
        return new OpenAPI()
                .addSecurityItem(new SecurityRequirement()
                        .addList(securitySchemeName))
                .components(new Components()
                        .addSecuritySchemes(securitySchemeName, new SecurityScheme()
                                .name(securitySchemeName)
                                .type(SecurityScheme.Type.HTTP)
                                .scheme("bearer")
                                .bearerFormat("JWT")));
    }
}