swagger schema bundler
Project description
This is individual tool for bundling swagger definitions.
python3 only (python3.5+ is better)
setup
$ pip install "swagger-bundler[validation]"
or
$ pip install -e git+git@github.com:podhmo/swagger-bundler.git@master#egg=swagger_bundler
getting started
generating your config file
using it
0. generating your config file
swagger-bundler needs config file for using. so, at first, you must generate config file.
$ swagger-bundler config --init generate ~/venv/web/work/swagger-bundler.ini.
The stragegy of finding config file, following below.
Your current working directory is ~/venv/web/work/. then,
finds ~/venv/web/work/swagger-bundler.ini
finds ~/venv/web/swagger-bundler.ini
finds ~/venv/swagger-bundler.ini
finds ~/swagger-bundler.ini
Config file is not found, then, lookup ~/.swagger-bundle.ini.
1. how to use
Usage: swagger-bundler [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
bundle bundles many source files into single file
concat concatnates many swagger-definition files
config show config
validate validates via swagger-2.0 spec
Swagger-bundler has two commands.
bundle
concat
bundle
This is the main feature. bundling many source files into one single swagger-definition file.
$ swagger-bundler bundle <file.yaml>
The target file of swagger-bundler, it can use three special-marker.
x-bundler-namespace – when bundling, using this value as prefix string.
x-bundler-compose – importing from other files with namespace
x-bundler-concat – importing from other files without namespace
For example. the structure of current working directory is such as below,
. ├── main.yaml └── parts ├── common.yaml ├── x.yaml └── y.yaml
and the content of main.yaml is this.
x-bundler-namespace: ZZZ
x-bundler-compose:
- ./parts/x.yaml
- ./parts/y.yaml
x-bundler-concat:
- ./parts/common.yaml
And run it.
$ swagger-bundler bundle main.yaml
definitions in x.yaml, y.yaml are renamed (with namespace). (e.g. foo -> ZZZFoo)
definitions in common.yaml are not renamed. (e.g. bar -> bar)
The link of example.
qualified import.
x-bundler-namespace: O
x-bundler-compose:
- ../parts/x-state.yaml as X
- ../parts/y-state.yaml as Y
then
state of x-state.yaml is converting XState, eventually, OXState
state of y-state.yaml is converting YState, eventually, OYState
the link of example(qualified import)
concat
This is just concatnate files.
$ swagger-bundler concat [file1.yaml] [file2.yaml] ...
0.0.4
gentle warning message on FileNotFoundError
bundle command with –namespace option
qualified import (e.g. x-bundler-compose with ‘foo.yaml as F’)
0.0.3
adding readme and examples
support json format(input/output)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for swagger_bundler-0.0.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f279d48bc57bad94c7ae5846aedfa92f325f955edd9f3d1c7720096a7bb51ce |
|
MD5 | 6442112f10dab924ecfb9d8d5ed9f895 |
|
BLAKE2b-256 | a2b52eb75f097266e75a13875fed4331d2161bc623567d93ab90644128c13b9d |