我正在使用 grape-swagger gem 和SwaggerUI的独立安装。我的 API 文档位于http://example.com/api/v1/docs/。SwaggerUI 发现所有资源,但将所有请求发送到http://example.com/v1/foo(URL中缺少“api/”)。这是为什么?
问问题
3889 次
2 回答
1
如果有人遇到同样的问题,请查看文档:grape-swagger 方法有一个参数,add_swagger_documentation
称为base_path
. 就我而言,我必须指定
base_path: '/api'
于 2014-11-17T12:27:43.003 回答
0
使用带有spring-boot ans swagger-ui 2.4.0的maven时遇到了同样的问题。可能与 thymeleaf 等关于资源 url 的其他包不兼容可能是导致问题的原因。
作为一种解决方法,我可以通过像这样重新映射 url 来克服断开的链接:
@Configuration
public class CustomResourceMapping extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addRedirectViewController(
"/configuration/ui",
"/swagger-resources/configuration/ui");
registry.addRedirectViewController(
"/configuration/security",
"/swagger-resources/configuration/security");
}
}
于 2017-04-20T08:15:11.000 回答