npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-swagger-api

v1.4.2

Published

[![Build Status](https://travis-ci.org/drg-adaptive/serverless-swagger-api.svg)](https://travis-ci.org/drg-adaptive/serverless-swagger-api) [![Maintainability](https://api.codeclimate.com/v1/badges/006339522a8624e9bacb/maintainability)](https://codeclimat

Downloads

281

Readme

Serverless Swagger API

Build Status Maintainability npm version FOSSA Status

This is a serverless plugin that simplifies the process of creating an AWS API Gateway from a swagger file.

Installation

yarn add --dev serverless-swagger-api

Configuration

Lambda Functions

You must manually create your own lambda functions in the serverless configuration. Once the methods are created, they will be referenced in the swagger file.

Swagger File

Add a x-lambda-name property to every path method to bind a part of the api to a lambda.

paths:
  /testPath:
    get:
      x-lambda-name: TestPathLambdaFunction
      ...

CORS Configuration

Add a x-cors property to the path you want to add CORS options responses to.

paths:
  /testPath:
    x-cors: true

If you want to specify a specific attribute, provide one of the following properties

| Property | Description | Default | | -------- | ----------------------------------- | ------------------------------------------------------------- | | origin | A string specifying allowed origins | * | | headers | An array of headers to be allowed | Constructed from the parameters property of every path method | | methods | An array of methods to be allowed | Constructed by looking at all methods defined for a path |

Plugin Settings

Now you need to tell the swagger api plugin about your configuration file. Add a swaggerApi property to the custom section of your serverless configuration. You can add as many apis as you want by adding children to the swaggerApi.apis property.

updateDeployments

Will automatically update API gateway deployments if not set to false.

usePackageVersion

The info.version value in your OpenAPI file will be overwritten with the version in package.json.

apis

An object containing all of the APIs to be defined in this stack.

custom:
  swaggerApi:
    updateDeployments: true
    usePackageVersion: true
    apis:
      PrimaryApi:
        Name: ${self:provider.stage}-${self:service}-PrimaryApi
        Body: ${file(./some-swagger-file.yaml)}
        Lambda: ExampleLambdaFunction
        Stage: dev
Properties

Each API object has the following properties

| Name | Required | Description | | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------- | | Name | Yes | Name of the API that will be used as the Name parameter when creating the AWS::ApiGateway::RestApi CloudFormation object | | Body | Yes | The swagger/openapi file that defines the API | | Stage | Yes | The name of the API Gateway stage that will be created | | Lambda | No | Default lambda name that will be used if x-lambda-name isn't provided on a path |

Created Resources

IAM Roles

An IAM role is created for each API with the name PrimaryApiServiceRole

License

FOSSA Status