# serverless-plugin-swagger-api

> Define your API Endpoints in OpenAPI format (swagger) and create APIGW integration automatically

Latest version **1.1.0** (published 2019-10-31) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install serverless-plugin-swagger-api
pnpm add serverless-plugin-swagger-api
yarn add serverless-plugin-swagger-api
bun add serverless-plugin-swagger-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-10-31 |
| First published | 2019-10-31 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 22.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Patrik Keinonen |
| Maintainers | dontepsu |
| Keywords | serverless, swagger, apigw, api, gateway |

## Links

- npm: https://www.npmjs.com/package/serverless-plugin-swagger-api
- Repository: https://github.com/dontepsu/serverless-plugin-swagger-api
- Homepage: https://github.com/dontepsu/serverless-plugin-swagger-api#readme
- Issues: https://github.com/dontepsu/serverless-plugin-swagger-api/issues
- npm.io page: https://npm.io/package/serverless-plugin-swagger-api

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [@types/serverless](https://npm.io/package/@types/serverless.md) ^1.18.4

## Recent versions

- 1.1.0 (latest) — 2019-10-31
- 1.0.0 — 2019-10-31
- 0.1.4 — 2019-10-31
- 0.1.3 — 2019-10-31
- 0.1.2 — 2019-10-31
- 0.1.1 — 2019-10-31
- 0.1.0 — 2019-10-31
- 0.0.1 — 2019-10-31

## README

# Serverless plugin Swagger API
Create severless function events from `swagger` definition.

## Install
`npm i -D serverless-plugin-swagger-api`

## Usage:
### serverless.yml

Add Swagge file to custom.swaggerApi.swagger

```yaml
custom:
  swaggerApi:
    swagger: ${file(swagger.yml)}

functions:
  ExampleLambda:
    handler: src/example.js
```

### swagger.yml

Add `x-attr-serverless` to your swagger path definition

```yaml
swagger: "2.0"
schemes:
- "https"
info:
  description: "Serverless Plugin Swagger API test yml"
  version: "1.0.0"
  title: "Serverless Plugin Swagger API"
paths:
  /hello:
    get:
      produces:
      - "application/json"
      responses:
        200:
          description: "200 response"
          schema:
            $ref: "#/definitions/Empty"
      x-attr-serverless:
        functionName: ExampleLambda # LambdaFunction in serverless.yml
        cors: true # Turn on CORS for this endpoint, but don't forget to return the right header in your response
        private: true # Requires clients to add API keys values in the `x-api-key` header of their request
        authorizer: # An AWS API Gateway custom authorizer function
          name: authorizerFunc # The name of the authorizer function (must be in this service)
          arn: xxx:xxx:Lambda-Name # Can be used instead of name to reference a function outside of service
          resultTtlInSeconds: 0
          identitySource: method.request.header.Authorization
          identityValidationExpression: someRegex
          type: token # token or request. Determines input to the authorier function, called with the auth token or the entire request event. Defaults to token
definitions:
  Empty:
    type: "object"
    title: "Empty Schema"
```

## Contributing
PR's are welcome! :)

---
_Source: https://npm.io/package/serverless-plugin-swagger-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
