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
TODO: uncomment after c12 supports multiple configs
77
-
see https://github.com/unjs/c12/issues/92
78
-
-->
79
-
<!-- ### Multiple Clients
80
-
81
-
If you want to generate multiple clients with a single `openapi-ts` command, you can provide an array of configuration objects.
82
-
83
-
```js
84
-
import { defineConfig } from '@hey-api/openapi-ts';
85
-
86
-
export default defineConfig([
87
-
{
88
-
input: 'path/to/openapi_one.json',
89
-
output: 'src/client_one',
90
-
plugins: ['legacy/fetch'],
91
-
},
92
-
{
93
-
input: 'path/to/openapi_two.json',
94
-
output: 'src/client_two',
95
-
plugins: ['legacy/axios'],
96
-
},
97
-
])
98
-
``` -->
99
-
100
41
## Input
101
42
102
43
You must provide an input so we can load your OpenAPI specification.
@@ -197,6 +138,108 @@ Plugins are responsible for generating artifacts from your input. By default, He
197
138
198
139
You can learn more on the [Output](/openapi-ts/output) page.
199
140
141
+
## Advanced
142
+
143
+
More complex configuration scenarios can be handled by providing an array of inputs, outputs, or configurations.
144
+
145
+
### Multiple jobs
146
+
147
+
Throughout this documentation, we generally reference single job configurations. However, you can easily run multiple jobs by providing an array of configuration objects.
148
+
149
+
::: code-group
150
+
151
+
```js [config]
152
+
exportdefault [
153
+
{
154
+
input:'foo.yaml',
155
+
output:'src/foo',
156
+
},
157
+
{
158
+
input:'bar.yaml',
159
+
output:'src/bar',
160
+
},
161
+
];
162
+
```
163
+
164
+
```md [example]
165
+
src/
166
+
├── foo/
167
+
│ ├── client/
168
+
│ ├── core/
169
+
│ ├── client.gen.ts
170
+
│ ├── index.ts
171
+
│ ├── sdk.gen.ts
172
+
│ └── types.gen.ts
173
+
└── bar/
174
+
├── client/
175
+
├── core/
176
+
├── client.gen.ts
177
+
├── index.ts
178
+
├── sdk.gen.ts
179
+
└── types.gen.ts
180
+
```
181
+
182
+
:::
183
+
184
+
### Job matrix
185
+
186
+
Reusing configuration across multiple jobs is possible by defining a job matrix. You can create a job matrix by providing `input` and `output` arrays of matching length.
187
+
188
+
::: code-group
189
+
190
+
```js [config]
191
+
exportdefault {
192
+
input: ['foo.yaml', 'bar.yaml'],
193
+
output: ['src/foo', 'src/bar'],
194
+
};
195
+
```
196
+
197
+
```md [example]
198
+
src/
199
+
├── foo/
200
+
│ ├── client/
201
+
│ ├── core/
202
+
│ ├── client.gen.ts
203
+
│ ├── index.ts
204
+
│ ├── sdk.gen.ts
205
+
│ └── types.gen.ts
206
+
└── bar/
207
+
├── client/
208
+
├── core/
209
+
├── client.gen.ts
210
+
├── index.ts
211
+
├── sdk.gen.ts
212
+
└── types.gen.ts
213
+
```
214
+
215
+
:::
216
+
217
+
### Merging inputs
218
+
219
+
You can merge inputs by defining multiple inputs and a single output.
220
+
221
+
::: code-group
222
+
223
+
```js [config]
224
+
exportdefault {
225
+
input: ['foo.yaml', 'bar.yaml'],
226
+
output:'src/client',
227
+
};
228
+
```
229
+
230
+
```md [example]
231
+
src/
232
+
└── client/
233
+
├── client/
234
+
├── core/
235
+
├── client.gen.ts
236
+
├── index.ts
237
+
├── sdk.gen.ts
238
+
└── types.gen.ts
239
+
```
240
+
241
+
:::
242
+
200
243
## API
201
244
202
245
You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/types/config.d.ts) interface.
Copy file name to clipboardExpand all lines: docs/openapi-ts/configuration/input.md
+3-15Lines changed: 3 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ You must provide an input so we can load your OpenAPI specification.
9
9
10
10
## Input
11
11
12
-
The input can be a string path, URL, [API registry](#api-registry), an object containing any of these, or an object representing an OpenAPI specification. You can also pass an array of inputs to merge multiple specifications. Hey API supports all valid OpenAPI versions and file formats.
12
+
The input can be a string path, URL, [API registry](#api-registry), an object containing any of these, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.
13
13
14
14
::: code-group
15
15
@@ -52,22 +52,10 @@ export default {
52
52
```
53
53
<!-- prettier-ignore-end -->
54
54
55
-
```js [array]
56
-
exportdefault {
57
-
input: [
58
-
// [!code ++]
59
-
'hey-api/backend', // [!code ++]
60
-
'./overrides/openapi.yaml', // [!code ++]
61
-
], // [!code ++]
62
-
};
63
-
// When you pass multiple inputs as an array, `@hey-api/openapi-ts` bundles them into a single resolved OpenAPI
64
-
// document. To avoid name collisions between files, component names may be prefixed with the input file’s base
65
-
// name when needed (for example, `users.yaml` ➜ `users.*`). References across files are resolved, and
66
-
// later inputs in the array can override earlier ones on conflict.
67
-
```
68
-
69
55
:::
70
56
57
+
You can learn more about complex use cases in the [Advanced](/openapi-ts/configuration#advanced) section.
58
+
71
59
::: info
72
60
If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/openapi-ts/issues/276#issuecomment-2043143501) in your environment.
0 commit comments