[英]How to generate swagger documentation for aws-lambda python API?
I have an AWS-lambda based API, written in python.我有一个基于 AWS-lambda 的 API,用 python 编写。 The data is in elastic search.
数据在弹性搜索中。 The python code is basically an interface between the user and ES.
python代码基本上是用户和ES之间的接口。
I need to add swagger documentation.我需要添加 swagger 文档。
I can create the swagger.json file manually, but I would like to have some automated process, to be able to keep up with future changes.我可以手动创建 swagger.json 文件,但我希望有一些自动化过程,以便能够跟上未来的变化。
Is there a library that would help me to somehow automatically generate the swagger documentation?是否有一个库可以帮助我以某种方式自动生成 swagger 文档?
I was searching around, and I found multiple libraries for flask, but I'm not using flask我四处寻找,发现了多个烧瓶库,但我没有使用烧瓶
In API Gateway you can create REST APIs or HTTP APIs, for the differences see here .在 API Gateway 中,您可以创建 REST API 或 HTTP API,差异请参见此处。
@aviboy2006's answer is for the older standard, REST API. @aviboy2006 的答案是针对较旧的标准 REST API。
If you are using the newer HTTP API, you can only export in OpenAPI 3.0 format (Swagger will import this, unless you have an old version) and you have to export using the AWS CLI:如果您使用较新的 HTTP API,则只能以 OpenAPI 3.0 格式导出(Swagger 将导入此格式,除非您有旧版本),并且必须使用 AWS CLI 导出:
aws apigatewayv2 export-api \
--api-id api-id \
--output-type YAML \
--specification OAS30 \
--stage-name prod \
stage-definition.yaml
for output type you can choose between JSON
and YAML
.对于输出类型,您可以在
JSON
和YAML
之间进行选择。
Source: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-export.html来源: https : //docs.aws.amazon.com/apigateway/latest/developerguide/http-api-export.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.