小编zod*_*i91的帖子

如何在 Swagger 中引用包含响应示例的外部 JSON 文件?

在我的 Swagger 规范文件中,我想返回示例响应,因为我可以examples在响应中添加它。但这使得我的规范文件相当大并且容易出错。有没有办法引用包含示例对象的 JSON 的文件?

我尝试了类似下面的方法,但似乎不起作用。

get:
  tags:
    - businesses
  summary: Get Taxable Entities details 
  description: ''
  operationId: getTaxableEntities
  produces:
    - application/json
  parameters:
    - name: business_id
      in: path
      required: true
      type: integer
      format: int32
    - name: gstIn
      in: query
      required: false
      type: integer
      format: int32
  responses:
    '200':
      description: Taxable Entities
      schema:
        type: file
        default:
          $ref: taxable_entity_example.json
    '401':
      description: You are not authorised to view this Taxable Entity
Run Code Online (Sandbox Code Playgroud)

swagger swagger-2.0 openapi

5
推荐指数
1
解决办法
6286
查看次数

标签 统计

openapi ×1

swagger ×1

swagger-2.0 ×1