package com.gcsc.guide.config; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Contact; 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 io.swagger.v3.oas.models.servers.Server; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.List; @Configuration public class OpenApiConfig { private static final String SECURITY_SCHEME_NAME = "Bearer JWT"; @Value("${server.port:8080}") private int serverPort; @Bean public OpenAPI openAPI() { return new OpenAPI() .info(new Info() .title("GC Guide API") .description("GC SI 개발자 가이드 사이트 백엔드 API.\n\n" + "### 인증 방식\n" + "1. `POST /api/auth/google`에 Google ID Token을 전송하여 JWT를 발급받습니다.\n" + "2. 발급받은 JWT를 `Authorization: Bearer {token}` 헤더에 포함하여 요청합니다.\n\n" + "### 권한 구분\n" + "- **Public**: 인증 없이 접근 가능\n" + "- **Authenticated**: 로그인 필요 (ACTIVE 상태)\n" + "- **Admin**: 관리자 권한 필요 (isAdmin=true)") .version("1.0.0") .contact(new Contact() .name("GC SI Dev Team") .email("htlee@gcsc.co.kr"))) .servers(List.of( new Server().url("https://guide.gc-si.dev").description("Production"), new Server().url("http://localhost:" + serverPort).description("Local"))) .addSecurityItem(new SecurityRequirement().addList(SECURITY_SCHEME_NAME)) .components(new Components() .addSecuritySchemes(SECURITY_SCHEME_NAME, new SecurityScheme() .name(SECURITY_SCHEME_NAME) .type(SecurityScheme.Type.HTTP) .scheme("bearer") .bearerFormat("JWT") .description("Google 로그인 후 발급받은 JWT 토큰"))); } }