@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
99 lines (56 loc) • 1.74 kB
Markdown
---
lang: en
title: 'API docs: openapi-v3.requestbody.array'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/openapi-v3
permalink: /doc/en/lb4/apidocs.openapi-v3.requestbody.array.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/openapi-v3](./openapi-v3.md) > [requestBody](./openapi-v3.requestbody.md) > [array](./openapi-v3.requestbody.array.md)
## requestBody.array() function
Define a requestBody of `array` type.
**Signature:**
```typescript
array: (itemSpec: SchemaObject | ReferenceObject, properties?: {
description?: string;
required?: boolean;
}) => (target: object, member: string, index: number) => void
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
itemSpec
</td><td markdown="1">
SchemaObject \| ReferenceObject
</td><td markdown="1">
the full item object
</td></tr>
<tr><td markdown="1">
properties
</td><td markdown="1">
{ description?: string; required?: boolean; }
</td><td markdown="1">
_(Optional)_ The requestBody properties other than `content`
</td></tr>
</tbody></table>
**Returns:**
(target: object, member: string, index: number) => void
## Example
```ts
export class MyController {
@post('/greet')
greet(@requestBody.array(
{type: 'string'},
{description: 'an array of names', required: false}
) names: string[]): string {
return `Hello, ${names}`;
}
}
```