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
feat(core): add tagsSplitDeduplication option for barrel + shared type extraction
Add a new `tagsSplitDeduplication` output option (default: false) that
extracts shared infrastructure types (e.g. HTTPStatusCode*) emitted by
client header builders into a `common-types.ts` file, then generates a
barrel `index.ts` with named re-exports for public types.
When enabled (with `indexFiles: true`):
- Shared types are collected across all per-tag files and deduplicated
- Extracted to `<commonTypesFileName>.ts` (default: 'common-types')
- Per-tag files import shared types from the common file
- Barrel uses named re-exports for exported types + `export *` for tags
When disabled (default): behavior is identical to before — shared types
are inlined per-tag, no barrel, no extraction.
The header builder API is backward compatible: `ClientHeaderBuilder`
return type widens from `string` to `string | HeaderResult`. Existing
builders returning `string` continue to work unchanged.
Currently only `generateFetchHeader` emits `sharedTypes` (HTTPStatusCode*
family). The extraction mechanism is generic — other header builders can
adopt it incrementally.
Remove stale barrel snapshots from the previous naive implementation
(gated on `indexFiles` alone). The barrel now requires both
`indexFiles` and `tagsSplitDeduplication` to be `true`.
Related design discussion: #3553Closes#3553
Copy file name to clipboardExpand all lines: docs/content/docs/reference/configuration/output.mdx
+64Lines changed: 64 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -618,6 +618,70 @@ import { getPetMock } from '@acme/data-layer/sdk/fakers';
618
618
619
619
Generate `index.ts` files for schemas.
620
620
621
+
## tagsSplitDeduplication
622
+
623
+
**Type:**`Boolean`
624
+
**Default:**`false`
625
+
626
+
In `tags-split` mode, extract shared infrastructure types (e.g. `HTTPStatusCode*` emitted by the fetch client) into a single `common-types.ts` file and generate a barrel `index.ts` at the target root.
627
+
628
+
When enabled alongside [`indexFiles: true`](#indexfiles):
629
+
630
+
- Shared types that would otherwise be duplicated across per-tag files are collected and written once to `[commonTypesFileName].ts`
631
+
- Each per-tag file imports shared types from the common file instead of declaring them inline
632
+
- A barrel `index.ts` is generated with named re-exports for public shared types plus `export *` re-exports for each per-tag implementation file
633
+
634
+
```ts title="orval.config.ts"
635
+
exportdefaultdefineConfig({
636
+
petstore: {
637
+
output: {
638
+
mode: 'tags-split',
639
+
target: './src/api/endpoints.ts',
640
+
schemas: './src/api/model',
641
+
client: 'fetch',
642
+
indexFiles: true,
643
+
tagsSplitDeduplication: true,
644
+
},
645
+
},
646
+
});
647
+
```
648
+
649
+
Resulting structure:
650
+
651
+
```
652
+
src/api/
653
+
├── common-types.ts ← shared types extracted once
654
+
├── index.ts ← barrel with named + wildcard re-exports
655
+
├── pets/
656
+
│ └── pets.ts ← import type { ... } from '../common-types'
657
+
└── health/
658
+
└── health.ts ← import type { ... } from '../common-types'
659
+
```
660
+
661
+
When disabled (default), shared types are inlined per-tag and no barrel is generated — identical to previous behavior.
662
+
663
+
Suppressed when [`workspace`](#workspace) is set (the workspace barrel handles aggregation).
664
+
665
+
## commonTypesFileName
666
+
667
+
**Type:**`String`
668
+
**Default:**`'common-types'`
669
+
670
+
The file name (without extension) used for the shared types file when [`tagsSplitDeduplication`](#tagssplitdeduplication) is enabled.
0 commit comments