You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/guides/faker.mdx
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,13 +108,13 @@ Requires `output.schemas` to be configured (the consolidated file is written int
108
108
109
109
### Array Item Factories
110
110
111
-
Set `arrayItems: true` to emit reusable mock factories for **object-like array item schemas** found in operation responses. This covers array elements that are inlined in the response body (not just entries under `components/schemas`):
111
+
Set `arrayItems: true`on any mock generator entry to emit reusable mock factories for **object-like array item schemas** found in operation responses. This covers array elements that are inlined in the response body (not just entries under `components/schemas`). Works with both `faker` and `msw` generators:
112
112
113
113
```ts title="orval.config.ts"
114
114
mock: {
115
115
generators: [
116
116
{
117
-
type: 'faker',
117
+
type: 'msw',
118
118
arrayItems: true,
119
119
},
120
120
],
@@ -146,7 +146,7 @@ When `schemas: true` is also enabled, `$ref` items delegate to the consolidated
146
146
147
147
## Options
148
148
149
-
Set faker-specific options on the generator entry:
149
+
Shared mock options apply to both `faker` and `msw` generator entries. Faker-only options are listed separately below.
150
150
151
151
```ts title="orval.config.ts"
152
152
mock: {
@@ -157,6 +157,7 @@ mock: {
157
157
generateEachHttpStatus: true,
158
158
locale: 'en_GB',
159
159
preferredContentType: 'application/json',
160
+
arrayItems: true,
160
161
},
161
162
],
162
163
}
@@ -168,9 +169,14 @@ mock: {
168
169
|`generateEachHttpStatus`|`boolean`|`false`| Emit a separate factory per HTTP status code defined in the spec (not just the success response). |
169
170
|`locale`|`keyof typeof allLocales`| — | Faker locale. Switches the import to `@faker-js/faker/locale/<x>` (e.g. `'en_GB'`, `'fr'`, `'ja'`). |
170
171
|`preferredContentType`|`string`| — | When an operation has multiple response content types, mock the one matching this MIME type. |
172
+
|`arrayItems`|`boolean`|`false`| Emit reusable mock factories for object-like array item schemas in operation responses. See [Array Item Factories](#array-item-factories). |
173
+
174
+
Faker-only options:
175
+
176
+
| Option | Type | Default | Description |
177
+
|---|---|---|---|
171
178
|`schemas`|`boolean`|`false`| Emit a consolidated `get<SchemaName>Mock` factory per `components/schemas` entry into `<schemas-dir>/index.faker.ts`. See [Schema Factories](#schema-factories). |
172
179
|`operationResponses`|`boolean`|`true`| Emit per-operation `get<OperationId>ResponseMock` factories. Set to `false` (typically with `schemas: true`) to skip operation-level factories. |
173
-
|`arrayItems`|`boolean`|`false`| Emit reusable mock factories for object-like array item schemas in operation responses. See [Array Item Factories](#array-item-factories). |
Copy file name to clipboardExpand all lines: docs/content/docs/guides/msw.mdx
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,21 @@ export default defineConfig({
95
95
96
96
`preferredContentType` accepts common MIME literals and any custom string (via a loose `(string & {})` fallback), so vendor-specific types are supported too.
97
97
98
+
### Array Item Factories
99
+
100
+
Set `arrayItems: true` on the MSW generator entry to emit reusable mock factories for object-like array item schemas in operation responses (for example, `getTenantResponseModelDtoMock` for `value: TenantResponseModelDto[]`). The factories are written into the same `.msw.ts` / endpoints mock file as the handlers and response mocks. See the [Faker guide — Array Item Factories](/docs/guides/faker#array-item-factories) for configuration details and supported shapes.
101
+
102
+
```ts title="orval.config.ts"
103
+
mock: {
104
+
generators: [
105
+
{
106
+
type: 'msw',
107
+
arrayItems: true,
108
+
},
109
+
],
110
+
}
111
+
```
112
+
98
113
### 2. Aggregated Handlers
99
114
100
115
Functions that combine all handlers for easy setup:
0 commit comments