package com.huimv.employment.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.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * OpenAPI / Knife4j 接口文档配置。
 * <p>文档入口：{@code http://localhost:8080/doc.html}</p>
 * <p>
 * 注意：不使用 {@code GroupedOpenApi} 分组。分组模式下 SpringDoc 会将
 * {@code /v3/api-docs/swagger-config} 误判为分组名，导致 Knife4j 请求异常。
 * </p>
 */
@Configuration
public class OpenApiConfig {

    @Bean
    public OpenAPI openAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("灵活用工 fe-server API")
                        .description("灵活用工与用工税筹 — 小程序端及内部接口")
                        .version("1.0.0")
                        .contact(new Contact().name("huimv")))
                .components(new Components().addSecuritySchemes("Authorization",
                        new SecurityScheme()
                                .type(SecurityScheme.Type.HTTP)
                                .scheme("bearer")
                                .bearerFormat("JWT")
                                .in(SecurityScheme.In.HEADER)
                                .name("Authorization")));
    }
}
