openapi规范扩展工具
项目描述
openapi-ext-tools
openapi规范扩展工具
将多个yaml文件打包成单个openapi.yaml
$ 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
如何使用
目前,仅支持将components对象打包。
tests/fixtures/simple/openapi.yaml
是openapi规范文件,部分模式定义在tests/fixtures/simple/schemas.yaml
中。
...
content:
application/json:
schema:
$ref: 'schemas.yaml#/components/schemas/User'
...
例如,User模式定义如下。
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
运行openapi-spec-cli
来打包yaml文件并创建单个openapi.yaml
。
$ 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
您可以在当前目录中确认bundled_openapi.yaml
。然后,schemas.yaml
中的所有模式都将移动到bundled_openapi.yaml
,并且$ref
字段也引用为本地引用。
...
content:
application/json:
schema:
$ref: '#/components/schemas/User'
...
项目详情
关闭
openapi-ext-tools-0.5.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d559128ded1d28d8a49e8a42189b0932807f74966bde331600f11890f3f5d487 |
|
MD5 | 1a9fd505a92d87fe2a5fb6b42a4683a4 |
|
BLAKE2b-256 | 87a7ba2d6ed13f4b187ea91504d65af69af2424fbc9d01dc5bcf4fc17287ac71 |
关闭
openapi_ext_tools-0.5.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c6ab3bbb4e90c49bb7bb9afef29c687cf8620caabd93a9a1c664139596dff4ad |
|
MD5 | fee5ef3736caa40012f495b4f79473b0 |
|
BLAKE2b-256 | 510cfd994c137416d0554093473598a0efd934674db534eb405120ea3e1df0cb |