Import functions from swagger spec filet to serverless.yml
Last updated 9 months ago by adrien-fery .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @amaplex-software/serverless-import-swagger 
SYNC missed versions from official npm registry.


Import functions from swagger spec filet to serverless.yml of Serverless Framework

Build Status


$ npm install serverless-import-swagger

Add tag to Operation Object in swagger.yaml

Add sls-{service-name} tag to the operation that targeted by serverless.
Default prefix is "sls". If you want to use other prefix, call sls command with -A option.


Set swagger.yaml file on applicaion root directory.
If you want to apply common configs to serverless.yml, set serverless.common.yml file on application root directory.

Usage: sis [options]

  Import functions from swagger spec filet to serverless.yml


    -h, --help                     output usage information
    -V, --version                  output the version number

    # Common options.
    -i, --input [path]             Specify swagger file path(s). (default "./swagger.ya?ml")
                                   It multiple paths given like `-i foo/swagger.yml -i bar/swagger.ymls, merged result is produced.
    -c, --common <path>            Specify common config of serverless file path. (default "./serverless.common.ya?ml")
    -o, --out-dir <path>           Specify dist directory of services. (default "./")
    -f, --force                    If add this option, overwriten serverless.yml by generated definitinos.

    # Services and tags prefix options.
    -A, --api-prefix <prefix>      Specify target prefix for swagger tags. (default "sls")
    -S, --service-prefix <prefix>  Specify prefix that added service name. (default none)

    # Base path mode that spliting large api specification settings.
    -B, --base-path                If add this option, run in a mode of dividing a service by a api base path.

    # CORS and OPTIONS method settings.
    -C, --cors                     If add this option, added cors setting to all http event.
    -O, --options-method           If add this option, added cors setting to get http event, and added OPTIONS method to api path that including other http method.

    # Other settings.
    --operation-id                 If this option is added and an API has operationId, the function is named from operationId.


$ sis -i /path/to/swagger.yml -c /path/to/serverless.common.yml -o ./src


Serverless depends on constraints of amazon web service.
For example...

  • The maximum number of CloudFormation resources is 200. Therefore, APIs that contain many paths need to be divided using --base-path mode.
  • The function name of AWS Lambda must be 64 characters or less. For that reason, if long function names are generated, they can not be deployed.
  • API Gateway requires that path parameters in the same hierarchy be unique. Serverless also suffers from similar restrictions.

Current Tags

  • 0.1.3                                ...           latest (9 months ago)

1 Versions

  • 0.1.3                                ...           9 months ago
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (9)
Dev Dependencies (8)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |