Skip to content

ikkyu-3/serverless-openapi3-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 23, 2020
a54e317 · Jul 23, 2020

History

46 Commits
Jul 23, 2020
Jul 23, 2020
Aug 6, 2019
Jul 23, 2020
Aug 6, 2019
Jul 25, 2019
Jul 28, 2019
Jul 23, 2020
Jul 23, 2020
Jul 28, 2019
Jul 24, 2019
Aug 1, 2019
Jul 30, 2019
Jul 23, 2020
Jul 23, 2020
Jul 23, 2020

Repository files navigation

serverless-openapi3-plugin

CircleCI npm version License: MIT

Serverless plugin to resolve $ref syntax of OpenAPI3

install

npm install --save serverless-openapi3-plugin

usage

plugins:
  - serverless-openapi3-plugin

custom:
  openApiPath: './resources/open-api/index.yaml' # OpenApi File

When do you use it ?

When you want to use $ref syntax in OpenApi File, use this plugin.

example project

The example project uses example API of Amazon API Gateway.

.
├── resources
│   ├── api-gateway.yaml # ApiGateway Resource
│   └── open-api
│       ├── index.yaml # OpenApi Entry File
│       ├── components
│       │   └── schemas.yaml
│       └── paths
│           ├── pets-id.yaml
│           ├── pets.yaml
│           └── root.yaml
└── serverless.yml
# serverless.yaml
...
resources:
  - ${file(./resources/api-gateway.yaml)}
# resources/api-gateway.yaml
Resources:
  RestApi:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: rest-api
      Body: ${file(./resources/open-api/index.yaml)} # OpenApi Entry File
# resources/open-api/index.yaml
paths:
  /pets:
    $ref: './paths/pets.yaml'
  /pets/{petId}:
    $ref: './paths/pets-id.yaml'
  /:
    $ref: './paths/root.yaml'

components:
  schemas:
    $ref: './components/schemas.yaml'