Package Exports
- swagger-ui-aws-apigateway
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (swagger-ui-aws-apigateway) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Swagger UI AWS API Gateway
This module is branched from swagger-ui-express. It allows you to serve auto-generated swagger-ui generated API docs from the AWS API Gateway. It uses Lambda functions to generate the API docs based on a swagger.json or swagger.yaml file. The result is living documentation for your API hosted on your AWS API Gateway.
Swagger version is pulled from npm module swagger-ui-dist. Please use a lock file or specify the version of swagger-ui-dist you want to ensure it is consistent across environments.
You may be also interested in:
- swagger tools: Various tools, including swagger editor, swagger code gen etc.
Usage
Install using npm:
$ npm install swagger-ui-aws-apigatewayConfigure your API Gateway:
- Create a resource of type "proxy resource"
- 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('swagger-ui-aws-apigateway');
const fs = require('fs');
// read your yaml file and initialize
const swaggerDocument = fs.readFileSync('./interface/service_interface.yaml');
var swaggerHandler = swaggerUi.setup(swaggerDocument);
// call the swagger api doc in your handler
exports.handler = (event, context, callback) => {
if (event.path.includes("/api-docs")) {
console.log("Got request to the api docs.");
swaggerHandler(event, context, callback);
return;
}
// ... your other code ...
}Restrictions
Currently the path in the url must be named "api-docs".
Requirements
- Node v0.10.32 or above