Swaggertools

Load and merge nested configurations. It works with Python >= 3.4. Code source is published at https://lab.errorist.xyz/swagger/tools.

Installation

python -m pip install swaggertools

Quick Start

For example, these two files:

# swagger.yml
/paths:
  /users: {$ref: grafts/users.yml#/resources/collection}

# grafts/users.yml
/resources:
  collection:
    get:
      200:
    post:
      201:

Will be merged as:

# swagger.yml
/paths:
  /users:
    get:
      200:
    post:
      201:

Wich can be used to validate your API against editor.swagger.io.

Usage

As a command line:

swagger-tools /path/to/swagger.yml

Into python script:

from swaggertools import resolve

with open('/path/to/swagger.yml') as filehandler:
    app = resolve(filehandler)
print(app.to_yaml())