package com.seer.teach.mp.app.config;

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.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile({"local","dev","test"})
public class MpApiConfig {

    @Value("${server.servlet.context-path:/}")
    private String contextPath;

    @Bean
    public OpenAPI mpAppOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("Seer Teach MP端API")
                        .description("此文档详细说明了mp端接口规范")
                        .version("v1.0.0")
                        .contact(new Contact()
                                .name("广东用嘉研发部")))
                .addServersItem(new Server().url(contextPath));
    }

    @Bean
    public GroupedOpenApi mallWeChatApi() {
        return GroupedOpenApi.builder()
                .group("seer-mp-app")
                .pathsToMatch("/app/**")
                .build();
    }
}