jar包支援
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webflux</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.6</version>
</dependency>
配置類SwaggerAggregationConfig
package com.fms.gateway.config;
import com.google.common.collect.Lists;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux;
import java.util.List;
/**
* create by uking on 2020/7/28
*/
@Data
@Primary
@Component
@RefreshScope
@EnableSwagger2WebFlux
@ConfigurationProperties(prefix = "swagger.resource")
public class SwaggerAggregationConfig implements SwaggerResourcesProvider {
private List<SwaggerResource> list = Lists.newArrayList();
@Override
public List<SwaggerResource> get() {
return list;
}
}
網關需要放開的位址
http
.authorizeExchange()
.pathMatchers(
"/*/v2/api-docs",
"/doc.html",
"/webjars/**",
"/swagger-ui.html",
"/swagger-resources/configuration/ui",
"/swagger-resources"
).permitAll()
最後yml 檔案配置
swagger:
resource:
list:
- {name: 管理平台, location: /cloud-fms/v2/api-docs, swaggerVersion: 1.0}
- {name: 視訊服務, location: /cloud-video/v2/api-docs, swaggerVersion: 1.0}
通路位址:http://localhost:8080/doc.html