Swagger API文档中是否有任何方法可以对一个组件下的所有API的多重响应进行汇总

时间:2019-01-07 15:40:19

标签: rest api swagger swagger-2.0 swagger-editor

我已经为API实现了Swagger文档。所有API都有多个响应代码,例如-000,103,130,178,158,因此大约有50个响应代码。

我已经为所有API实现了它们。但是,所有API中的所有这50个响应代码都是重复的。

我想知道是否有什么好办法。

下面是示例文档-

/endpoint:
    post:
      tags:
      - "tag1"
      summary: "My Request"
      description: "My Request description"
      operationId: "Op1"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
      - in: "body"
        name: "body"
        description: "My request"
        required: true
        schema:
          $ref: "#/definitions/MyRequest"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/MyResponse"
        000:
          description: "Approval"
        103:
          description: "Invalid status value"
        130:
          description: "Invalid Format"
        178:
          description: "Original request not found"
        158:
          description: "Invalid processing code"
        161:
          description: "Withdrawal limit exceeded"
        191:
          description: "Destination not available"
        194:
          description: "Duplicate transaction"
        196:
          description: "System error"
        201:
          description: "Contact Card Issuer"
        205: 
          description: "Contact Card Issuer2"
/endpoint2:
    post:
      tags:
      - "tag2"
      summary: "My Request2"
      description: "My Request description2"
      operationId: "Op2"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
      - in: "body"
        name: "body"
        description: "Myrequest"
        required: true
        schema:
          $ref: "#/definitions/MyRequest2"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/MyResponse2"
        000:
          description: "Approval"
        103:
          description: "Invalid status value"
        130:
          description: "Invalid Format"
        178:
          description: "Original request not found"
        158:
          description: "Invalid processing code"
        161:
          description: "Withdrawal limit exceeded"
        191:
          description: "Destination not available"
        194:
          description: "Duplicate transaction"
        196:
          description: "System error"
        201:
          description: "Contact Card Issuer"
        205: 
          description: "Contact Card Issuer2"

0 个答案:

没有答案
相关问题