How to represent the following response in a Swagger Doc definition

时间:2015-09-14 15:49:13

标签: swagger

I have several levels of nested objects in my response and I cannot change these. How can I represent these in a Swagger doc definition?

{
    name.response: {
        name.result: {
            name.row: [
                {
                    name.first: "John",
                    name.last: "Doe",
                }
            ]
        }
    }
}

Here is what I have right now:

person:
    type: object
    properties:
        name.first:
            type:string
        name.last
            type.string
name.result:
    type: object
    properties:
        name.row:
            type: array
            items:
              $ref: '#/definitions/person'
name.response:
    type: object
    properties:
      name.result:
        type: object
        description: Result

I don't think this is right because the Swagger Editor is warning me that the name.result definition is not being used.

1 个答案:

答案 0 :(得分:0)

Nevermind!

I figured it out:

name.response:
    type: object
    properties:
      name.result:
        type: object
        description: Result
        $ref: '#/definitions/name.result'

I had tried this already, but the warning that name.result wasn't being used was still there...

But then I refreshed the Swagger Editor and the warning went away.