相关疑难解决方法(0)

如何在几乎所有路径中复制粘贴3个通用错误响应?

我希望我的几乎所有路径都有以下3个通用错误响应.我怎么在Swagger中描述它,而不是在任何地方复制这些行?

    401:
      description: The requester is unauthorized.
      schema:
        $ref: '#/definitions/Error'
    500:
      description: "Something went wrong. It's server's fault."
      schema:
        $ref: '#/definitions/Error'
    503:
      description: Server is unavailable. Maybe there is maintenance?
      schema:
        $ref: '#/definitions/Error'
Run Code Online (Sandbox Code Playgroud)

我在请求中如何使用它的示例:

paths:
    /roles:
      get:
        summary: Roles
        description: |
          Returns all roles available for users.
        responses:
          200:
            description: An array with all roles.
            schema:
              type: array
              items:
                $ref: '#/definitions/Role'
          401:
            description: The requester is unauthorized.
            schema:
              $ref: '#/definitions/Error'
          500:
            description: "Something went wrong. It's server's fault."
            schema:
              $ref: …
Run Code Online (Sandbox Code Playgroud)

swagger openapi

10
推荐指数
1
解决办法
1939
查看次数

标签 统计

openapi ×1

swagger ×1