0

I try to define an object array in swagger as response: /product: get: operationId: api.product.read_all tags: - Product summary: Read the Products description: Read the Products responses: 200: description: Successfully read product set operation schema: type: array items: oneOf: - $ref: '#/definitions/product'

But I find errors for those:

Schema error at paths['/product'].get.responses['200']
should NOT have additional properties
additionalProperty: description, schema
Jump to line 138
Schema error at paths['/product'].get.responses['200'].schema
should NOT have additional properties
additionalProperty: items
Jump to line 140
Schema error at paths['/product'].get.responses['200'].schema
should match exactly one schema in oneOf
Jump to line 140
Schema error at paths['/product'].get.responses['200'].schema.type
should be equal to one of the allowed values
allowedValues: file
Jump to line 141
Schema error at paths['/product'].get.responses['200'].schema.items
should NOT have additional properties
additionalProperty: anyOf
Jump to line 142
Schema error at paths['/product'].get.responses['200'].schema.items
should be array
Jump to line 142
Schema error at paths['/product'].get.responses['200'].schema.items
should match some schema in anyOf
Jump to line 142

I know I can use nested array with object like:

      schema:
        type: array
        items:
          properties:
            id:
              type: string
              description: Id of the cat
            name:
              type: string
              description: category name

But I wan to apply the internal array object ref to some objects I already defined. Can swagger do that, how to do that?

I use swagger 2.0

user504909
  • 9,119
  • 12
  • 60
  • 109
  • Just to clarify - do you need an array of `$ref`? Or an array of arrays of `$ref`? Or something else? – Helen Sep 28 '18 at 16:11
  • Possible duplicate of [Returning an array of objects that properly defines the SDK response](https://stackoverflow.com/questions/45175188/returning-an-array-of-objects-that-properly-defines-the-sdk-response) and [Return an array of object in SwaggerHub](https://stackoverflow.com/q/46167981/113116) – Helen Sep 28 '18 at 16:15
  • array of $ref. thanks – user504909 Sep 28 '18 at 23:02
  • Please see the ^^ linked Q&As. – Helen Oct 01 '18 at 10:10

0 Answers0