Search code examples
swaggerswagger-editor

How to declare a collection resource model in swagger 2.0?


I'm not sure about how I should do the declaration of the model for a collection resource on swagger.

The spec is missing some examples, so I'm guessing something like this:

  Class:
    required:
      - id
      - name
    properties:
      id:
        type: string
      name:
        type: string

  ClassList:
    type: array
    items:
      type:
        schema:
          $ref: Class

Then swagger editor shows the following generated documentation:

Print from swagger editor

Is it correct?


Solution

  • I think you got the answer to this one already, but even for the sake of documentation:

    ClassList:
      type: array
      items:
        $ref: #/definitions/Class