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

2023-09-07 14:23:01 作者:、别触碰硪逞强的笑

I am experiencing an issue using springfox-swagger2 v2.2.0 related to the request padding port 80 for a HTTP URL.

Is there anyway to disable the generation of the port or set the port to 443 programmatically based on a Spring Profile?

springfox swagger2配置成功但无法访问 swagger ui.html的解决方法

Generated CURL:

curl -X GET --header "Accept: application/json" "https://test.com:80/api/users/search"

解决方案

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.