@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
@EnableSwagger2Doc
public class AppGateWay {

    public static void main(String[] args) {
        SpringApplication.run(AppGateWay.class, args);
    }

    // 添加文档来源
    @Component
    @Primary
    class DocumentationConfig implements SwaggerResourcesProvider {
        @Override
        public List<SwaggerResource> get() {
            List resources = new ArrayList<>();
            //会员服务
            resources.add(swaggerResource("app-shop-member", "/app-shop-member/v2/api-docs", "2.0"));                
            //微信服务
            resources.add(swaggerResource("app-shop-weixin", "/app-shop-weixin/v2/api-docs", "2.0"));
            return resources;
        }

        private SwaggerResource swaggerResource(String name, String location, String version) {
            SwaggerResource swaggerResource = new SwaggerResource();
            swaggerResource.setName(name);
            swaggerResource.setLocation(location);
            swaggerResource.setSwaggerVersion(version);
            return swaggerResource;
        }

    }

}

访问方法:ip:端口/v2/api-docs
例如http://localhost:8300/v2/api-docs

Last modification:August 16, 2019
如果觉得这篇技术文章对你有用,请随意赞赏