···11+---
22+'@hey-api/openapi-ts': minor
33+---
44+55+feat: upgraded input filters
66+77+### Upgraded input filters
88+99+Input filters now avoid generating invalid output without requiring you to specify every missing schema as in the previous releases. As part of this release, we changed the way filters are configured and removed the support for regular expressions. Let us know if regular expressions are still useful for you and want to bring them back!
1010+1111+::: code-group
1212+1313+```js [include]
1414+export default {
1515+ input: {
1616+ // match only the schema named `foo` and `GET` operation for the `/api/v1/foo` path
1717+ filters: {
1818+ operations: {
1919+ include: ['GET /api/v1/foo'], // [!code ++]
2020+ },
2121+ schemas: {
2222+ include: ['foo'], // [!code ++]
2323+ },
2424+ },
2525+ include: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code --]
2626+ path: 'https://get.heyapi.dev/hey-api/backend',
2727+ },
2828+ output: 'src/client',
2929+ plugins: ['@hey-api/client-fetch'],
3030+};
3131+```
3232+3333+```js [exclude]
3434+export default {
3535+ input: {
3636+ // match everything except for the schema named `foo` and `GET` operation for the `/api/v1/foo` path
3737+ exclude: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code --]
3838+ filters: {
3939+ operations: {
4040+ exclude: ['GET /api/v1/foo'], // [!code ++]
4141+ },
4242+ schemas: {
4343+ exclude: ['foo'], // [!code ++]
4444+ },
4545+ },
4646+ path: 'https://get.heyapi.dev/hey-api/backend',
4747+ },
4848+ output: 'src/client',
4949+ plugins: ['@hey-api/client-fetch'],
5050+};
5151+```
5252+5353+:::
+180-5
docs/openapi-ts/configuration.md
···193193194194## Filters
195195196196-If you work with large specifications and want to generate output from their subset, you can use regular expressions to select the relevant definitions. Set `input.include` to match resource references to be included or `input.exclude` to match resource references to be excluded. When both regular expressions match the same definition, `input.exclude` takes precedence over `input.include`.
196196+If you work with large specifications and want to generate output from their subset, you can use `input.filters` to select the relevant resources.
197197+198198+### Operations
199199+200200+Set `include` to match operations to be included or `exclude` to match operations to be excluded. When both rules match the same operation, `exclude` takes precedence over `include`.
201201+202202+::: code-group
203203+204204+```js [include]
205205+export default {
206206+ input: {
207207+ filters: {
208208+ operations: {
209209+ include: ['GET /api/v1/foo'], // [!code ++]
210210+ },
211211+ },
212212+ path: 'https://get.heyapi.dev/hey-api/backend',
213213+ },
214214+ output: 'src/client',
215215+ plugins: ['@hey-api/client-fetch'],
216216+};
217217+```
218218+219219+```js [exclude]
220220+export default {
221221+ input: {
222222+ filters: {
223223+ operations: {
224224+ exclude: ['GET /api/v1/foo'], // [!code ++]
225225+ },
226226+ },
227227+ path: 'https://get.heyapi.dev/hey-api/backend',
228228+ },
229229+ output: 'src/client',
230230+ plugins: ['@hey-api/client-fetch'],
231231+};
232232+```
233233+234234+:::
235235+236236+### Tags
237237+238238+Set `include` to match tags to be included or `exclude` to match tags to be excluded. When both rules match the same tag, `exclude` takes precedence over `include`.
239239+240240+::: code-group
241241+242242+```js [include]
243243+export default {
244244+ input: {
245245+ filters: {
246246+ tags: {
247247+ include: ['v2'], // [!code ++]
248248+ },
249249+ },
250250+ path: 'https://get.heyapi.dev/hey-api/backend',
251251+ },
252252+ output: 'src/client',
253253+ plugins: ['@hey-api/client-fetch'],
254254+};
255255+```
256256+257257+```js [exclude]
258258+export default {
259259+ input: {
260260+ filters: {
261261+ tags: {
262262+ exclude: ['v1'], // [!code ++]
263263+ },
264264+ },
265265+ path: 'https://get.heyapi.dev/hey-api/backend',
266266+ },
267267+ output: 'src/client',
268268+ plugins: ['@hey-api/client-fetch'],
269269+};
270270+```
271271+272272+:::
273273+274274+### Deprecated
275275+276276+You can filter out deprecated resources by setting `deprecated` to `false`.
277277+278278+```js
279279+export default {
280280+ input: {
281281+ filters: {
282282+ deprecated: false, // [!code ++]
283283+ },
284284+ path: 'https://get.heyapi.dev/hey-api/backend',
285285+ },
286286+ output: 'src/client',
287287+ plugins: ['@hey-api/client-fetch'],
288288+};
289289+```
290290+291291+### Schemas
292292+293293+Set `include` to match schemas to be included or `exclude` to match schemas to be excluded. When both rules match the same schema, `exclude` takes precedence over `include`.
197294198295::: code-group
199296200297```js [include]
201298export default {
202299 input: {
203203- // match only the schema named `foo` and `GET` operation for the `/api/v1/foo` path // [!code ++]
204204- include: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code ++]
300300+ filters: {
301301+ schemas: {
302302+ include: ['Foo'], // [!code ++]
303303+ },
304304+ },
205305 path: 'https://get.heyapi.dev/hey-api/backend',
206306 },
207307 output: 'src/client',
···212312```js [exclude]
213313export default {
214314 input: {
215215- // match everything except for the schema named `foo` and `GET` operation for the `/api/v1/foo` path // [!code ++]
216216- exclude: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code ++]
315315+ filters: {
316316+ schemas: {
317317+ exclude: ['Foo'], // [!code ++]
318318+ },
319319+ },
217320 path: 'https://get.heyapi.dev/hey-api/backend',
218321 },
219322 output: 'src/client',
···222325```
223326224327:::
328328+329329+### Request Bodies
330330+331331+Set `include` to match request bodies to be included or `exclude` to match request bodies to be excluded. When both rules match the same request body, `exclude` takes precedence over `include`.
332332+333333+::: code-group
334334+335335+```js [include]
336336+export default {
337337+ input: {
338338+ filters: {
339339+ requestBodies: {
340340+ include: ['Payload'], // [!code ++]
341341+ },
342342+ },
343343+ path: 'https://get.heyapi.dev/hey-api/backend',
344344+ },
345345+ output: 'src/client',
346346+ plugins: ['@hey-api/client-fetch'],
347347+};
348348+```
349349+350350+```js [exclude]
351351+export default {
352352+ input: {
353353+ filters: {
354354+ requestBodies: {
355355+ exclude: ['Payload'], // [!code ++]
356356+ },
357357+ },
358358+ path: 'https://get.heyapi.dev/hey-api/backend',
359359+ },
360360+ output: 'src/client',
361361+ plugins: ['@hey-api/client-fetch'],
362362+};
363363+```
364364+365365+:::
366366+367367+### Orphaned resources
368368+369369+If you only want to exclude orphaned resources, set `orphans` to `false`. This is the default value when combined with any other filters. If this isn't the desired behavior, you may want to set `orphans` to `true` to always preserve unused resources.
370370+371371+```js
372372+export default {
373373+ input: {
374374+ filters: {
375375+ orphans: false, // [!code ++]
376376+ },
377377+ path: 'https://get.heyapi.dev/hey-api/backend',
378378+ },
379379+ output: 'src/client',
380380+ plugins: ['@hey-api/client-fetch'],
381381+};
382382+```
383383+384384+### Order
385385+386386+For performance reasons, we don't preserve the original order when filtering out resources. If maintaining the original order is important to you, set `preserveOrder` to `true`.
387387+388388+```js
389389+export default {
390390+ input: {
391391+ filters: {
392392+ preserveOrder: true, // [!code ++]
393393+ },
394394+ path: 'https://get.heyapi.dev/hey-api/backend',
395395+ },
396396+ output: 'src/client',
397397+ plugins: ['@hey-api/client-fetch'],
398398+};
399399+```
225400226401## Watch Mode
227402
+50
docs/openapi-ts/migrating.md
···27272828This config option is deprecated and will be removed.
29293030+## v0.68.0
3131+3232+### Upgraded input filters
3333+3434+Input filters now avoid generating invalid output without requiring you to specify every missing schema as in the previous releases. As part of this release, we changed the way filters are configured and removed the support for regular expressions. Let us know if regular expressions are still useful for you and want to bring them back!
3535+3636+::: code-group
3737+3838+```js [include]
3939+export default {
4040+ input: {
4141+ // match only the schema named `foo` and `GET` operation for the `/api/v1/foo` path
4242+ filters: {
4343+ operations: {
4444+ include: ['GET /api/v1/foo'], // [!code ++]
4545+ },
4646+ schemas: {
4747+ include: ['foo'], // [!code ++]
4848+ },
4949+ },
5050+ include: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code --]
5151+ path: 'https://get.heyapi.dev/hey-api/backend',
5252+ },
5353+ output: 'src/client',
5454+ plugins: ['@hey-api/client-fetch'],
5555+};
5656+```
5757+5858+```js [exclude]
5959+export default {
6060+ input: {
6161+ // match everything except for the schema named `foo` and `GET` operation for the `/api/v1/foo` path
6262+ exclude: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code --]
6363+ filters: {
6464+ operations: {
6565+ exclude: ['GET /api/v1/foo'], // [!code ++]
6666+ },
6767+ schemas: {
6868+ exclude: ['foo'], // [!code ++]
6969+ },
7070+ },
7171+ path: 'https://get.heyapi.dev/hey-api/backend',
7272+ },
7373+ output: 'src/client',
7474+ plugins: ['@hey-api/client-fetch'],
7575+};
7676+```
7777+7878+:::
7979+3080## v0.67.0
31813282### Respecting `moduleResolution` value in `tsconfig.json`
···33import { sanitizeNamespaceIdentifier } from '../../common/parser/sanitize';
44import type { State } from '../types/state';
5566+export const httpMethods = [
77+ 'delete',
88+ 'get',
99+ 'head',
1010+ 'options',
1111+ 'patch',
1212+ 'post',
1313+ 'put',
1414+ 'trace',
1515+] as const;
1616+617/**
718 * Verifies that operation ID is unique. For now, we only warn when this isn't
819 * true as people like to not follow this part of the specification. In the
+96-22
packages/openapi-ts/src/types/config.d.ts
···3939 */
4040 commit_sha?: string;
4141 /**
4242- * Prevent parts matching the regular expression(s) from being processed.
4343- * You can select both operations and components by reference within
4444- * the bundled input.
4545- *
4646- * In case of conflicts, `exclude` takes precedence over `include`.
4747- *
4848- * @example
4949- * operation: '^#/paths/api/v1/foo/get$'
5050- * schema: '^#/components/schemas/Foo$'
5151- * deprecated: '@deprecated'
5252- */
5353- exclude?: ReadonlyArray<string> | string;
5454- /**
5542 * You pass any valid Fetch API options to the request for fetching your
5643 * specification. This is useful if your file is behind auth for example.
5744 */
5845 fetch?: RequestInit;
5946 /**
6060- * Process only parts matching the regular expression(s). You can select both
6161- * operations and components by reference within the bundled input.
6262- *
6363- * In case of conflicts, `exclude` takes precedence over `include`.
6464- *
6565- * @example
6666- * operation: '^#/paths/api/v1/foo/get$'
6767- * schema: '^#/components/schemas/Foo$'
4747+ * Filters can be used to select a subset of your input before it's processed
4848+ * by plugins.
6849 */
6969- include?: ReadonlyArray<string> | string;
5050+ filters?: {
5151+ /**
5252+ * Include deprecated resources in the output?
5353+ *
5454+ * @default true
5555+ */
5656+ deprecated?: boolean;
5757+ operations?: {
5858+ /**
5959+ * Prevent operations matching the `exclude` filters from being processed.
6060+ *
6161+ * In case of conflicts, `exclude` takes precedence over `include`.
6262+ *
6363+ * @example ['GET /api/v1/foo']
6464+ */
6565+ exclude?: ReadonlyArray<string>;
6666+ /**
6767+ * Process only operations matching the `include` filters.
6868+ *
6969+ * In case of conflicts, `exclude` takes precedence over `include`.
7070+ *
7171+ * @example ['GET /api/v1/foo']
7272+ */
7373+ include?: ReadonlyArray<string>;
7474+ };
7575+ /**
7676+ * Keep reusable components without any references in the output? By
7777+ * default, we exclude orphaned resources.
7878+ *
7979+ * @default false
8080+ */
8181+ orphans?: boolean;
8282+ /**
8383+ * Should we preserve the key order when overwriting your input? This
8484+ * option is disabled by default to improve performance.
8585+ *
8686+ * @default false
8787+ */
8888+ preserveOrder?: boolean;
8989+ requestBodies?: {
9090+ /**
9191+ * Prevent request bodies matching the `exclude` filters from being processed.
9292+ *
9393+ * In case of conflicts, `exclude` takes precedence over `include`.
9494+ *
9595+ * @example ['Foo']
9696+ */
9797+ exclude?: ReadonlyArray<string>;
9898+ /**
9999+ * Process only request bodies matching the `include` filters.
100100+ *
101101+ * In case of conflicts, `exclude` takes precedence over `include`.
102102+ *
103103+ * @example ['Foo']
104104+ */
105105+ include?: ReadonlyArray<string>;
106106+ };
107107+ schemas?: {
108108+ /**
109109+ * Prevent schemas matching the `exclude` filters from being processed.
110110+ *
111111+ * In case of conflicts, `exclude` takes precedence over `include`.
112112+ *
113113+ * @example ['Foo']
114114+ */
115115+ exclude?: ReadonlyArray<string>;
116116+ /**
117117+ * Process only schemas matching the `include` filters.
118118+ *
119119+ * In case of conflicts, `exclude` takes precedence over `include`.
120120+ *
121121+ * @example ['Foo']
122122+ */
123123+ include?: ReadonlyArray<string>;
124124+ };
125125+ tags?: {
126126+ /**
127127+ * Prevent tags matching the `exclude` filters from being processed.
128128+ *
129129+ * In case of conflicts, `exclude` takes precedence over `include`.
130130+ *
131131+ * @example ['foo']
132132+ */
133133+ exclude?: ReadonlyArray<string>;
134134+ /**
135135+ * Process only tags matching the `include` filters.
136136+ *
137137+ * In case of conflicts, `exclude` takes precedence over `include`.
138138+ *
139139+ * @example ['foo']
140140+ */
141141+ include?: ReadonlyArray<string>;
142142+ };
143143+ };
70144 /**
71145 * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
72146 *