AFAIK in an array type can contain one type, if you want to have several types under the array, then you need to define another super-type and wrap the subtypes in it (maybe use an object type), as shown below. This limitation is due to the fact that swagger-2.0 does not support all the functions of json-schema.org, oneOf , anyOf , allOf , etc. Some of them.
But you can use a third-party extension available with swagger-2.0. If you can name the key with x- , then you can include these oneOf as x-oneOf when analyzing the circuit you are doing, using the json-schema parser along with the smagger parser.
One such example is given below,
Json-schema
{ "id": "http://some.site.somewhere/entry-schema#", "$schema": "http://json-schema.org/draft-04/schema#", "description": "schema for an fstab entry", "type": "object", "required": [ "storage" ], "properties": { "storage": { "type": "object", "oneOf": [ { "$ref": "#/definitions/diskDevice" } ] }, "deviceList": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/Device" } } }, "definitions": { "diskDevice": { "type": "object", "properties": { "label": { "type": "string" } }, "required": [ "label" ] }, "blockDevice": { "type": "object", "properties": { "blockId": { "type": "number" } }, "required": [ "blockId" ] }, "CharDevice": { "type": "object", "properties": { "charDeviceName": { "type": "string" } }, "required": [ "charDeviceName" ] }, "Device": { "type": "object", "oneOf": [ { "$ref": "#/definitions/diskDevice" }, { "$ref": "#/definitions/blockDevice" }, { "$ref": "#/definitions/CharDevice" } ] } } }
Data or payload
{ "storage": {"label": "adsf"}, "deviceList": [{"label": "asdf"}, {"blockId": 23}, {"charDeviceName": "asdf"}] }
Use this site to play with your sample data - http://www.jsonschemavalidator.net/
Pay attention to the deviceList property and how to create it. Hope this helps you.