Serverless Plugin Api Docs

homepage icon https://github.com/8select/serverless-plugin-api-docs
Follow @8select

Tracked

NPM Downloads Last Month
0
Issues
1
Stars
8
Forks
4
Watchers
8
Watch Star Fork Issue Download License NPM Build Status Coverage Status Contributors

Repo README Contents:

serverless-plugin-api-docs

serverless

Work with SWAGGER documentation for Serverless v1.0 projects.

A serverless plugin to automatically create a lambda function which returns the swagger-ui HTML based on the given swagger spec JSON file GET /docs => swagger-ui

Install

using npm:

npm install --save-dev @8select/serverless-plugin-api-docs

or yarn:

yarn add -D @8select/serverless-plugin-api-docs

Add the plugin to your serverless.yml file:

plugins:
  - serverless-plugin-api-docs

Prerequisites

Download and host swagger-ui library files e.g. with S3

Configuration

custom:
  documentation:
    contentUrl: '<URL_TO_YOUR_HOSTED_SWAGGER_UI_FILES>' # REQUIRED
    name: '<your_custom_lambda_function_name>' # OPTIONAL - default = 'docs'

To load your swagger.json you need to add a resolve.alias.
E.g. for webpack:
Assupmtion:

<root>
 |
 |-docs - REST API swagger spec & definitions
    | swagger.json
 | webpack.config.json
module.exports = {
  // [...],
  resolve: {
    alias: {
      PATH_TO_SWAGGER_SPEC: path.resolve(__dirname, 'docs/swagger.json'),
    },
  },
  // [...],
}