2016-03-03 39 views
4

我想通过我的API从我的数据库请求一个表。但是,我不知道表格将包含多少个列,或者包含哪些列。我怎样才能在Swagger中指定这个?这是我想要做的:如何在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对象的任何想法?

回答

8

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

"responses": { 
     "200": { 
     "description": "successful operation", 
     "schema": { 
      "type": "object" 
     } 
     } 
    },