繁体   English   中英

Swagger openapi 重定向 http 到 https

[英]Swagger openapi redirect http to https

在我的应用程序中,我们使用openapi以默认配置引导 swagger。

我们使用的依赖: org.springdoc:springdoc-openapi-ui:1.6.9

我们没有使用任何 json / yaml 来指定开放的 api 规格。

该应用程序在https上运行,但 swagger 使用默认协议http

我已经通过社区回答这样建议编辑 json 规范来配置协议。

但是想知道是否有任何其他方式(可能是任何注释)可以实现相同的效果?

请建议。

使用 openapi @ServerVariable 在主 SpringBootApplication 中定义 @OpenAPIDefinition,如下所示:

@OpenAPIDefinition(servers = {@Server(url = "https://{host}",
variables = @ServerVariable(name = "host",
defaultValue = "hostname_sit",
allowableValues = {"hostname_sit","hostname_uat"}),
description = "Host name by environment")})
    

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM