I have a return type which is an array of two elements. The first element is an integer and the second element is an array of dictionary with keys of sql_ident
In OpenAPI/Swagger 2.0, array items must be of the same type, so there is no way to precisely model your response. The most you can do is to use a typeless schema for items
, which means the items can be anything - numbers, objects, strings, etc. - but you can't specify the exact types for items.
definitions:
MyResponse:
type: array
items: {}
In OpenAPI 3.0, multi-type arrays can be described using oneOf
and anyOf
:
components:
schemas:
MyResponse:
type: array
items:
oneOf:
- type: integer
- type: array
items:
$ref: "#/components/schemas/MyDictionary"
MyDictionary:
type: object
properties:
sql_ident:
type: string
name:
type: string