# openapi-ext-tools
extended tools for openapi spec
## bundle multiple yaml files into single openapi.yaml
```bash
$ openapi-spec-cli --help
usage: openapi-spec-cli [-h] --spec-path SPEC_PATH
[--bundled-spec-path BUNDLED_SPEC_PATH] [--verbose]
optional arguments:
-h, --help show this help message and exit
--spec-path SPEC_PATH
set path to openapi spec file
--bundled-spec-path BUNDLED_SPEC_PATH
set path to bundled spec file
--verbose set verbose mode
```
### How to use
**Currently, bundling only support components object.**
The `tests/fixtures/simple/openapi.yaml` is openapi specification file and a part of schemas is defined in `tests/fixtures/simple/schemas.yaml`.
```yaml
...
content:
application/json:
schema:
$ref: 'schemas.yaml#/components/schemas/User'
...
```
For example, *User* schema is defined like this.
```yaml
components:
schemas:
User:
type: object
properties:
id:
type: integer
format: int64
username:
type: string
firstName:
type: string
lastName:
type: string
birthday:
type: string
format: date
email:
type: string
password:
type: string
phone:
type: string
userStatus:
type: integer
description: User Status
format: int32
```
Run `openapi-spec-cli` to bundle yaml files and create single `openapi.yaml`.
```bash
$ openapi-spec-cli --spec-path tests/fixtures/simple/openapi.yaml
2019-05-11 11:56:12,337 openapi.spec.ext INFO wrote bundled spec file to "bundled_openapi.yaml"
2019-05-11 11:56:12,402 openapi.spec.ext INFO validating bundled spec: OK
```
You can confirm `bundled_openapi.yaml` in current directory. Then, all schemas in `schemas.yaml` are moved to `bundled_openapi.yaml` and a `$ref` field also reffers as Local Reference.
```yaml
...
content:
application/json:
schema:
$ref: '#/components/schemas/User'
...
```
Raw data
{
"_id": null,
"home_page": "https://github.com/t2y/openapi-ext-tools",
"name": "openapi-ext-tools",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Tetsuya Morimoto",
"author_email": "tetsuya.morimoto@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/87/a7/ba2d6ed13f4b187ea91504d65af69af2424fbc9d01dc5bcf4fc17287ac71/openapi-ext-tools-0.5.1.tar.gz",
"platform": "any",
"description": "# openapi-ext-tools\n\nextended tools for openapi spec\n\n## bundle multiple yaml files into single openapi.yaml\n\n```bash\n$ openapi-spec-cli --help\nusage: openapi-spec-cli [-h] --spec-path SPEC_PATH\n [--bundled-spec-path BUNDLED_SPEC_PATH] [--verbose]\n\noptional arguments:\n -h, --help show this help message and exit\n --spec-path SPEC_PATH\n set path to openapi spec file\n --bundled-spec-path BUNDLED_SPEC_PATH\n set path to bundled spec file\n --verbose set verbose mode\n```\n\n### How to use\n\n**Currently, bundling only support components object.**\n\nThe `tests/fixtures/simple/openapi.yaml` is openapi specification file and a part of schemas is defined in `tests/fixtures/simple/schemas.yaml`.\n\n```yaml\n...\n content:\n application/json:\n schema:\n $ref: 'schemas.yaml#/components/schemas/User'\n...\n```\n\nFor example, *User* schema is defined like this.\n\n```yaml\ncomponents:\n schemas:\n User:\n type: object\n properties:\n id:\n type: integer\n format: int64\n username:\n type: string\n firstName:\n type: string\n lastName:\n type: string\n birthday:\n type: string\n format: date\n email:\n type: string\n password:\n type: string\n phone:\n type: string\n userStatus:\n type: integer\n description: User Status\n format: int32\n```\n\nRun `openapi-spec-cli` to bundle yaml files and create single `openapi.yaml`.\n\n```bash\n$ openapi-spec-cli --spec-path tests/fixtures/simple/openapi.yaml\n2019-05-11 11:56:12,337 openapi.spec.ext INFO wrote bundled spec file to \"bundled_openapi.yaml\"\n2019-05-11 11:56:12,402 openapi.spec.ext INFO validating bundled spec: OK\n```\n\nYou can confirm `bundled_openapi.yaml` in current directory. Then, all schemas in `schemas.yaml` are moved to `bundled_openapi.yaml` and a `$ref` field also reffers as Local Reference.\n\n```yaml\n...\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/User'\n...\n```\n\n\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Extended tools for openapi spec",
"version": "0.5.1",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "fee5ef3736caa40012f495b4f79473b0",
"sha256": "c6ab3bbb4e90c49bb7bb9afef29c687cf8620caabd93a9a1c664139596dff4ad"
},
"downloads": -1,
"filename": "openapi_ext_tools-0.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fee5ef3736caa40012f495b4f79473b0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10600,
"upload_time": "2022-12-09T06:56:09",
"upload_time_iso_8601": "2022-12-09T06:56:09.485396Z",
"url": "https://files.pythonhosted.org/packages/51/0c/fd994c137416d0554093473598a0efd934674db534eb405120ea3e1df0cb/openapi_ext_tools-0.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "1a9fd505a92d87fe2a5fb6b42a4683a4",
"sha256": "d559128ded1d28d8a49e8a42189b0932807f74966bde331600f11890f3f5d487"
},
"downloads": -1,
"filename": "openapi-ext-tools-0.5.1.tar.gz",
"has_sig": false,
"md5_digest": "1a9fd505a92d87fe2a5fb6b42a4683a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12227,
"upload_time": "2022-12-09T06:56:12",
"upload_time_iso_8601": "2022-12-09T06:56:12.017570Z",
"url": "https://files.pythonhosted.org/packages/87/a7/ba2d6ed13f4b187ea91504d65af69af2424fbc9d01dc5bcf4fc17287ac71/openapi-ext-tools-0.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-09 06:56:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "t2y",
"github_project": "openapi-ext-tools",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "openapi-ext-tools"
}