Page Contents
Home > @loopback/openapi-v3 > requestBody > array
requestBody.array() function
Define a requestBody of array
type.
Signature:
array: (itemSpec: SchemaObject | ReferenceObject, properties?: {
description?: string;
required?: boolean;
}) => (target: object, member: string, index: number) => void
Parameters
Parameter | Type | Description |
---|---|---|
itemSpec | SchemaObject | ReferenceObject | the full item object |
properties | { description?: string; required?: boolean; } | (Optional) The requestBody properties other than content |
Returns:
(target: object, member: string, index: number) => void
Example
export class MyController {
@post('/greet')
greet(@requestBody.array(
{type: 'string'},
{description: 'an array of names', required: false}
) names: string[]): string {
return `Hello, ${names}`;
}
}