Enable Swagger in spring boot through API Gateway
// below is code for API Gateway
@Component
@Primary
@EnableAutoConfiguration
public class DocumentationController implements SwaggerResourcesProvider {
@Override
public List get() {
List resources = new ArrayList<>();
resources.add(swaggerResource("account-service", "/api/account/v2/api-docs", "2.0"));
resources.add(swaggerResource("customer-service", "/api/customer/v2/api-docs", "2.0"));
resources.add(swaggerResource("product-service", "/api/product/v2/api-docs", "2.0"));
resources.add(swaggerResource("transfer-service", "/api/transfer/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;
}
}