Springfox Swagger使用端口80为HTTPS URL生成请求

时间:2015-10-14 05:46:06

标签: swagger springfox

我在使用与HTTP URL的请求填充端口80相关的springfox-swagger2 v2.2.0时遇到问题。

是否有禁用端口的生成或根据Spring配置文件以编程方式将端口设置为443?

生成的CURL:

curl -X GET --header“接受:application / json”“https://test.com:80/api/users/search

2 个答案:

答案 0 :(得分:1)

I had the same issue. It is because Swagger uses a class from Spring Framework which is adding the port 80 to the host property in the /v2/api-docs json response (Check Swagger2Controller.class). I had this issue with spring framework version 4.1.4.Release. Upgrading to latest version 4.3.2.Release fixed it.

答案 1 :(得分:1)

遇到同样的问题,但不是根据@Akshay的答案升级spring框架库(感谢指出Swagger2Controller.class),我将以下属性添加到我的application-dev.yml文件中(将hostname替换为你的主机)。

springfox.documentation.swagger.v2.host:hostName:443