11

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

eternal_student
  • 626
  • 4
  • 18

2 Answers2

4

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 export images

Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53
3

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

mastazi
  • 1,623
  • 26
  • 41