spring cloud gateway 底层采用的是webflux,swagger2暂时不支持webflux,网上的解决方案虽然有一些,比如这篇文章 还有《重新定义spring cloud 实战》这本书也有解决方案,书源码链接,
我们项目里面采用的是集成了最新的swagger3 snapshot版本,需要引入的pom文件有:


            org.springframework.boot
            spring-boot-starter-integration
        

        
            org.springframework.integration
            spring-integration-webflux
        

        
            io.springfox
            springfox-swagger2
            3.0.0-SNAPSHOT
        
        
            io.springfox
            springfox-spring-webflux
            3.0.0-SNAPSHOT
        
        
            io.springfox
            springfox-spring-integration-webflux
            3.0.0-SNAPSHOT
        
        
            io.springfox
            springfox-swagger-ui
            3.0.0-SNAPSHOT
            
                
                    ch.qos.logback
                    logback-classic
                
                
                    ch.qos.logback
                    logback-core
                
            
        

                还要引入资源库
                
        
            jcenter-snapshots
            jcenter
            http://oss.jfrog.org/simple/oss-snapshot-local/io/springfox/
            
               false
            
            
               true
            
        
    

因为公司的构建系统只代理这几个仓库:
http://repo1.maven.org/maven2/
http://jcenter.bintray.com/
http://repo.grails.org/grails/core/

所以虽然本地可以调试,但是服务器上构建失败,最后结局方案是,把swagger3的jar包引入本地lib文件,然后在pom中引入,解决问题。这是一个细心的活~
pom文件


            classgraph
            classgraph
            4.1.7
            system
            ${basedir}/lib/classgraph-4.1.7.jar
        
        
            classmate
            classmate
            1.4.0
            system
            ${basedir}/lib/classmate-1.4.0.jar
        
        
            mapstruct
            mapstruct
            1.2.0.Final
            system
            ${basedir}/lib/mapstruct-1.2.0.Final.jar
        
        
            rawhttp
            rawhttp
            2.0
            system
            ${basedir}/lib/rawhttp-core-2.0.jar
        
        
            springfox
            springfox
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-core-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-schema
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-schema-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-spi
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-spi-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-spring-integration
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-spring-integration-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-spring-integration-webflux
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-spring-integration-webflux-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-spring-web
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-spring-web-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-spring-webflux
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-spring-webflux-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-swagger2
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-swagger2-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-swagger-common
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-swagger-common-3.0.0-SNAPSHOT.jar
        
        
            springfox
            springfox-swagger-ui
            3.0.0-SNAPSHOT
            system
            ${basedir}/lib/springfox-swagger-ui-3.0.0-SNAPSHOT.jar
        
        
            spring
            spring-plugin-core
            1.2.0.RELEASE
            system
            ${basedir}/lib/spring-plugin-core-1.2.0.RELEASE.jar
        
        
            spring
            spring-plugin-metadata
            1.2.0.RELEASE
            system
            ${basedir}/lib/spring-plugin-metadata-1.2.0.RELEASE.jar
        
        
            swagger
            swagger-annotations
            1.5.20
            system
            ${basedir}/lib/swagger-annotations-1.5.20.jar
        
        
            swagger
            swagger-models
            1.5.20
            system
            ${basedir}/lib/swagger-models-1.5.20.jar
        

lib库截图:
SpringCloud Gateway与swagger集成解决方案_第1张图片

springfox提供的快照版本:https://springfox.github.io/springfox/docs/current/#maven
希望swagger官方尽早提供swagger3的release版本。