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

标签 swagger aws-cloudformation aws-api-gateway documentation openapi

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/

相关文章:

swagger - Swagger 2.0 中的 JSON API 示例

c# - 获取 Swasbuckle 5 以输出 Swagger 2.0 Json 而不是 OpenAPI 3.0

amazon-web-services - AWS 云形成 : How to get subnet list from VPC?

amazon-web-services - DCOS Cloudformation 中 Mesos 代理的自定义代理角色

amazon-web-services - Terraform 无法将创建的集成附加到 API 网关的路由中

amazon-web-services - AWS API Gateway CORS 飞行前检查失败

node.js - 从架构生成静态 API 文档?

yaml - swagger 编辑器中的多行字符串

amazon-web-services - AWS Cloud Formation WordPress URL 超时

json - AWS API Gateway 正文映射模板中的原始正文有效负载