Swagger基本URL对于我在AWS上部署的应用程序是错误的

时间:2019-08-27 16:52:08

标签: swagger swagger-ui swagger-2.0

我有一个Spring Boot应用程序已部署并配置为AWS Route 53> AWS Load Balance-> 2个托管Spring Boot应用程序的EC2实例。

Swagger的URL是 https ://applicationXYZ.company.net/release/swagger-ui.html

我可以看到页面,而没有任何问题。但是我们无法使用“试用”功能,因为基本URL错误。

在页面顶部,我确实看到了以下信息: [基本网址:服务/版本]

enter image description here

我不知道“服务”在哪里成为我的基本URL。我还点击了api-docs,还在“主机”字段中看到了“服务器”。

您能帮忙吗?

注意:我使用的是Spring Boot Starter 2.0.8.RELEASE和Swagger 2.9.2(没有任何Spring Security)

谢谢

1 个答案:

答案 0 :(得分:0)

您曾经尝试进行重定向,

//Do redirection inside controller
@RequestMapping("/swagger")
public String greeting() {
    return "redirect:/swagger-ui.html";
}

您也可以尝试在main方法内添加bean,

@Bean
RouterFunction<ServerResponse> routerFunction() {
    return route(GET("/swagger"), req ->
        ServerResponse.temporaryRedirect(URI.create("swagger-ui.html")).build());
}

引用:How to change Swagger-ui URL prefix?