aws / aws/aws-sam-cli

Add command to generate swagger/OpenAPI from SAM template

Open
#1,473 11 comments 32 reactions 0 assignees View on GitHub
area/new-command maintainer/need-response type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Describe your idea/feature/enhancement

SAM CLI should provide a command to generate a swagger/OpenAPI definition file given a SAM template. SAM has this great convenience feature where it authors the swagger/OpenAPI document for you at deploy time. However, there are good reasons why a project would want to have access to the document as part of the build process. One example is if the project wants to use [swagger-codegen](https://swagger.io/tools/swagger-codegen/) to generate code from the swagger file. If you want to do this with SAM today, you have to hand-manage the OpenAPI doc yourself rather than let SAM manage it for you.

### Proposal

No SAM spec changes should be needed for this, but the SAM translator library should do most of the heavy lifting here and add a library method to fetch the OpenAPI doc for a given SAM template and API logicalId (default to ServerlessRestApi). Then SAM CLI can add a command (`sam generate openapi`?) that calls this method and outputs the generated OpenAPI doc.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.