gpt4 book ai didi

swagger - 将 API Gateway Cloudformation 模板转换为 Swagger 文件

转载 作者:行者123 更新时间:2023-12-03 07:13:26 27 4
gpt4 key购买 nike

Coludformation 模板中描述了现有的 API。现在我想使用 Swagger 记录 API。有没有办法解析 Cloudformation 模板来创建 swagger.yaml 规范文件?如果可能的话,我希望避免再次编写 API。

注意:我知道您可以使用 Swagger 定义 API,然后在 Cloudformation 模板中导入 API 配置。这不是我需要的。 Cloudformation 已存在且不会更改。因此,我需要相反的东西:基于现有 Cloudformation 模板的 Swagger 配置文件。

最佳答案

据我所知,无法将模板转换为 swagger 文件。但是,如果您正在寻找一种将服务规范仅保留在一个地方(模板)并且已部署它的方法,则可以从舞台中获取 swagger 或 OAS 文件(因此,为此,您还必须有一个舞台)至少有两种方式:

  1. 通过 Web 控制台。使用亚马逊API网关->API->您的 API->阶段>您的阶段->导出选项卡。看图:exporting Swagger or OAS as a file by Web console

  2. aws apigateway get-export ... 这是一个示例:

aws apigateway get-export --rest-api-id ${API_ID} --stage-name ${STAGE_NAME} --export-type swagger swagger.json

关于swagger - 将 API Gateway Cloudformation 模板转换为 Swagger 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65148355/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com