将属性附加到Swagger $ ref

时间:2017-09-27 15:04:30

标签: swagger-2.0

大家好我试图将新属性添加到参考对象但我似乎无法在这里找到正确的答案我想要实现的目标和结果应该是下面的东西

{
  "results": {         
     "param1": "Add",
     "param2": {},
     "object1": "obj",
     "object2": "object"
  }
 }

以下是我的所作所为

responses:
    results:
        description: My description here
        schema:
            $ref: '#/definitions/Success'
definitions:
    Success:
       properties:
          param1:
            type: string
            default: Add
          param2:
            type: object
          $ref: '#/definitions/ObjectData'
    ObjectData:
       properties:
          object1:
             type: string
             default: obj
          object2:
             type: string
             default: object

1 个答案:

答案 0 :(得分:0)

如果我要做那个结果,这将是我的方法

resoponses:
    result:
    description: Description here
    schema:
        $ref: '#/definitions/Success'
properties:
Success:
    param1:
        type: string
        default: 'Add'
    param2:
        type: object
        properties:
            object1: 
                $ref: '#/definitions/object1'
            object2: 
                $ref: '#/definitions/object2'