package com.malk.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * OpenAPI (Swagger UI) 配置
 * -
 * 仅当 application.yml 中 swagger.enable=true 时加载；
 * 配合 springdoc.api-docs.enabled / springdoc.swagger-ui.enabled 共同控制。
 * -
 * UI 路径：{contextPath}/swagger-ui.html
 * JSON 路径：{contextPath}/v3/api-docs
 */
@Configuration
@ConditionalOnProperty(name = "swagger.enable", havingValue = "true")
public class OpenApiConfig {

    @Bean
    public OpenAPI mjavaOpenAPI() {
        return new OpenAPI().info(new Info()
                .title("mjava API")
                .description("mjava 基座对外 HTTP 接口文档")
                .version("v1"));
    }
}
