Skip to content

U-nified/aws-serverless-swagger-ui

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Serverless Swagger UI

This module allows you to serve auto-generated swagger-ui API docs from the AWS API Gateway. It uses Lambda functions to generate the API docs based on a swagger/open-api yaml file. The result is living documentation for your API hosted on your AWS API Gateway.

Initially based upon swagger-ui-aws-apigateway, this version focus on :

  • simplify the code base.
  • speed up rendering
  • update code with ES6 syntax including async handler.
  • reduce the number of HTTP requests.
  • accept any filename in .yaml for the definition, not only interface.yaml.
  • allow the path to be whatever you want, not limited to /api-docs (see Restrictions).
  • fix media files rendering in base64.

Install

npm install aws-serverless-swagger-ui

Usage

Configure your API Gateway:

  • Create a resource which will serve your sagger UI (ex: /docs)
  • Create a resource of type "proxy resource" (ex: /docs/{proxy+})
  • Create a method ANY
  • Create a lambda function of type "LAMBDA_PROXY"

In your AWS lambda function, include this package as follows:

const swaggerUi = require('aws-serverless-swagger-ui');
const swaggerHandler = swaggerUi.setup('swagger.yaml');

exports.handler = async (event, context, callback) => {
	return (await swaggerHandler)(event, context, callback);
};

Logs

You can print some logs by setting the Environment Variable DEBUG

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%