我和spring混淆了url,他们没有指向正确的url。
我刚刚在一个上下文中部署了一个war,所以这个应用程序是在127.0.0.1:8080/bff中运行的,我成功地添加了它现在在127.0.0.1:8080/bff/swagger-ui.html中的运行,但是当我尝试测试它指向127.0.0.1:8080/bff/v2/api-docs/api/v1/home/profile的api时。为什么会有v2/api-docs !?
我知道swagger上的API列表是从该列表中填充的,但是为什么在测试API时将它注入URL呢?因为我所有的API都在127.0.0.1:8080/bff/api/v1上
这是截图

这是密码。
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Autowired
private GitVersionPropertiesConfig gitVersionPropertiesConfig;
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.globalOperationParameters(
Lists.newArrayList(new ParameterBuilder()
.name("Authorization")
.description("OAUTH2 Token")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(false)
.build()))
.apiInfo(apiInfo())
.pathMapping("/")
.pathProvider(new RelativePathProvider(null) {
@Override
public String getApplicationBasePath() {
return "/bff/";
}
})
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.regex("/api.*"))
.build();
}
ApiInfo apiInfo() {
String desc = "Bima Friends Forever API<br>"
+ "Current Branch : <b>"+gitVersionPropertiesConfig.getGitBranch()+"</b><br>"
+ "Timestamp : <b>"+gitVersionPropertiesConfig.getGitBuildTime()+"</b>";
return new ApiInfoBuilder()
.title("BFF - Hutchison")
.description(desc)
.version(gitVersionPropertiesConfig.getGitCommitIdAbbrev())
.build();
}
}这是暂时的解决办法,但不是永久性的。
打开浏览器控制台并运行window.swaggerUi.api.setBasePath('/bff');
服务器:版本: 2.7.0
提前谢谢。
发布于 2019-03-17 09:51:38
我设法修好了..。罪魁祸首是jboss-web.xml上下文
之前
<jboss-web>
<context-root>/bff/</context-root>
</jboss-web>修正:
<jboss-web>
<context-root>/bff</context-root>
</jboss-web>天啊..。
https://stackoverflow.com/questions/54918671
复制相似问题