首页 > 解决方案 > 根据其模式验证 swagger 规范的示例部分

问题描述

是否可以根据相应的模式验证example部分招摇文档?

我找到了用于验证模式本身的工具(如http://editor.swagger.ioswagger-cli等 - 但这只是 linting)和验证针对模式的请求/响应(如swagger-express-middlewareswagger-断言)。

但我想验证examples是否responsesdefinitions模式一致。例如:

swagger: '2.0'
paths:
  /test:
    get:
      description: test endpoint
      produces:
        - application/json
      responses:
        200:
          description: OK
          schema:
            type: object
            properties:
              name:
                type: string
              id:
                type: integer
            example:
              name: 13
              id: some string

即使example包含不正确的结构,对于所有这些工具似乎都是“正确的”。

有没有可以做到这一点的工具?

标签: validationswaggerschemaopenapi

解决方案


推荐阅读