• swagger


    package com.config;
    
    import com.google.common.base.Predicates;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import springfox.documentation.builders.ApiInfoBuilder;
    import springfox.documentation.builders.PathSelectors;
    import springfox.documentation.builders.RequestHandlerSelectors;
    import springfox.documentation.service.ApiInfo;
    import springfox.documentation.service.Contact;
    import springfox.documentation.spi.DocumentationType;
    import springfox.documentation.spring.web.plugins.Docket;
    import springfox.documentation.swagger2.annotations.EnableSwagger2;
    
    /**
     * 
     * @date 2020/6/2 10:05
     **/
    @Configuration
    @EnableSwagger2
    public class Swagger2Config {
        /**
         * 屏蔽部分的spring-boot自带的接口
         *
         * @return
         */
        @Bean
        public Docket createRestApi() {
            return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.any())
                    ./*paths(Predicates.not(PathSelectors.regex("/error.*"))).paths(Predicates.not(PathSelectors.regex("/info.*")))
                    .paths(Predicates.not(PathSelectors.regex("/autoconfig.*")))
                    .paths(Predicates.not(PathSelectors.regex("/health.*")))
                    .paths(Predicates.not(PathSelectors.regex("/metrics.*")))
                    .paths(Predicates.not(PathSelectors.regex("/mappings.*")))
                    .paths(Predicates.not(PathSelectors.regex("/trace.*")))
                    .paths(Predicates.not(PathSelectors.regex("/configprops.*")))
                    .paths(Predicates.not(PathSelectors.regex("/beans.*"))).paths(Predicates.not(PathSelectors.regex("/env.*")))
                    .paths(Predicates.not(PathSelectors.regex("/dump.*")))
                    .paths(Predicates.not(PathSelectors.regex("/auditevents.*")))
                    .paths(Predicates.not(PathSelectors.regex("/docs.*"))).paths(Predicates.not(PathSelectors.regex("/archaius.*")))
                    .paths(Predicates.not(PathSelectors.regex("/features.*")))
                    .paths(Predicates.not(PathSelectors.regex("/pause.*"))).paths(Predicates.not(PathSelectors.regex("/refresh.*")))
                    .paths(Predicates.not(PathSelectors.regex("/resume.*")))
                    .paths(Predicates.not(PathSelectors.regex("/actuator.*")))
                    .paths(Predicates.not(PathSelectors.regex("/jolokia.*")))
                    .paths(Predicates.not(PathSelectors.regex("/loggers.*")))
                    .paths(Predicates.not(PathSelectors.regex("/restart.*")))
                    .paths(Predicates.not(PathSelectors.regex("/service-registry/instance-status.*")))
                    .paths(Predicates.not(PathSelectors.regex("/logfile.*")))
                    .paths(Predicates.not(PathSelectors.regex("/channels.*"))).paths(Predicates.not(PathSelectors.regex("/bus.*")))
                    .paths(Predicates.not(PathSelectors.regex("/heapdump.*"))).*/build();
        }
        /**
         * Swagger2主界面信息,描述api的基本信息用于展示
         *
         * @return
         */
        private ApiInfo apiInfo() {
            return new ApiInfoBuilder().
                    title("交换中心服务工具")
                    .description("交换中心服务工具")
                    .termsOfServiceUrl("http://abc.com/")
                    .contact(new Contact("abc", "", ""))
                    .version("1.0")
                    .license("开发有限公司").build();
        }
    }
    

      

  • 相关阅读:
    C++/C编程指南之基本语句
    利用Lucene.net对附件做搜索
    验证码的破解思路!
    javascript中replace的正则表达式语法
    让数据库访问组件支持Using
    C#读写文件总结
    net use命令详细解释
    利用SQL语句清理日志
    彻底修改Google Chrome浏览器的安装目录
    oracle sqlplus 常用命令大全
  • 原文地址:https://www.cnblogs.com/gendway/p/13952287.html
Copyright © 2020-2023  润新知