All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lx.boot.SwaggerConfig Maven / Gradle / Ivy

Go to download

使用文档: https://a7fi97h1rc.feishu.cn/docx/X3LRdtLhkoXQ8hxgXDQc2CLOnEg?from=from_copylink

There is a newer version: 1.1
Show newest version
package com.lx.boot;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
import com.lx.constant.DefaultBaseConstant;
import com.lx.entity.Var;
import com.lx.util.LX;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * #默认关闭swagger
 * knife4j.enable=true
 * #controller包名
 * swagger.basePackage=com.xxx
 * #请求头默认参数
 * swagger.defaultHeaders=[{"name":"Authorization","description":"登录令牌","defaultValue":"0"}]
 * */
@Slf4j
@Configuration
@EnableKnife4j
@ConditionalOnProperty(name = "knife4j.enable", havingValue = "true", matchIfMissing = false)
public class SwaggerConfig {
    @Bean
    public OpenAPI springShopOpenApi() {
        return new OpenAPI()
                // 接口文档标题
                .info(new Info().title("蒾酒的demo")
                        // 接口文档简介
                        .description("这是基于Knife4j OpenApi3的测试接口文档")
                        // 接口文档版本
                        .version("1.0版本")
                        // 开发者联系方式
                        .contact(new Contact().name("蒾酒")
                                .email("[email protected]")));

    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy