package com.muyu.common.api.doc.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SpringDocConfig {

    @Value("${spring.application.name}")
    private String applicationName;

    private Info info(){
        return new Info()
                .title(String.format("%S-微服务接口文档", applicationName))
                .description("微服务接口文档，根据此接口文档可以进行前后端功能对接/联调")
                .version("v1.0.0");
    }
    private ExternalDocumentation externalDocumentation() {
        return new ExternalDocumentation()
                .description("服务总站")
                .url("https://gitea.qinmian.online");
    }

    @Bean
    public OpenAPI springShopOpenAPI() {
        return new OpenAPI()
                .info(info())
                .externalDocs(externalDocumentation());
    }
}
