Array type can contain different scalar types, objects and even inner arrays. The most simple types can be used almost everywhere, the more complex types can't.
- Query parameters don't support array of arrays or array of objects but supports arrays of scalar types;
- Path parameters don't support arrays of any kind;
- Header parameters don't support arrays of any kind;
- Cookie parameters don't support arrays of any kind;
- Body content does not support arrays at top level (for security reasons), but support it inside objects;
// a simple example
Types.Array({ arrayType: Types.String() })
// a more complete declaration
Types.Array({
arrayType: Types.String(),
description: "String array",
minLength: 10,
maxLength: 20,
required: true,
default: ["string"], // default value, if none provided
example: ["string"], // example data
nullable: true,
isParameter: true, // optional, make this a named parameter, check documentation for parameters
}) // a simple example
Types.Array({
arrayType: Types.Object({
properties: {
test: Types.String(),
},
}),
})
// a more complete declaration
Types.Array({
arrayType: Types.Object({
properties: {
name: Types.String(),
},
}),
description: "Array of objects",
required: true,
minLength: 1,
maxLength: 10,
default: [{name: "John Doe"}], // default value, if none provided
example: [{name: "John Doe"}], // example data
nullable: true
})
// a simple example
Types.Array({
arrayType: Types.Array({
arrayType: Types.String()
}),
})
// a more complete declaration
Types.Array({
arrayType: Types.Array({
arrayType: Types.String()
}),
description: "Array of strings",
required: true,
minLength: 1,
maxLength: 10,
default: "some string", // default value, if none provided
example: "some string", // example data
nullable: true
})