4

我想通过我的 API 从我的数据库中请求一个表。但是,我不知道该表将有多少列,或者它将包含什么。如何在 Swagger 中指定这个?这就是我想做的:

paths:
  /reports/{id}:
    get:
      summary: Detailed results
      description: filler
      parameters:
        - name: id
          in: path
          description: filler
          required: true
          type: integer
          format: int64
      responses:
        200:
          description: OK
          schema:
            type: array
            items: 
              $ref: '#/definitions/DynamicObject'
definitions:
  DynamicObject:
    type: object
    properties:
      **$IDONTKNOWWHATTODO**

关于如何定义没有特定参数的 JSON 对象的任何想法?

4

1 回答 1

8

要描述任意 JSON,请使用"type": "object". 以下是 JSON 格式的示例:

    "responses": {
      "200": {
        "description": "successful operation",
        "schema": {
          "type": "object"
        }
      }
    },
于 2016-03-04T09:02:39.987 回答