openapi规范的扩展工具

openapi-ext-tools的Python项目详细描述


OpenAPI扩展工具

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

如何使用

当前,捆绑仅支持组件对象。

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:objectproperties:id:type:integerformat:int64username:type:stringfirstName:type:stringlastName:type:stringbirthday:type:stringformat:dateemail:type:stringpassword:type:stringphone:type:stringuserStatus:type:integerdescription:User Statusformat: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'...

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
使用jaxb2annotateplugin和XJC工具的java自定义注释   java组织。xeustechnologies。jcl无法加载WstxInputFactory类   java JUnit在格式化字符串上比较失败   java Bukkit配置部分getKeys   如何关闭Java流?   java Struts2正则表达式配置   链式事务注释的java奇怪行为   java在两个JButton之间使用变量   java签署APK时内容会发生什么变化?   java LWJGL:Slick:3D世界中的绘图字体   如何分解Java数组?   在Java MySql中处理多个过滤器   java如何在Firebase数据库中跳过初始OnChildaded事件触发   java如何在PreviewView中使用CameraX?   在子类#中重写父类后访问父类原始方法的java已解决   java找不到类型的属性   游戏框架游戏!框架+Java