简体   繁体   中英

How to generate swagger documentation for aws-lambda python API?

I have an AWS-lambda based API, written in python. The data is in elastic search. The python code is basically an interface between the user and ES.

I need to add swagger documentation.

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.

Is there a library that would help me to somehow automatically generate the swagger documentation?

I was searching around, and I found multiple libraries for flask, but I'm not using flask

Steps to get swagger details from AWS API gateway :

  1. Go to API gateway
  2. Click on stage
  3. Select Stage which you need to get
  4. Select "Export" tab
  5. Choose required option like Export as Swagger

Swagger 导出图像

In API Gateway you can create REST APIs or HTTP APIs, for the differences see here .

@aviboy2006's answer is for the older standard, 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:

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 .

Source: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-export.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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