swagger-merger
Merge multiple swagger files into a swagger file, support JSON/YAML.
Last updated 4 months ago by windomz .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install swagger-merger -g
SYNC missed versions from official npm registry.

swagger-merger

Greenkeeper badge Build Status Coverage Status Dependency Standard - JavaScript Style Guide License

Merge multiple swagger files into a swagger file, support JSON/YAML.

NPM

swagger-merger status

Features

  • [x] $ref - A tag, include a single-level of swagger file.
  • [x] $ref#* - A tag, include a multi-level of swagger file.
  • [x] CLI - Command line interface.
  • [x] Support JSON/YAML swagger files(.json/.yaml/.yml).
  • [x] Merge multiple swagger files into a swagger file.

Install

npm install -g swagger-merger

Usage

$ swagger-merger -h

  Usage: swagger-merger [-h] [-v] [-c] [-o file] <-i file | file>

  Merge multiple swagger files into a swagger file, just support JSON/YAML.

  Options:

    -h, --help           output usage information
    -V, --version        output the version number
    -i, --input <file>   input a main/entry JSON/YAML swagger file
    -o, --output <file>  output a merged JSON/YAML swagger file, default is `swagger.*`
    -c, --compact        compact JSON/YAML format string
    --debug              debug mode, such as print error tracks

$ref

Include a single-level of swagger file.

For example:

parameters:
    - $ref: "./name.yaml"
    - $ref: "./year.yaml"

$ref#*

Include a multi-level of swagger file.

For example:

paths:
  $ref#pets: "./paths/pets.yaml"
  $ref#pets-id: "./paths/pets-id.yaml"
definitions:
  $ref#pets: "./definitions/pets.yaml"
  $ref#error: "./definitions/error.yaml"

CLI

How to use?

swagger-merger -i in.yaml                # Merge in.yaml into swagger.yaml
swagger-merger -i in.yaml -o out.yaml    # Merge in.yaml into out.yaml
swagger-merger -i in.yaml -o out.yaml -c # Merge in.yaml into out.yaml and compress it
swagger-merger -i in.yaml -o out.json    # Merge in.yaml into out.json

swagger-merger -i in.json                # Merge in.json into swagger.json
swagger-merger -i in.json -o out.json    # Merge in.json into out.json
swagger-merger -i in.json -o out.json -c # Merge in.json into out.json and compress it
swagger-merger -i in.json -o out.yaml    # Merge in.json into out.yaml

Examples

how to use? It would be more helpful to see this examples.

./example/heroku-pets

  • Official swagger example
  • No modification
  • For more help, see the README

Go to ./example/heroku-pets, run the following script:

swagger-merger -i index.yaml
swagger-merger -i index.json
  1. The output swagger.json is same as the expected heroku-pets.json.
  2. The output swagger.yaml is similar to the expected heroku-pets.yaml.

./example/echo

  • Base on official swagger example
  • Modify to support for $ref tags
  • For more help, see the README

Go to ./example/echo, run the following script:

swagger-merger -i index.yaml
swagger-merger -i index.json
  1. The output swagger.json is same as the expected echo.json.
  2. The output swagger.yaml is similar to the expected echo.yaml.

./example/petstore_simple

  • Base on official swagger example
  • Modify to support for $ref#* tags
  • For more help, see the README

Go to ./example/petstore_simple, run the following script:

swagger-merger -i index.yaml
swagger-merger -i index.json
  1. The output swagger.json is same as the expected petstore_simple.json.
  2. The output swagger.yaml is similar to the expected petstore_simple.yaml.

./example/petstore_domain

A way of using $ref instead of $ref#*

  • Same as petstore_simple
  • Modify to support for $ref tags
  • Modify to support for multiple levels schema
  • For more help, see the README

Go to ./example/petstore_domain, run the following script:

swagger-merger -i index.yaml
swagger-merger -i index.json
  1. The output swagger.json is same as the expected petstore_simple.json.
  2. The output swagger.yaml is similar to the expected petstore_simple.yaml.

Development

Welcome your Star, make pull requests, report bugs, suggest ideas and discuss swagger-merger.

I would love to hear what you think about swagger-merger on issues page.

License

MIT

Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 18
Dependencies (2)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |