@kubb/core 5.0.0-alpha.73 → 5.0.0-alpha.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -202,9 +202,17 @@ type Storage = {
202
202
  dispose?(): Promise<void>;
203
203
  };
204
204
  /**
205
- * Creates a storage factory. Call the returned function with optional options to get the storage instance.
205
+ * Factory for implementing custom storage backends that control where generated files are written.
206
+ *
207
+ * Takes a builder function `(options: TOptions) => Storage` and returns a factory `(options?: TOptions) => Storage`.
208
+ * Kubb provides filesystem and in-memory implementations out of the box.
209
+ *
210
+ * @note Call the returned factory with optional options to instantiate the storage adapter.
206
211
  *
207
212
  * @example
213
+ * ```ts
214
+ * import { createStorage } from '@kubb/core'
215
+ *
208
216
  * export const memoryStorage = createStorage(() => {
209
217
  * const store = new Map<string, string>()
210
218
  * return {
@@ -220,38 +228,35 @@ type Storage = {
220
228
  * async clear(base) { if (!base) store.clear() },
221
229
  * }
222
230
  * })
231
+ *
232
+ * // Instantiate:
233
+ * const storage = memoryStorage()
234
+ * ```
223
235
  */
224
236
  declare function createStorage<TOptions = Record<string, never>>(build: (options: TOptions) => Storage): (options?: TOptions) => Storage;
225
237
  //#endregion
226
238
  //#region src/defineGenerator.d.ts
227
239
  /**
228
- * A generator is a named object with optional `schema`, `operation`, and `operations`
229
- * methods. Each method receives the AST node as the first argument and a typed
230
- * `ctx` object as the second, giving access to `ctx.config`, `ctx.resolver`,
231
- * `ctx.adapter`, `ctx.options`, `ctx.upsertFile`, etc.
240
+ * Declares a named generator unit that walks the AST and emits files.
232
241
  *
233
- * Generators that return renderer elements (e.g. JSX) must declare a `renderer`
234
- * factory so that core knows how to process the output without coupling core
235
- * to any specific renderer package.
242
+ * Each method (`schema`, `operation`, `operations`) is called for the matching node type.
243
+ * Each method returns `TElement | Array<FileNode> | void`. JSX-based generators require a `renderer` factory.
244
+ * Return `Array<FileNode>` directly or call `ctx.upsertFile()` manually and return `void` to bypass rendering.
236
245
  *
237
- * Return a renderer element, an array of `FileNode`, or `void` to handle file
238
- * writing manually via `ctx.upsertFile`.
246
+ * @note Generators are consumed by plugins and registered via `ctx.addGenerator()` in `kubb:plugin:setup`.
239
247
  *
240
248
  * @example
241
249
  * ```ts
250
+ * import { defineGenerator } from '@kubb/core'
242
251
  * import { jsxRenderer } from '@kubb/renderer-jsx'
243
252
  *
244
- * export const typeGenerator = defineGenerator<PluginTs>({
253
+ * export const typeGenerator = defineGenerator({
245
254
  * name: 'typescript',
246
255
  * renderer: jsxRenderer,
247
256
  * schema(node, ctx) {
248
257
  * const { adapter, resolver, root, options } = ctx
249
258
  * return <File ...><Type node={node} resolver={resolver} /></File>
250
259
  * },
251
- * operation(node, ctx) {
252
- * const { options } = ctx
253
- * return <File ...><OperationType node={node} /></File>
254
- * },
255
260
  * })
256
261
  * ```
257
262
  */
@@ -348,23 +353,23 @@ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
348
353
  };
349
354
  };
350
355
  /**
351
- * Creates a plugin factory using the hook-style (`hooks:`) API.
356
+ * Wraps a factory function and returns a typed `Plugin` with lifecycle handlers grouped under `hooks`.
352
357
  *
353
- * The returned factory is called with optional options and produces a `Plugin`
354
- * that coexists with plugins created via the legacy `createPlugin` API in the same
355
- * `kubb.config.ts`.
358
+ * Handlers live in a single `hooks` object (inspired by Astro integrations).
359
+ * All lifecycle events from `KubbHooks` are available for subscription.
356
360
  *
357
- * Lifecycle handlers are registered on the `PluginDriver`'s `AsyncEventEmitter`, enabling
358
- * both the plugin's own handlers and external tooling (CLI, devtools) to observe every event.
361
+ * @note For real plugins, use a `PluginFactoryOptions` type parameter to get type-safe context in `kubb:plugin:setup`.
362
+ * Plugin names should follow the convention `plugin-<feature>` (e.g., `plugin-react-query`, `plugin-zod`).
359
363
  *
360
364
  * @example
361
365
  * ```ts
362
- * // With PluginFactoryOptions (recommended for real plugins)
363
- * export const pluginTs = definePlugin<PluginTs>((options) => ({
366
+ * import { definePlugin } from '@kubb/core'
367
+ *
368
+ * export const pluginTs = definePlugin((options: { prefix?: string } = {}) => ({
364
369
  * name: 'plugin-ts',
365
370
  * hooks: {
366
371
  * 'kubb:plugin:setup'(ctx) {
367
- * ctx.setResolver(resolverTs) // typed as Partial<ResolverTs>
372
+ * ctx.setResolver(resolverTs)
368
373
  * },
369
374
  * },
370
375
  * }))
@@ -571,48 +576,44 @@ declare function createKubb(userConfig: UserConfig, options?: CreateKubbOptions)
571
576
  //#endregion
572
577
  //#region src/Kubb.d.ts
573
578
  /**
574
- * The instance returned by {@link createKubb}.
579
+ * Kubb code generation instance returned by {@link createKubb}.
580
+ *
581
+ * Use this when orchestrating multiple builds, inspecting plugin timings, or integrating Kubb into a larger toolchain.
582
+ * For a single one-off build, chain directly: `await createKubb(config).build()`.
575
583
  */
576
584
  type Kubb$1 = {
577
585
  /**
578
- * The shared event emitter. Attach listeners here before calling `setup()` or `build()`.
586
+ * Shared event emitter for lifecycle and status events. Attach listeners before calling `setup()` or `build()`.
579
587
  */
580
588
  readonly hooks: AsyncEventEmitter<KubbHooks>;
581
589
  /**
582
- * Raw generated source, keyed by absolute file path.
583
- * Populated after a successful `build()` or `safeBuild()` call.
590
+ * Generated source code keyed by absolute file path. Available after `build()` or `safeBuild()` completes.
584
591
  */
585
592
  readonly sources: Map<string, string>;
586
593
  /**
587
- * The plugin driver. Available after `setup()` has been called.
594
+ * Plugin driver managing all plugins. Available after `setup()` completes.
588
595
  */
589
596
  readonly driver: PluginDriver | undefined;
590
597
  /**
591
- * The resolved config with applied defaults. Available after `setup()` has been called.
598
+ * Resolved configuration with defaults applied. Available after `setup()` completes.
592
599
  */
593
600
  readonly config: Config | undefined;
594
601
  /**
595
- * Initializes all Kubb infrastructure: validates input, applies config defaults,
596
- * runs the adapter, and creates the PluginDriver.
597
- *
598
- * Calling `build()` or `safeBuild()` without calling `setup()` first will
599
- * automatically invoke `setup()` before proceeding.
602
+ * Resolves config and initializes the driver. `build()` calls this automatically.
600
603
  */
601
604
  setup(): Promise<void>;
602
605
  /**
603
- * Runs a full Kubb build and throws on any error or plugin failure.
604
- * Automatically calls `setup()` if it has not been called yet.
606
+ * Runs the full pipeline and throws on any plugin error. Automatically calls `setup()` if needed.
605
607
  */
606
608
  build(): Promise<BuildOutput>;
607
609
  /**
608
- * Runs a full Kubb build and captures errors instead of throwing.
609
- * Automatically calls `setup()` if it has not been called yet.
610
+ * Runs the full pipeline and captures errors in `BuildOutput` instead of throwing. Automatically calls `setup()` if needed.
610
611
  */
611
612
  safeBuild(): Promise<BuildOutput>;
612
613
  };
613
614
  /**
614
- * Events emitted during the Kubb code generation lifecycle.
615
- * These events can be listened to for logging, progress tracking, and custom integrations.
615
+ * Lifecycle events emitted during Kubb code generation.
616
+ * Use these for logging, progress tracking, and custom integrations.
616
617
  *
617
618
  * @example
618
619
  * ```typescript
@@ -632,69 +633,67 @@ type Kubb$1 = {
632
633
  */
633
634
  interface KubbHooks {
634
635
  /**
635
- * Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
636
+ * Fires at the start of the Kubb lifecycle, before code generation begins.
636
637
  */
637
638
  'kubb:lifecycle:start': [ctx: KubbLifecycleStartContext];
638
639
  /**
639
- * Emitted at the end of the Kubb lifecycle, after all code generation is complete.
640
+ * Fires at the end of the Kubb lifecycle, after all code generation completes.
640
641
  */
641
642
  'kubb:lifecycle:end': [];
642
643
  /**
643
- * Emitted when configuration loading starts.
644
+ * Fires when configuration loading starts.
644
645
  */
645
646
  'kubb:config:start': [];
646
647
  /**
647
- * Emitted when configuration loading is complete.
648
+ * Fires when configuration loading completes.
648
649
  */
649
650
  'kubb:config:end': [ctx: KubbConfigEndContext];
650
651
  /**
651
- * Emitted when code generation phase starts.
652
+ * Fires when code generation starts.
652
653
  */
653
654
  'kubb:generation:start': [ctx: KubbGenerationStartContext];
654
655
  /**
655
- * Emitted when code generation phase completes.
656
+ * Fires when code generation completes.
656
657
  */
657
658
  'kubb:generation:end': [ctx: KubbGenerationEndContext];
658
659
  /**
659
- * Emitted with a summary of the generation results.
660
- * Contains summary lines, title, and success status.
660
+ * Fires with a generation summary including summary lines, title, and success status.
661
661
  */
662
662
  'kubb:generation:summary': [ctx: KubbGenerationSummaryContext];
663
663
  /**
664
- * Emitted when code formatting starts (e.g., running Biome or Prettier).
664
+ * Fires when code formatting starts (e.g., Biome or Prettier).
665
665
  */
666
666
  'kubb:format:start': [];
667
667
  /**
668
- * Emitted when code formatting completes.
668
+ * Fires when code formatting completes.
669
669
  */
670
670
  'kubb:format:end': [];
671
671
  /**
672
- * Emitted when linting starts.
672
+ * Fires when linting starts.
673
673
  */
674
674
  'kubb:lint:start': [];
675
675
  /**
676
- * Emitted when linting completes.
676
+ * Fires when linting completes.
677
677
  */
678
678
  'kubb:lint:end': [];
679
679
  /**
680
- * Emitted when plugin hooks execution starts.
680
+ * Fires when plugin hooks execution starts.
681
681
  */
682
682
  'kubb:hooks:start': [];
683
683
  /**
684
- * Emitted when plugin hooks execution completes.
684
+ * Fires when plugin hooks execution completes.
685
685
  */
686
686
  'kubb:hooks:end': [];
687
687
  /**
688
- * Emitted when a single hook execution starts (e.g., format or lint).
689
- * The callback should be invoked when the command completes.
688
+ * Fires when a single hook executes (e.g., format or lint). The callback is invoked when the command finishes.
690
689
  */
691
690
  'kubb:hook:start': [ctx: KubbHookStartContext];
692
691
  /**
693
- * Emitted when a single hook execution completes.
692
+ * Fires when a single hook execution completes.
694
693
  */
695
694
  'kubb:hook:end': [ctx: KubbHookEndContext];
696
695
  /**
697
- * Emitted when a new version of Kubb is available.
696
+ * Fires when a new Kubb version is available.
698
697
  */
699
698
  'kubb:version:new': [ctx: KubbVersionNewContext];
700
699
  /**
@@ -702,7 +701,7 @@ interface KubbHooks {
702
701
  */
703
702
  'kubb:info': [ctx: KubbInfoContext];
704
703
  /**
705
- * Error event. Emitted when an error occurs during code generation.
704
+ * Error event, fired when an error occurs during generation.
706
705
  */
707
706
  'kubb:error': [ctx: KubbErrorContext];
708
707
  /**
@@ -714,77 +713,56 @@ interface KubbHooks {
714
713
  */
715
714
  'kubb:warn': [ctx: KubbWarnContext];
716
715
  /**
717
- * Debug event for detailed logging.
718
- * Contains timestamp, log messages, and optional filename.
716
+ * Debug event for detailed logging with timestamp and optional filename.
719
717
  */
720
718
  'kubb:debug': [ctx: KubbDebugContext];
721
719
  /**
722
- * Emitted when file processing starts.
723
- * Contains the list of files to be processed.
720
+ * Fires when file processing starts with the list of files to process.
724
721
  */
725
722
  'kubb:files:processing:start': [ctx: KubbFilesProcessingStartContext];
726
723
  /**
727
- * Emitted for each file being processed, providing progress updates.
728
- * Contains processed count, total count, percentage, and file details.
724
+ * Fires for each file with progress updates: processed count, total, percentage, and file details.
729
725
  */
730
726
  'kubb:file:processing:update': [ctx: KubbFileProcessingUpdateContext];
731
727
  /**
732
- * Emitted when file processing completes.
733
- * Contains the list of processed files.
728
+ * Fires when file processing completes with the list of processed files.
734
729
  */
735
730
  'kubb:files:processing:end': [ctx: KubbFilesProcessingEndContext];
736
731
  /**
737
- * Emitted when a plugin starts executing.
732
+ * Fires when a plugin starts execution.
738
733
  */
739
734
  'kubb:plugin:start': [ctx: KubbPluginStartContext];
740
735
  /**
741
- * Emitted when a plugin completes execution.
742
- * Duration in ms.
736
+ * Fires when a plugin completes execution. Duration measured in milliseconds.
743
737
  */
744
738
  'kubb:plugin:end': [ctx: KubbPluginEndContext];
745
739
  /**
746
- * Fired once — before any plugin's `buildStart` runs so that hook-style plugins
747
- * can register generators, configure resolvers/transformers/renderers, or inject
748
- * extra files. All `kubb:plugin:setup` handlers registered via `definePlugin` receive
749
- * a plugin-specific context (with the correct `addGenerator` closure).
750
- * External tooling can observe this event via `hooks.on('kubb:plugin:setup', …)`.
740
+ * Fires once before plugins execute allowing plugins to register generators, configure resolvers/transformers/renderers, or inject files.
751
741
  */
752
742
  'kubb:plugin:setup': [ctx: KubbPluginSetupContext];
753
743
  /**
754
- * Fired immediately before the plugin execution loop begins.
755
- * The adapter has already parsed the source and `inputNode` is available.
744
+ * Fires before the plugin execution loop begins. The adapter has already parsed the source and `inputNode` is available.
756
745
  */
757
746
  'kubb:build:start': [ctx: KubbBuildStartContext];
758
747
  /**
759
- * Fired after all plugins have run and all per-plugin barrels have been generated,
760
- * but BEFORE files are written to disk.
761
- * Use this event to inject final files (e.g. a root barrel) that must be persisted
762
- * in the same write pass as the plugin output.
748
+ * Fires after all plugins run and per-plugin barrels generate, but before files write to disk.
749
+ * Use this to inject final files that must persist in the same write pass as plugin output.
763
750
  */
764
751
  'kubb:plugins:end': [ctx: KubbPluginsEndContext];
765
752
  /**
766
- * Fired after all files have been written to disk.
753
+ * Fires after all files write to disk.
767
754
  */
768
755
  'kubb:build:end': [ctx: KubbBuildEndContext];
769
756
  /**
770
- * Emitted for each schema node during the AST walk.
771
- * Generator listeners registered via `addGenerator()` in `kubb:plugin:setup` respond to this event.
772
- * The `ctx.plugin.name` identifies which plugin is driving the current walk.
773
- * `ctx.options` carries the per-node resolved options (after exclude/include/override).
757
+ * Fires for each schema node during AST traversal. Generator listeners respond to this.
774
758
  */
775
759
  'kubb:generate:schema': [node: SchemaNode, ctx: GeneratorContext];
776
760
  /**
777
- * Emitted for each operation node during the AST walk.
778
- * Generator listeners registered via `addGenerator()` in `kubb:plugin:setup` respond to this event.
779
- * The `ctx.plugin.name` identifies which plugin is driving the current walk.
780
- * `ctx.options` carries the per-node resolved options (after exclude/include/override).
761
+ * Fires for each operation node during AST traversal. Generator listeners respond to this.
781
762
  */
782
763
  'kubb:generate:operation': [node: OperationNode, ctx: GeneratorContext];
783
764
  /**
784
- * Emitted once after all operations have been walked, with the full collected array.
785
- * Generator listeners with an `operations()` method respond to this event.
786
- * The `ctx.plugin.name` identifies which plugin is driving the current walk.
787
- * `ctx.options` carries the plugin-level resolved options for the batch call.
765
+ * Fires once after all operations traverse with the full collected array. Batch generator listeners respond to this.
788
766
  */
789
767
  'kubb:generate:operations': [nodes: Array<OperationNode>, ctx: GeneratorContext];
790
768
  }
@@ -871,14 +849,17 @@ type Middleware = {
871
849
  hooks: { [K in keyof KubbHooks]?: (...args: KubbHooks[K]) => void | Promise<void> };
872
850
  };
873
851
  /**
874
- * Creates a middleware factory using the hook-style (`hooks:`) API.
852
+ * Creates a middleware factory using the hook-style `hooks` API.
853
+ *
854
+ * Middleware handlers fire after all plugin handlers for any given event, making them ideal for post-processing, logging, and auditing.
855
+ * Per-build state (such as accumulators) belongs inside the factory closure so each `createKubb` invocation gets its own isolated instance.
875
856
  *
876
- * Mirrors `definePlugin`: the factory is called with optional options and returns a
877
- * fresh `Middleware` instance. Placing per-build state (e.g. accumulators) inside the
878
- * factory closure ensures each `createKubb` invocation gets its own isolated instance.
857
+ * @note The factory can accept typed options. See examples for using options and per-build state patterns.
879
858
  *
880
859
  * @example
881
860
  * ```ts
861
+ * import { defineMiddleware } from '@kubb/core'
862
+ *
882
863
  * // Stateless middleware
883
864
  * export const logMiddleware = defineMiddleware(() => ({
884
865
  * name: 'log-middleware',
@@ -890,10 +871,10 @@ type Middleware = {
890
871
  * }))
891
872
  *
892
873
  * // Middleware with options and per-build state
893
- * export const myMiddleware = defineMiddleware((options: { prefix: string } = { prefix: '' }) => {
874
+ * export const prefixMiddleware = defineMiddleware((options: { prefix: string } = { prefix: '' }) => {
894
875
  * const seen = new Set<string>()
895
876
  * return {
896
- * name: 'my-middleware',
877
+ * name: 'prefix-middleware',
897
878
  * hooks: {
898
879
  * 'kubb:plugin:end'({ plugin }) {
899
880
  * seen.add(`${options.prefix}${plugin.name}`)
@@ -901,11 +882,6 @@ type Middleware = {
901
882
  * },
902
883
  * }
903
884
  * })
904
- *
905
- * // Usage in kubb.config.ts:
906
- * export default defineConfig({
907
- * middleware: [logMiddleware(), myMiddleware({ prefix: 'pfx:' })],
908
- * })
909
885
  * ```
910
886
  */
911
887
  declare function defineMiddleware<TOptions extends object = object>(factory: (options: TOptions) => Middleware): (options?: TOptions) => Middleware;
@@ -930,10 +906,9 @@ type Parser<TMeta extends object = any> = {
930
906
  parse(file: FileNode<TMeta>, options?: PrintOptions): Promise<string> | string;
931
907
  };
932
908
  /**
933
- * Defines a parser with type safety.
909
+ * Defines a parser with type safety. Creates parsers that transform generated files to strings based on their extension.
934
910
  *
935
- * Use this function to create parsers that transform generated files to strings
936
- * based on their extension.
911
+ * @note Call the returned factory with optional options to instantiate the parser.
937
912
  *
938
913
  * @example
939
914
  * ```ts
@@ -953,30 +928,53 @@ declare function defineParser<TMeta extends object = any>(parser: Parser<TMeta>)
953
928
  //#endregion
954
929
  //#region src/types.d.ts
955
930
  /**
956
- * Safely extracts the type of key `K` from `T`, returning `{}` when `K` is not a key of `T`.
957
- * Used to implement optional interface augmentation for `Kubb.ConfigOptionsRegistry` and
958
- * `Kubb.PluginOptionsRegistry` so that middleware and plugin packages can extend core types
959
- * without requiring modifications to core.
931
+ * Safely extracts a type from a registry, returning `{}` if the key doesn't exist.
932
+ * Enables optional interface augmentation for `Kubb.ConfigOptionsRegistry` and `Kubb.PluginOptionsRegistry`
933
+ * without requiring changes to core.
960
934
  *
961
935
  * @internal
962
936
  */
963
937
  type ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {};
938
+ /**
939
+ * Reference to an input file to generate code from.
940
+ *
941
+ * Specify an absolute path or a path relative to the config file location.
942
+ * The adapter will parse this file (e.g., OpenAPI YAML or JSON) into the universal AST.
943
+ */
964
944
  type InputPath = {
965
945
  /**
966
- * Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
946
+ * Path to your Swagger/OpenAPI file, absolute or relative to the config file location.
947
+ *
948
+ * @example
949
+ * ```ts
950
+ * { path: './petstore.yaml' }
951
+ * { path: '/absolute/path/to/openapi.json' }
952
+ * ```
967
953
  */
968
954
  path: string;
969
955
  };
956
+ /**
957
+ * Inline input data to generate code from.
958
+ *
959
+ * Useful when you want to pass the specification directly instead of from a file.
960
+ * Can be a string (YAML/JSON) or a parsed object.
961
+ */
970
962
  type InputData = {
971
963
  /**
972
- * A `string` or `object` that contains your Swagger/OpenAPI data.
964
+ * Swagger/OpenAPI data as a string (YAML/JSON) or a parsed object.
965
+ *
966
+ * @example
967
+ * ```ts
968
+ * { data: fs.readFileSync('./openapi.yaml', 'utf8') }
969
+ * { data: { openapi: '3.1.0', info: { ... } } }
970
+ * ```
973
971
  */
974
972
  data: string | unknown;
975
973
  };
976
974
  type Input = InputPath | InputData;
977
975
  /**
978
- * The raw source passed to an adapter's `parse` function.
979
- * Mirrors the shape of `Config['input']` with paths already resolved to absolute.
976
+ * Source data passed to an adapter's `parse` function.
977
+ * Mirrors the config input shape with paths resolved to absolute.
980
978
  */
981
979
  type AdapterSource = {
982
980
  type: 'path';
@@ -989,13 +987,12 @@ type AdapterSource = {
989
987
  paths: Array<string>;
990
988
  };
991
989
  /**
992
- * Type parameters for an adapter definition.
990
+ * Generic type parameters for an adapter definition.
993
991
  *
994
- * Mirrors `PluginFactoryOptions` but scoped to the adapter lifecycle:
995
- * - `TName` — unique string identifier (e.g. `'oas'`, `'asyncapi'`)
996
- * - `TOptions` — raw user-facing options passed to the adapter factory
997
- * - `TResolvedOptions` — defaults applied; what the adapter stores as `options`
998
- * - `TDocument` — type of the raw source document exposed by the adapter after `parse()`
992
+ * - `TName` unique identifier (e.g. `'oas'`, `'asyncapi'`)
993
+ * - `TOptions` — user-facing options passed to the adapter factory
994
+ * - `TResolvedOptions` — options after defaults applied
995
+ * - `TDocument` — type of the parsed source document
999
996
  */
1000
997
  type AdapterFactoryOptions<TName extends string = string, TOptions extends object = object, TResolvedOptions extends object = TOptions, TDocument = unknown> = {
1001
998
  name: TName;
@@ -1004,48 +1001,46 @@ type AdapterFactoryOptions<TName extends string = string, TOptions extends objec
1004
1001
  document: TDocument;
1005
1002
  };
1006
1003
  /**
1007
- * An adapter converts a source file or data into a `@kubb/ast` `InputNode`.
1004
+ * Adapter that converts input files or data into an `InputNode`.
1008
1005
  *
1009
- * Adapters are the single entry-point for different schema formats
1010
- * (OpenAPI, AsyncAPI, Drizzle, …) and produce the universal `InputNode`
1011
- * that all Kubb plugins consume.
1006
+ * Adapters parse different schema formats (OpenAPI, AsyncAPI, Drizzle, etc.) into Kubb's
1007
+ * universal intermediate representation that all plugins consume.
1012
1008
  *
1013
1009
  * @example
1014
1010
  * ```ts
1015
- * import { oasAdapter } from '@kubb/adapter-oas'
1011
+ * import { adapterOas } from '@kubb/adapter-oas'
1016
1012
  *
1017
1013
  * export default defineConfig({
1018
- * adapter: adapterOas(), // default — OpenAPI / Swagger
1019
- * input: { path: './openapi.yaml' },
1014
+ * adapter: adapterOas(),
1015
+ * input: { path: './openapi.yaml' },
1020
1016
  * plugins: [pluginTs(), pluginZod()],
1021
1017
  * })
1022
1018
  * ```
1023
1019
  */
1024
1020
  type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
1025
1021
  /**
1026
- * Human-readable identifier, e.g. `'oas'`, `'drizzle'`, `'asyncapi'`.
1022
+ * Human-readable adapter identifier (e.g. `'oas'`, `'asyncapi'`).
1027
1023
  */
1028
1024
  name: TOptions['name'];
1029
1025
  /**
1030
- * Resolved options (after defaults have been applied).
1026
+ * Resolved adapter options after defaults have been applied.
1031
1027
  */
1032
1028
  options: TOptions['resolvedOptions'];
1033
1029
  /**
1034
- * The raw source document produced after the first `parse()` call.
1035
- * `undefined` before parsing; typed by the adapter's `TDocument` generic.
1030
+ * Parsed source document after the first `parse()` call. `null` before parsing.
1036
1031
  */
1037
1032
  document: TOptions['document'] | null;
1038
1033
  inputNode: InputNode | null;
1039
1034
  /**
1040
- * Convert the raw source into a universal `InputNode`.
1035
+ * Parse the source into a universal `InputNode`.
1041
1036
  */
1042
1037
  parse: (source: AdapterSource) => PossiblePromise<InputNode>;
1043
1038
  /**
1044
- * Extracts `ImportNode` entries needed by a `SchemaNode` tree.
1045
- * Populated after the first `parse()` call. Returns an empty array before that.
1039
+ * Extract `ImportNode` entries for a schema tree.
1040
+ * Returns an empty array before the first `parse()` call.
1046
1041
  *
1047
1042
  * The `resolve` callback receives the collision-corrected schema name and must
1048
- * return the `{ name, path }` pair for the import, or `undefined` to skip it.
1043
+ * return `{ name, path }` for the import, or `undefined` to skip it.
1049
1044
  */
1050
1045
  getImports: (node: SchemaNode, resolve: (schemaName: string) => {
1051
1046
  name: string;
@@ -1054,34 +1049,47 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
1054
1049
  };
1055
1050
  type DevtoolsOptions = {
1056
1051
  /**
1057
- * Open the AST inspector view (`/ast`) in Kubb Studio.
1058
- * When `false`, opens the main Studio page instead.
1052
+ * Open the AST inspector in Kubb Studio (`/ast`). Defaults to the main Studio page.
1059
1053
  * @default false
1060
1054
  */
1061
1055
  ast?: boolean;
1062
1056
  };
1063
1057
  /**
1058
+ * Build configuration for Kubb code generation.
1059
+ *
1060
+ * The Config is the main entry point for customizing how Kubb generates code. It specifies:
1061
+ * - What to generate from (adapter + input)
1062
+ * - Where to output generated code (output)
1063
+ * - How to generate (plugins + middleware)
1064
+ * - Runtime details (parsers, storage, renderer)
1065
+ *
1066
+ * See `UserConfig` for a relaxed version with sensible defaults.
1067
+ *
1064
1068
  * @private
1065
1069
  */
1066
1070
  type Config<TInput = Input> = {
1067
1071
  /**
1068
- * The name to display in the CLI output.
1072
+ * Display name for this configuration in CLI output and logs.
1073
+ * Useful when running multiple builds with `defineConfig` arrays.
1074
+ *
1075
+ * @example
1076
+ * ```ts
1077
+ * name: 'api-client'
1078
+ * ```
1069
1079
  */
1070
1080
  name?: string;
1071
1081
  /**
1072
- * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
1082
+ * Project root directory, absolute or relative to the config file.
1073
1083
  * @default process.cwd()
1074
1084
  */
1075
1085
  root: string;
1076
1086
  /**
1077
- * An array of parsers used to convert generated files to strings.
1078
- * Each parser handles specific file extensions (e.g. `.ts`, `.tsx`).
1079
- *
1080
- * A catch-all fallback parser is always appended last for any unhandled extension.
1087
+ * Parsers that convert generated files to strings.
1088
+ * Each parser handles specific extensions (e.g. `.ts`, `.tsx`).
1089
+ * A fallback parser is appended for unhandled extensions.
1090
+ * When omitted, defaults to `parserTs` from `@kubb/parser-ts`.
1081
1091
  *
1082
- * When omitted, `parserTs` from `@kubb/parser-ts` is used automatically as the
1083
- * default (requires `@kubb/parser-ts` to be installed as an optional dependency).
1084
- * @default [parserTs] — from `@kubb/parser-ts`
1092
+ * @default [parserTs] from `@kubb/parser-ts`
1085
1093
  * @example
1086
1094
  * ```ts
1087
1095
  * import { parserTs, tsxParser } from '@kubb/parser-ts'
@@ -1092,125 +1100,197 @@ type Config<TInput = Input> = {
1092
1100
  */
1093
1101
  parsers: Array<Parser>;
1094
1102
  /**
1095
- * Adapter that converts the input file into a `@kubb/ast` `InputNode` — the universal
1096
- * intermediate representation consumed by all Kubb plugins.
1097
- *
1098
- * - Use `@kubb/adapter-oas` for OpenAPI / Swagger.
1099
- * - Use `@kubb/adapter-drizzle` or `@kubb/adapter-asyncapi` for other formats.
1103
+ * Adapter that parses input files into the universal `InputNode` representation.
1104
+ * Use `@kubb/adapter-oas` for OpenAPI/Swagger or `@kubb/adapter-asyncapi` for other formats.
1100
1105
  *
1101
1106
  * @example
1102
1107
  * ```ts
1103
1108
  * import { adapterOas } from '@kubb/adapter-oas'
1104
1109
  * export default defineConfig({
1105
1110
  * adapter: adapterOas(),
1106
- * input: { path: './petStore.yaml' },
1111
+ * input: { path: './petstore.yaml' },
1107
1112
  * })
1108
1113
  * ```
1109
1114
  */
1110
1115
  adapter: Adapter;
1111
1116
  /**
1112
1117
  * Source file or data to generate code from.
1113
- * Use `input.path` for a file on disk or `input.data` for an inline string or object.
1118
+ * Use `input.path` for a file path or `input.data` for inline data.
1114
1119
  */
1115
1120
  input: TInput;
1116
1121
  output: {
1117
1122
  /**
1118
- * Output directory for generated files.
1119
- * Accepts an absolute path or a path relative to `root`.
1123
+ * Output directory for generated files, absolute or relative to `root`.
1124
+ *
1125
+ * All generated files will be written under this directory. Subdirectories can be created
1126
+ * by plugins based on grouping strategy (by tag, path, etc.).
1127
+ *
1128
+ * @example
1129
+ * ```ts
1130
+ * output: {
1131
+ * path: './src/gen', // generates ./src/gen/api.ts, ./src/gen/types.ts, etc.
1132
+ * }
1133
+ * ```
1120
1134
  */
1121
1135
  path: string;
1122
1136
  /**
1123
- * Clean the output directory before each build.
1137
+ * Remove all files from the output directory before starting the build.
1138
+ *
1139
+ * Useful to ensure old generated files aren't mixed with new ones.
1140
+ * Set to `true` for fresh builds, `false` to preserve manual edits in output dir.
1141
+ *
1142
+ * @default false
1143
+ * @example
1144
+ * ```ts
1145
+ * clean: true // wipes ./src/gen/* before generating
1146
+ * ```
1124
1147
  */
1125
1148
  clean?: boolean;
1126
1149
  /**
1127
- * Save files to the file system.
1150
+ * Persists generated files to the file system.
1151
+ *
1128
1152
  * @default true
1129
- * @deprecated Use `storage` to control where files are written.
1153
+ * @deprecated Use `storage` option to control where files are written instead.
1130
1154
  */
1131
1155
  write?: boolean;
1132
1156
  /**
1133
- * Specifies the formatting tool to be used.
1134
- * - 'auto' automatically detects and uses oxfmt, biome, or prettier (in that order of preference).
1135
- * - 'oxfmt' uses Oxfmt for code formatting.
1136
- * - 'prettier' uses Prettier for code formatting.
1137
- * - 'biome' uses Biome for code formatting.
1138
- * - false disables code formatting.
1157
+ * Auto-format generated files after code generation completes.
1158
+ *
1159
+ * Applies a code formatter to all generated files. Use `'auto'` to detect which formatter
1160
+ * is available on your system. Pass `false` to skip formatting (useful for CI or specific workflows).
1161
+ *
1139
1162
  * @default false
1163
+ * @example
1164
+ * ```ts
1165
+ * format: 'auto' // auto-detect prettier, biome, or oxfmt
1166
+ * format: 'prettier' // force prettier
1167
+ * format: false // skip formatting
1168
+ * ```
1140
1169
  */
1141
1170
  format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
1142
1171
  /**
1143
- * Specifies the linter that should be used to analyze the code.
1144
- * - 'auto' automatically detects and uses oxlint, biome, or eslint (in that order of preference).
1145
- * - 'oxlint' uses Oxlint for linting.
1146
- * - 'eslint' uses ESLint for linting.
1147
- * - 'biome' uses Biome for linting.
1148
- * - false disables linting.
1172
+ * Auto-lint generated files after code generation completes.
1173
+ *
1174
+ * Analyzes all generated files for style/correctness issues. Use `'auto'` to detect which linter
1175
+ * is available on your system. Pass `false` to skip linting.
1176
+ *
1149
1177
  * @default false
1178
+ * @example
1179
+ * ```ts
1180
+ * lint: 'auto' // auto-detect oxlint, biome, or eslint
1181
+ * lint: 'eslint' // force eslint
1182
+ * lint: false // skip linting
1183
+ * ```
1150
1184
  */
1151
1185
  lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
1152
1186
  /**
1153
- * Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
1154
- * @default { '.ts': '.ts'}
1187
+ * Map file extensions to different output extensions.
1188
+ *
1189
+ * Useful when you want generated `.ts` imports to reference `.js` files or vice versa (e.g., for ESM dual packages).
1190
+ * Keys are the original extension, values are the output extension. Use empty string `''` to omit extension.
1191
+ *
1192
+ * @default { '.ts': '.ts' }
1193
+ * @example
1194
+ * ```ts
1195
+ * extension: { '.ts': '.js' } // generates import './api.js' instead of './api.ts'
1196
+ * extension: { '.ts': '', '.tsx': '.jsx' }
1197
+ * ```
1155
1198
  */
1156
1199
  extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
1157
1200
  /**
1158
- * Adds a default banner to the start of every generated file indicating it was generated by Kubb.
1159
- * - 'simple' adds banner with link to Kubb.
1160
- * - 'full' adds source, title, description, and OpenAPI version.
1161
- * - false disables banner generation.
1201
+ * Banner text prepended to every generated file.
1202
+ *
1203
+ * Useful for auto-generation notices or license headers. Choose a preset or write custom text.
1204
+ * Use `'simple'` for a basic Kubb banner, `'full'` for detailed metadata, or `false` to omit.
1205
+ *
1162
1206
  * @default 'simple'
1207
+ * @example
1208
+ * ```ts
1209
+ * defaultBanner: 'simple' // "This file was autogenerated by Kubb"
1210
+ * defaultBanner: 'full' // adds source, title, description, API version
1211
+ * defaultBanner: false // no banner
1212
+ * ```
1163
1213
  */
1164
1214
  defaultBanner?: 'simple' | 'full' | false;
1165
1215
  /**
1166
- * Whether to override existing external files if they already exist.
1167
- * When setting the option in the global configuration, all plugins inherit the same behavior by default.
1168
- * However, all plugins also have an `output.override` option, which can be used to override the behavior for a specific plugin.
1216
+ * When `true`, overwrites existing files. When `false`, skips generated files that already exist.
1217
+ *
1218
+ * Individual plugins can override this setting. This is useful for preventing accidental data loss
1219
+ * when re-generating while you have local edits in the output folder.
1220
+ *
1169
1221
  * @default false
1222
+ * @example
1223
+ * ```ts
1224
+ * override: true // regenerate everything, even existing files
1225
+ * override: false // skip files that already exist
1226
+ * ```
1170
1227
  */
1171
1228
  override?: boolean;
1172
1229
  } & ExtractRegistryKey<Kubb.ConfigOptionsRegistry, 'output'>;
1173
1230
  /**
1174
- * Storage backend for generated files.
1175
- * Defaults to `fsStorage()` — the built-in filesystem driver.
1176
- * Accepts any object implementing the {@link Storage} interface.
1177
- * Keys are root-relative paths (e.g. `src/gen/api/getPets.ts`).
1231
+ * Storage backend that controls where and how generated files are persisted.
1232
+ *
1233
+ * Defaults to `fsStorage()` which writes to the file system. Pass `memoryStorage()` to keep files in RAM,
1234
+ * or implement a custom `Storage` interface to write to cloud storage, databases, or other backends.
1235
+ *
1178
1236
  * @default fsStorage()
1179
1237
  * @example
1180
1238
  * ```ts
1181
1239
  * import { memoryStorage } from '@kubb/core'
1240
+ *
1241
+ * // Keep generated files in memory (useful for testing, CI pipelines)
1182
1242
  * storage: memoryStorage()
1243
+ *
1244
+ * // Use custom S3 storage
1245
+ * storage: myS3Storage()
1183
1246
  * ```
1247
+ *
1248
+ * @see {@link Storage} interface for implementing custom backends.
1184
1249
  */
1185
1250
  storage?: Storage;
1186
1251
  /**
1187
- * An array of Kubb plugins used for code generation.
1188
- * Each plugin may declare additional configurable options.
1189
- * If a plugin depends on another, an error is thrown when the dependency is missing.
1190
- * Use `dependencies` on the plugin to declare execution order.
1252
+ * Plugins that execute during the build to generate code and transform the AST.
1253
+ *
1254
+ * Each plugin processes the AST produced by the adapter and can emit files for different
1255
+ * programming languages or formats (TypeScript, Zod schemas, Faker data, etc.).
1256
+ * Dependencies are enforced — an error is thrown if a plugin requires another plugin that isn't registered.
1257
+ *
1258
+ * Plugins can declare their own options via `PluginFactoryOptions`. See plugin documentation for details.
1259
+ *
1260
+ * @example
1261
+ * ```ts
1262
+ * import { pluginTs } from '@kubb/plugin-ts'
1263
+ * import { pluginZod } from '@kubb/plugin-zod'
1264
+ *
1265
+ * plugins: [
1266
+ * pluginTs({ output: { path: './src/gen' } }),
1267
+ * pluginZod({ output: { path: './src/gen' } }),
1268
+ * ]
1269
+ * ```
1191
1270
  */
1192
1271
  plugins: Array<Plugin>;
1193
1272
  /**
1194
- * Middleware instances that observe and post-process the build output.
1195
- * Each middleware receives the `hooks` emitter and attaches its own listeners.
1196
- * Middleware listeners are always registered after all plugin listeners,
1197
- * so middleware hooks fire last for any given event.
1273
+ * Middleware instances that observe build events and post-process generated code.
1274
+ *
1275
+ * Middleware fires AFTER all plugins for each event. Perfect for tasks like:
1276
+ * - Auditing what was generated
1277
+ * - Adding barrel/index files
1278
+ * - Validating output
1279
+ * - Running custom transformations
1198
1280
  *
1199
1281
  * @example
1200
1282
  * ```ts
1201
1283
  * import { middlewareBarrel } from '@kubb/middleware-barrel'
1202
- * export default defineConfig({
1203
- * middleware: [middlewareBarrel],
1204
- * plugins: [pluginTs(), pluginZod()],
1205
- * })
1284
+ *
1285
+ * middleware: [middlewareBarrel()]
1206
1286
  * ```
1287
+ *
1288
+ * @see {@link defineMiddleware} to create custom middleware.
1207
1289
  */
1208
1290
  middleware?: Array<Middleware>;
1209
1291
  /**
1210
- * Project-wide renderer factory. All plugins and generators that do not declare their own
1211
- * `renderer` ultimately fall back to this value.
1212
- *
1213
- * The resolution chain is: `generator.renderer` → `plugin.renderer` → `config.renderer` → `undefined` (raw `FileNode[]` mode).
1292
+ * Default renderer factory used by all plugins and generators.
1293
+ * Resolution chain: `generator.renderer` `plugin.renderer` `config.renderer` `undefined` (raw FileNode[] mode).
1214
1294
  *
1215
1295
  * @example
1216
1296
  * ```ts
@@ -1221,9 +1301,34 @@ type Config<TInput = Input> = {
1221
1301
  * })
1222
1302
  * ```
1223
1303
  */
1304
+ /**
1305
+ * Renderer that converts generated AST nodes to code strings.
1306
+ *
1307
+ * By default, Kubb uses the JSX renderer (`rendererJsx`). Pass a custom renderer to support
1308
+ * different output formats (template engines, code generation DSLs, etc.).
1309
+ *
1310
+ * @default rendererJsx() // from @kubb/renderer-jsx
1311
+ * @example
1312
+ * ```ts
1313
+ * import { rendererJsx } from '@kubb/renderer-jsx'
1314
+ * renderer: rendererJsx()
1315
+ * ```
1316
+ *
1317
+ * @see {@link Renderer} to implement a custom renderer.
1318
+ */
1224
1319
  renderer?: RendererFactory;
1225
1320
  /**
1226
- * Devtools configuration for Kubb Studio integration.
1321
+ * Kubb Studio cloud integration settings.
1322
+ *
1323
+ * Kubb Studio (https://studio.kubb.dev) is a web-based IDE for managing API specs and generated code.
1324
+ * Set to `true` to enable with default settings, or pass an object to customize the Studio URL.
1325
+ *
1326
+ * @default false // disabled by default
1327
+ * @example
1328
+ * ```ts
1329
+ * devtools: true // use default Kubb Studio
1330
+ * devtools: { studioUrl: 'https://my-studio.dev' } // custom Studio instance
1331
+ * ```
1227
1332
  */
1228
1333
  devtools?: true | {
1229
1334
  /**
@@ -1233,35 +1338,52 @@ type Config<TInput = Input> = {
1233
1338
  studioUrl?: typeof DEFAULT_STUDIO_URL | (string & {});
1234
1339
  };
1235
1340
  /**
1236
- * Hooks triggered when a specific action occurs in Kubb.
1341
+ * Lifecycle hooks that execute during or after the build process.
1342
+ *
1343
+ * Hooks allow you to run external tools (prettier, eslint, custom scripts) based on build events.
1344
+ * Currently supports the `done` hook which fires after all plugins and middleware complete.
1345
+ *
1346
+ * @example
1347
+ * ```ts
1348
+ * hooks: {
1349
+ * done: 'prettier --write "./src/gen"', // auto-format generated files
1350
+ * // or multiple commands:
1351
+ * done: ['prettier --write "./src/gen"', 'eslint --fix "./src/gen"']
1352
+ * }
1353
+ * ```
1237
1354
  */
1238
1355
  hooks?: {
1239
1356
  /**
1240
- * Hook that triggers at the end of all executions.
1241
- * Useful for running Prettier or ESLint to format/lint your code.
1357
+ * Command(s) to run after all plugins and middleware complete generation.
1358
+ *
1359
+ * Useful for post-processing: formatting, linting, copying files, or custom validation.
1360
+ * Pass a single command string or array of command strings to run sequentially.
1361
+ * Commands are executed relative to the `root` directory.
1362
+ *
1363
+ * @example
1364
+ * ```ts
1365
+ * done: 'prettier --write "./src/gen"'
1366
+ * done: ['prettier --write "./src/gen"', 'eslint --fix "./src/gen"']
1367
+ * ```
1242
1368
  */
1243
1369
  done?: string | Array<string>;
1244
1370
  };
1245
1371
  };
1246
1372
  /**
1247
- * A type/string-pattern filter used for `include`, `exclude`, and `override` matching.
1373
+ * Type/string pattern filter for include/exclude/override matching.
1248
1374
  */
1249
1375
  type PatternFilter = {
1250
1376
  type: string;
1251
1377
  pattern: string | RegExp;
1252
1378
  };
1253
1379
  /**
1254
- * A pattern filter paired with partial option overrides to apply when the pattern matches.
1380
+ * Pattern filter with partial option overrides applied when the pattern matches.
1255
1381
  */
1256
1382
  type PatternOverride<TOptions> = PatternFilter & {
1257
1383
  options: Omit<Partial<TOptions>, 'override'>;
1258
1384
  };
1259
1385
  /**
1260
- * Context passed to `resolver.resolveOptions` to apply include/exclude/override filtering
1261
- * for a given operation or schema node.
1262
- */
1263
- /**
1264
- * Resolves filtered options for a given operation or schema node.
1386
+ * Context for resolving filtered options for a given operation or schema node.
1265
1387
  *
1266
1388
  * @internal
1267
1389
  */
@@ -1274,9 +1396,8 @@ type ResolveOptionsContext<TOptions> = {
1274
1396
  /**
1275
1397
  * Base constraint for all plugin resolver objects.
1276
1398
  *
1277
- * `default`, `resolveOptions`, `resolvePath`, and `resolveFile` are injected automatically
1278
- * by `defineResolver` — plugin authors may override them but never need to implement them
1279
- * from scratch.
1399
+ * `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
1400
+ * are injected automatically by `defineResolver` — extend this type to add custom resolution methods.
1280
1401
  *
1281
1402
  * @example
1282
1403
  * ```ts
@@ -1298,20 +1419,20 @@ type Resolver = {
1298
1419
  };
1299
1420
  type PluginFactoryOptions<
1300
1421
  /**
1301
- * Name to be used for the plugin.
1422
+ * Unique plugin name.
1302
1423
  */
1303
1424
  TName extends string = string,
1304
1425
  /**
1305
- * Options of the plugin.
1426
+ * User-facing plugin options.
1306
1427
  */
1307
1428
  TOptions extends object = object,
1308
1429
  /**
1309
- * Options of the plugin that can be used later on, see `options` inside your plugin config.
1430
+ * Plugin options after defaults are applied.
1310
1431
  */
1311
1432
  TResolvedOptions extends object = TOptions,
1312
1433
  /**
1313
- * Resolver object that encapsulates the naming and path-resolution helpers used by this plugin.
1314
- * Use `defineResolver` to define the resolver object and export it alongside the plugin.
1434
+ * Resolver that encapsulates naming and path-resolution helpers.
1435
+ * Define with `defineResolver` and export alongside the plugin.
1315
1436
  */
1316
1437
  TResolver extends Resolver = Resolver> = {
1317
1438
  name: TName;
@@ -1320,9 +1441,9 @@ TResolver extends Resolver = Resolver> = {
1320
1441
  resolver: TResolver;
1321
1442
  };
1322
1443
  /**
1323
- * Internal representation of a plugin after normalization.
1324
- * Extends the user-facing `Plugin` with runtime fields populated during `kubb:plugin:setup`.
1325
- * Not part of the public API — use `Plugin` for external-facing interactions.
1444
+ * Normalized plugin after setup, with runtime fields populated.
1445
+ * For internal use only plugins use the public `Plugin` type externally.
1446
+ *
1326
1447
  * @internal
1327
1448
  */
1328
1449
  type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & {
@@ -1340,30 +1461,86 @@ type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptio
1340
1461
  version?: string;
1341
1462
  };
1342
1463
  /**
1343
- * Partial version of {@link Config} intended for user-facing config entry points.
1464
+ * Partial `Config` for user-facing entry points with sensible defaults.
1344
1465
  *
1345
- * Fields that have sensible defaults (`root`, `plugins`, `parsers`, `adapter`) are optional.
1466
+ * `UserConfig` is what you pass to `defineConfig()`. It has optional `root`, `plugins`, `parsers`, and `adapter`
1467
+ * fields (which fall back to sensible defaults). All other Config options are available, including `output`, `input`,
1468
+ * `storage`, `middleware`, `renderer`, `devtools`, and `hooks`.
1469
+ *
1470
+ * @example
1471
+ * ```ts
1472
+ * export default defineConfig({
1473
+ * input: { path: './petstore.yaml' },
1474
+ * output: { path: './src/gen' },
1475
+ * plugins: [pluginTs(), pluginZod()],
1476
+ * })
1477
+ * ```
1346
1478
  */
1347
1479
  type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter'> & {
1348
1480
  /**
1349
- * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
1481
+ * Project root directory, absolute or relative to the config file location.
1482
+ *
1483
+ * Used as the base path for `root`-relative paths (e.g., `output.path`, file paths in hooks).
1484
+ *
1350
1485
  * @default process.cwd()
1486
+ * @example
1487
+ * ```ts
1488
+ * root: '/home/user/my-project'
1489
+ * root: './my-project' // relative to config file
1490
+ * ```
1351
1491
  */
1352
1492
  root?: string;
1353
1493
  /**
1354
- * An array of parsers used to convert generated files to strings.
1355
- * Each parser handles specific file extensions (e.g. `.ts`, `.tsx`).
1494
+ * Custom parsers that convert generated AST nodes to strings (TypeScript, JSON, markdown, etc.).
1495
+ *
1496
+ * Each parser handles a specific file type. By default, Kubb uses `parserTs` from `@kubb/parser-ts` for TypeScript files.
1497
+ * Pass custom parsers to support additional languages or custom formats.
1498
+ *
1499
+ * @default [parserTs] // from @kubb/parser-ts
1500
+ * @example
1501
+ * ```ts
1502
+ * import { parserTs } from '@kubb/parser-ts'
1503
+ * import { parserJsonSchema } from '@kubb/parser-json-schema'
1356
1504
  *
1357
- * A catch-all fallback parser is always appended last for any unhandled extension.
1505
+ * parsers: [parserTs(), parserJsonSchema()]
1506
+ * ```
1507
+ *
1508
+ * @see {@link Parser} to implement a custom parser.
1358
1509
  */
1359
1510
  parsers?: Array<Parser>;
1360
1511
  /**
1361
- * Adapter that converts the input file into a `@kubb/ast` `InputNode`.
1512
+ * Adapter that parses your API specification (OpenAPI, GraphQL, AsyncAPI, etc.) into Kubb's universal AST.
1513
+ *
1514
+ * The adapter bridge between your input format and Kubb's internal representation. By default, uses the OAS adapter.
1515
+ * Pass an alternative adapter (or multiple configs with different adapters) to support different spec formats.
1516
+ *
1517
+ * @default new OasAdapter() // from @kubb/adapter-oas
1518
+ * @example
1519
+ * ```ts
1520
+ * import { Oas } from '@kubb/adapter-oas'
1521
+ *
1522
+ * adapter: new Oas({ apiVersion: '3.0.0' })
1523
+ * ```
1524
+ *
1525
+ * @see {@link Adapter} to implement a custom adapter for GraphQL or other formats.
1362
1526
  */
1363
1527
  adapter?: Adapter;
1364
1528
  /**
1365
- * An array of Kubb plugins used for code generation.
1366
- * Each entry is a hook-style plugin created with `definePlugin`.
1529
+ * Plugins that execute during the build to generate code and transform the AST.
1530
+ *
1531
+ * Each plugin processes the AST produced by the adapter and can emit files for different
1532
+ * programming languages or formats (TypeScript, Zod schemas, Faker data, etc.).
1533
+ *
1534
+ * @default [] // no plugins (useful for setup/testing)
1535
+ * @example
1536
+ * ```ts
1537
+ * plugins: [
1538
+ * pluginTs({ output: { path: './src/gen' } }),
1539
+ * pluginZod({ output: { path: './src/gen' } }),
1540
+ * ]
1541
+ * ```
1542
+ *
1543
+ * @see {@link definePlugin} to create a custom plugin.
1367
1544
  */
1368
1545
  plugins?: Array<Plugin>;
1369
1546
  };
@@ -1371,123 +1548,116 @@ type ResolveNameParams = {
1371
1548
  name: string;
1372
1549
  pluginName?: string;
1373
1550
  /**
1374
- * Specifies the type of entity being named.
1375
- * - `'file'` — customizes the name of the created file (camelCase).
1376
- * - `'function'` — customizes the exported function names (camelCase).
1377
- * - `'type'` — customizes TypeScript type names (PascalCase).
1378
- * - `'const'` — customizes variable names (camelCase).
1551
+ * Entity type being named.
1552
+ * - `'file'` — file name (camelCase)
1553
+ * - `'function'` — exported function name (camelCase)
1554
+ * - `'type'` — TypeScript type name (PascalCase)
1555
+ * - `'const'` — variable name (camelCase)
1379
1556
  */
1380
1557
  type?: 'file' | 'function' | 'type' | 'const';
1381
1558
  };
1382
1559
  /**
1383
- * Context object passed as the second argument to generator `schema`, `operation`, and
1384
- * `operations` methods.
1385
- *
1386
- * Generators are only invoked from `runPluginAstHooks`, which already guards against a
1387
- * missing adapter. This type reflects that guarantee — `ctx.adapter` and `ctx.inputNode`
1388
- * are always defined, so no runtime checks or casts are needed inside generator bodies.
1560
+ * Context object passed to generator `schema`, `operation`, and `operations` methods.
1389
1561
  *
1390
- * `ctx.options` carries the per-node resolved options for `schema`/`operation` calls
1391
- * (after exclude/include/override filtering) and the plugin-level options for `operations`.
1562
+ * The adapter is always defined (guaranteed by `runPluginAstHooks`) so no runtime checks
1563
+ * are needed. `ctx.options` carries resolved per-node options after exclude/include/override
1564
+ * filtering for individual schema/operation calls, or plugin-level options for operations.
1392
1565
  */
1393
1566
  type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1394
1567
  config: Config;
1395
1568
  /**
1396
- * Absolute path to the output directory for the current plugin.
1397
- * Shorthand for `path.resolve(config.root, config.output.path)`.
1569
+ * Absolute path to the current plugin's output directory.
1398
1570
  */
1399
1571
  root: string;
1400
1572
  /**
1401
- * Returns the output mode for the given output config.
1402
- * Returns `'single'` when `output.path` has a file extension, `'split'` otherwise.
1573
+ * Determine output mode based on the output config.
1574
+ * Returns `'single'` when `output.path` is a file, `'split'` for a directory.
1403
1575
  */
1404
1576
  getMode: (output: {
1405
1577
  path: string;
1406
1578
  }) => 'single' | 'split';
1407
1579
  driver: PluginDriver;
1408
1580
  /**
1409
- * Get a plugin by name. Returns the plugin typed via `Kubb.PluginRegistry` when
1410
- * the name is a registered key, otherwise returns the generic `Plugin`.
1581
+ * Get a plugin by name, typed via `Kubb.PluginRegistry` when registered.
1411
1582
  */
1412
1583
  getPlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined;
1413
1584
  getPlugin(name: string): Plugin | undefined;
1414
1585
  /**
1415
- * Like `getPlugin` but throws a descriptive error when the plugin is not found.
1586
+ * Get a plugin by name, throws an error if not found.
1416
1587
  */
1417
1588
  requirePlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]>;
1418
1589
  requirePlugin(name: string): Plugin;
1419
1590
  /**
1420
- * Get a resolver by plugin name. Returns the resolver typed via `Kubb.PluginRegistry` when
1421
- * the name is a registered key, otherwise returns the generic `Resolver`.
1591
+ * Get a resolver by plugin name, typed via `Kubb.PluginRegistry` when registered.
1422
1592
  */
1423
1593
  getResolver<TName extends keyof Kubb.PluginRegistry>(name: TName): Kubb.PluginRegistry[TName]['resolver'];
1424
1594
  getResolver(name: string): Resolver;
1425
1595
  /**
1426
- * Add files only when they do not exist yet.
1596
+ * Add files only if they don't exist.
1427
1597
  */
1428
1598
  addFile: (...file: Array<FileNode>) => Promise<void>;
1429
1599
  /**
1430
- * Merge multiple sources into the same output file.
1600
+ * Merge sources into the same output file.
1431
1601
  */
1432
1602
  upsertFile: (...file: Array<FileNode>) => Promise<void>;
1433
1603
  hooks: AsyncEventEmitter<KubbHooks>;
1434
1604
  /**
1435
- * The current plugin.
1605
+ * The current plugin instance.
1436
1606
  */
1437
1607
  plugin: Plugin<TOptions>;
1438
1608
  /**
1439
- * Resolver for the current plugin.
1609
+ * The current plugin's resolver.
1440
1610
  */
1441
1611
  resolver: TOptions['resolver'];
1442
1612
  /**
1443
- * Composed transformer for the current plugin.
1613
+ * The current plugin's transformer.
1444
1614
  */
1445
1615
  transformer: Visitor | undefined;
1446
1616
  /**
1447
- * Emit a warning via the build event system.
1617
+ * Emit a warning.
1448
1618
  */
1449
1619
  warn: (message: string) => void;
1450
1620
  /**
1451
- * Emit an error via the build event system.
1621
+ * Emit an error.
1452
1622
  */
1453
1623
  error: (error: string | Error) => void;
1454
1624
  /**
1455
- * Emit an info message via the build event system.
1625
+ * Emit an info message.
1456
1626
  */
1457
1627
  info: (message: string) => void;
1458
1628
  /**
1459
- * Opens the Kubb Studio URL for the current `inputNode` in the default browser.
1629
+ * Open the current input node in Kubb Studio.
1460
1630
  */
1461
1631
  openInStudio: (options?: DevtoolsOptions) => Promise<void>;
1462
1632
  /**
1463
- * The adapter from `@kubb/ast`.
1633
+ * The configured adapter instance.
1464
1634
  */
1465
1635
  adapter: Adapter;
1466
1636
  /**
1467
- * The universal `@kubb/ast` `InputNode` produced by the configured adapter.
1637
+ * The universal `InputNode` produced by the adapter.
1468
1638
  */
1469
1639
  inputNode: InputNode;
1470
1640
  /**
1471
- * Per-node resolved options (after exclude/include/override filtering).
1641
+ * Resolved options after exclude/include/override filtering.
1472
1642
  */
1473
1643
  options: TOptions['resolvedOptions'];
1474
1644
  };
1475
1645
  /**
1476
- * Configure generated file output location and behavior.
1646
+ * Output configuration for generated files.
1477
1647
  */
1478
1648
  type Output<_TOptions = unknown> = {
1479
1649
  /**
1480
- * Path to the output folder or file that will contain generated code.
1650
+ * Output folder or file path for generated code.
1481
1651
  */
1482
1652
  path: string;
1483
1653
  /**
1484
- * Text or function appended at the start of every generated file.
1485
- * When a function, receives the current `InputNode` and must return a string.
1654
+ * Text or function prepended to every generated file.
1655
+ * When a function, receives the current `InputNode` and returns a string.
1486
1656
  */
1487
1657
  banner?: string | ((node?: InputNode) => string);
1488
1658
  /**
1489
- * Text or function appended at the end of every generated file.
1490
- * When a function, receives the current `InputNode` and must return a string.
1659
+ * Text or function appended to every generated file.
1660
+ * When a function, receives the current `InputNode` and returns a string.
1491
1661
  */
1492
1662
  footer?: string | ((node?: InputNode) => string);
1493
1663
  /**
@@ -1498,14 +1668,14 @@ type Output<_TOptions = unknown> = {
1498
1668
  } & ExtractRegistryKey<Kubb.PluginOptionsRegistry, 'output'>;
1499
1669
  type Group = {
1500
1670
  /**
1501
- * Determines how files are grouped into subdirectories.
1502
- * - `'tag'` groups files by OpenAPI tags.
1503
- * - `'path'` groups files by OpenAPI paths.
1671
+ * How to group files into subdirectories.
1672
+ * - `'tag'` group by OpenAPI tags
1673
+ * - `'path'` group by OpenAPI paths
1504
1674
  */
1505
1675
  type: 'tag' | 'path';
1506
1676
  /**
1507
- * Returns the subdirectory name for a given group value.
1508
- * Defaults to `${camelCase(group)}Controller` for tags and the first path segment for paths.
1677
+ * Function that returns the subdirectory name for a group value.
1678
+ * Defaults to `${camelCase(group)}Controller` for tags, first path segment for paths.
1509
1679
  */
1510
1680
  name?: (context: {
1511
1681
  group: string;
@@ -1513,12 +1683,13 @@ type Group = {
1513
1683
  };
1514
1684
  type LoggerOptions = {
1515
1685
  /**
1686
+ * Log level for output verbosity.
1516
1687
  * @default 3
1517
1688
  */
1518
1689
  logLevel: (typeof logLevel)[keyof typeof logLevel];
1519
1690
  };
1520
1691
  /**
1521
- * Shared context passed to all plugins, parsers, and other internals.
1692
+ * Shared context passed to plugins, parsers, and other internals.
1522
1693
  */
1523
1694
  type LoggerContext = AsyncEventEmitter<KubbHooks>;
1524
1695
  type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
@@ -1527,44 +1698,35 @@ type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
1527
1698
  };
1528
1699
  type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Logger<TOptions>;
1529
1700
  /**
1530
- * Context passed to a hook-style plugin's `kubb:plugin:setup` handler.
1531
- * Provides methods to register generators, configure the resolver, transformer,
1532
- * and renderer, as well as access to the current build configuration.
1701
+ * Context for hook-style plugin `kubb:plugin:setup` handler.
1702
+ * Provides methods to register generators, configure resolvers, transformers, and renderers.
1533
1703
  */
1534
1704
  type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1535
1705
  /**
1536
- * Register a generator on this plugin. Generators are invoked during the AST walk
1537
- * (schema/operation/operations) exactly like generators declared statically on `createPlugin`.
1706
+ * Register a generator dynamically. Generators fire during the AST walk (schema/operation/operations)
1707
+ * just like generators declared statically on `createPlugin`.
1538
1708
  */
1539
1709
  addGenerator<TElement = unknown>(generator: Generator<TFactory, TElement>): void;
1540
1710
  /**
1541
- * Set or partially override the resolver for this plugin.
1542
- * The resolver controls file naming and path resolution for generated files.
1543
- *
1544
- * When `TFactory` is a concrete `PluginFactoryOptions` (e.g. `PluginClient`),
1545
- * the resolver parameter is typed to the plugin's own resolver type (e.g. `ResolverClient`).
1711
+ * Set or override the resolver for this plugin.
1712
+ * The resolver controls file naming and path resolution.
1546
1713
  */
1547
1714
  setResolver(resolver: Partial<TFactory['resolver']>): void;
1548
1715
  /**
1549
- * Set the AST transformer (visitor) for this plugin.
1550
- * The transformer pre-processes nodes before they reach the generators.
1716
+ * Set the AST transformer to pre-process nodes before they reach generators.
1551
1717
  */
1552
1718
  setTransformer(visitor: Visitor): void;
1553
1719
  /**
1554
- * Set the renderer factory for this plugin.
1555
- * Used to process JSX elements returned by generators.
1720
+ * Set the renderer factory to process JSX elements from generators.
1556
1721
  */
1557
1722
  setRenderer(renderer: RendererFactory): void;
1558
1723
  /**
1559
- * Set the resolved options for the build loop. These options are merged into the
1560
- * normalized plugin's `options` object (which includes `output`, `exclude`, `override`).
1561
- *
1562
- * Call this in `kubb:plugin:setup` to provide the resolved options that generators
1563
- * and the build loop need (e.g., `enumType`, `optionalType`, `group`).
1724
+ * Set resolved options merged into the normalized plugin's `options`.
1725
+ * Call this in `kubb:plugin:setup` to provide options generators need.
1564
1726
  */
1565
1727
  setOptions(options: TFactory['resolvedOptions']): void;
1566
1728
  /**
1567
- * Inject a raw file into the build output, bypassing the normal generation pipeline.
1729
+ * Inject a raw file into the build output, bypassing the generation pipeline.
1568
1730
  */
1569
1731
  injectFile(userFileNode: UserFileNode): void;
1570
1732
  /**
@@ -1572,16 +1734,16 @@ type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactor
1572
1734
  */
1573
1735
  updateConfig(config: Partial<Config>): void;
1574
1736
  /**
1575
- * The resolved build configuration at the time of setup.
1737
+ * The resolved build configuration at setup time.
1576
1738
  */
1577
1739
  config: Config;
1578
1740
  /**
1579
- * The plugin's own options as passed by the user.
1741
+ * The plugin's user-provided options.
1580
1742
  */
1581
1743
  options: TFactory['options'];
1582
1744
  };
1583
1745
  /**
1584
- * Context passed to a hook-style plugin's `kubb:build:start` handler.
1746
+ * Context for hook-style plugin `kubb:build:start` handler.
1585
1747
  * Fires immediately before the plugin execution loop begins.
1586
1748
  */
1587
1749
  type KubbBuildStartContext = {
@@ -1589,15 +1751,13 @@ type KubbBuildStartContext = {
1589
1751
  adapter: Adapter;
1590
1752
  inputNode: InputNode;
1591
1753
  /**
1592
- * Get a plugin by name. Returns the plugin typed via `Kubb.PluginRegistry` when
1593
- * the name is a registered key, otherwise returns the generic `Plugin`.
1754
+ * Get a plugin by name, typed via `Kubb.PluginRegistry` when registered.
1594
1755
  */
1595
1756
  getPlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined;
1596
1757
  getPlugin(name: string): Plugin | undefined;
1597
1758
  /**
1598
- * Returns all files currently in the file manager.
1599
- * Call this lazily (e.g. inside a `kubb:plugin:end` listener) to see files added by plugins
1600
- * that have already run.
1759
+ * Get all files currently in the file manager.
1760
+ * Call this lazily (e.g. in `kubb:plugin:end`) to see files added by prior plugins.
1601
1761
  */
1602
1762
  readonly files: ReadonlyArray<FileNode>;
1603
1763
  /**
@@ -1608,26 +1768,24 @@ type KubbBuildStartContext = {
1608
1768
  upsertFile: (...files: Array<FileNode>) => void;
1609
1769
  };
1610
1770
  /**
1611
- * Context passed to `kubb:plugins:end` handlers.
1612
- * Fires after all plugins have run and per-plugin barrels have been written,
1613
- * but BEFORE files are written to disk.
1614
- * Middleware that needs to inject final files (e.g. a root barrel) should use this event.
1771
+ * Context for `kubb:plugins:end` handlers.
1772
+ * Fires after plugins run and per-plugin barrels are written, before final write to disk.
1773
+ * Middleware that needs final files (e.g. root barrel) use this event.
1615
1774
  */
1616
1775
  type KubbPluginsEndContext = {
1617
1776
  config: Config;
1618
1777
  /**
1619
- * Returns all files currently in the file manager (lazy snapshot).
1620
- * Includes files added by plugins and per-plugin barrel middleware.
1778
+ * All files currently in the file manager (lazy snapshot).
1621
1779
  */
1622
1780
  readonly files: ReadonlyArray<FileNode>;
1623
1781
  /**
1624
- * Upsert one or more files into the file manager.
1625
- * Files added here will be included in the write pass that follows.
1782
+ * Upsert files into the file manager.
1783
+ * Files added here are included in the write pass.
1626
1784
  */
1627
1785
  upsertFile: (...files: Array<FileNode>) => void;
1628
1786
  };
1629
1787
  /**
1630
- * Context passed to a hook-style plugin's `kubb:build:end` handler.
1788
+ * Context for hook-style plugin `kubb:build:end` handler.
1631
1789
  * Fires after all files have been written to disk.
1632
1790
  */
1633
1791
  type KubbBuildEndContext = {
@@ -1690,11 +1848,11 @@ type KubbFilesProcessingStartContext = {
1690
1848
  };
1691
1849
  type KubbFileProcessingUpdateContext = {
1692
1850
  /**
1693
- * Number of files processed so far.
1851
+ * Number of files processed.
1694
1852
  */
1695
1853
  processed: number;
1696
1854
  /**
1697
- * Total number of files to process.
1855
+ * Total files to process.
1698
1856
  */
1699
1857
  total: number;
1700
1858
  /**
@@ -1710,8 +1868,7 @@ type KubbFileProcessingUpdateContext = {
1710
1868
  */
1711
1869
  file: FileNode;
1712
1870
  /**
1713
- * Kubb configuration.
1714
- * Provides access to the current config during file processing.
1871
+ * The current build configuration.
1715
1872
  */
1716
1873
  config: Config;
1717
1874
  };
@@ -1750,42 +1907,118 @@ type KubbHookEndContext = {
1750
1907
  error: Error | null;
1751
1908
  };
1752
1909
  type ByTag = {
1910
+ /**
1911
+ * Filter by OpenAPI `tags` field. Matches one or more tags assigned to operations.
1912
+ */
1753
1913
  type: 'tag';
1914
+ /**
1915
+ * Tag name to match (case-sensitive). Can be a literal string or regex pattern.
1916
+ */
1754
1917
  pattern: string | RegExp;
1755
1918
  };
1756
1919
  type ByOperationId = {
1920
+ /**
1921
+ * Filter by OpenAPI `operationId` field. Each operation (GET, POST, etc.) has a unique identifier.
1922
+ */
1757
1923
  type: 'operationId';
1924
+ /**
1925
+ * Operation ID to match (case-sensitive). Can be a literal string or regex pattern.
1926
+ */
1758
1927
  pattern: string | RegExp;
1759
1928
  };
1760
1929
  type ByPath = {
1930
+ /**
1931
+ * Filter by OpenAPI `path` (URL endpoint). Useful to group or filter by service segments like `/pets`, `/users`, etc.
1932
+ */
1761
1933
  type: 'path';
1934
+ /**
1935
+ * URL path to match (case-sensitive). Can be a literal string or regex pattern. Matches against the full path.
1936
+ */
1762
1937
  pattern: string | RegExp;
1763
1938
  };
1764
1939
  type ByMethod = {
1940
+ /**
1941
+ * Filter by HTTP method: `'get'`, `'post'`, `'put'`, `'delete'`, `'patch'`, `'head'`, `'options'`.
1942
+ */
1765
1943
  type: 'method';
1944
+ /**
1945
+ * HTTP method to match (case-insensitive when using string, or regex for dynamic matching).
1946
+ */
1766
1947
  pattern: HttpMethod | RegExp;
1767
1948
  };
1768
1949
  type BySchemaName = {
1950
+ /**
1951
+ * Filter by schema component name (TypeScript or JSON schema). Matches schemas in `#/components/schemas`.
1952
+ */
1769
1953
  type: 'schemaName';
1954
+ /**
1955
+ * Schema name to match (case-sensitive). Can be a literal string or regex pattern.
1956
+ */
1770
1957
  pattern: string | RegExp;
1771
1958
  };
1772
1959
  type ByContentType = {
1960
+ /**
1961
+ * Filter by response or request content type: `'application/json'`, `'application/xml'`, etc.
1962
+ */
1773
1963
  type: 'contentType';
1964
+ /**
1965
+ * Content type to match (case-sensitive). Can be a literal string or regex pattern.
1966
+ */
1774
1967
  pattern: string | RegExp;
1775
1968
  };
1776
1969
  /**
1777
1970
  * A pattern filter that prevents matching nodes from being generated.
1778
- * Match by `tag`, `operationId`, `path`, `method`, `contentType`, or `schemaName`.
1971
+ *
1972
+ * Use to skip code generation for specific operations or schemas. For example, exclude deprecated endpoints
1973
+ * or internal-only schemas. Can filter by tag, operationId, path, HTTP method, content type, or schema name.
1974
+ *
1975
+ * @example
1976
+ * ```ts
1977
+ * exclude: [
1978
+ * { type: 'tag', pattern: 'internal' }, // skip "internal" tag
1979
+ * { type: 'path', pattern: /^\/admin/ }, // skip all /admin endpoints
1980
+ * { type: 'operationId', pattern: 'deprecated_*' } // skip operationIds matching pattern
1981
+ * ]
1982
+ * ```
1779
1983
  */
1780
1984
  type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
1781
1985
  /**
1782
1986
  * A pattern filter that restricts generation to only matching nodes.
1783
- * Match by `tag`, `operationId`, `path`, `method`, `contentType`, or `schemaName`.
1987
+ *
1988
+ * Use to generate code for a subset of operations or schemas. For example, only generate for a specific service
1989
+ * tag or only for "production" endpoints. Can filter by tag, operationId, path, HTTP method, content type, or schema name.
1990
+ *
1991
+ * @example
1992
+ * ```ts
1993
+ * include: [
1994
+ * { type: 'tag', pattern: 'public' }, // generate only "public" tag
1995
+ * { type: 'path', pattern: /^\/api\/v1/ }, // generate only v1 endpoints
1996
+ * ]
1997
+ * ```
1784
1998
  */
1785
1999
  type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
1786
2000
  /**
1787
2001
  * A pattern filter paired with partial option overrides applied when the pattern matches.
1788
- * Match by `tag`, `operationId`, `path`, `method`, `schemaName`, or `contentType`.
2002
+ *
2003
+ * Use to customize generation for specific operations or schemas. For example, apply different output paths
2004
+ * for different tags, or use custom resolver functions per operation. Can filter by tag, operationId, path,
2005
+ * HTTP method, schema name, or content type.
2006
+ *
2007
+ * @example
2008
+ * ```ts
2009
+ * override: [
2010
+ * {
2011
+ * type: 'tag',
2012
+ * pattern: 'admin',
2013
+ * options: { output: { path: './src/gen/admin' } } // admin APIs go to separate folder
2014
+ * },
2015
+ * {
2016
+ * type: 'operationId',
2017
+ * pattern: 'listPets',
2018
+ * options: { exclude: true } // skip this specific operation
2019
+ * }
2020
+ * ]
2021
+ * ```
1789
2022
  */
1790
2023
  type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
1791
2024
  options: Partial<TOptions>;
@@ -1912,4 +2145,4 @@ type CLIOptions = {
1912
2145
  type PossibleConfig<TCliOptions = undefined> = PossiblePromise<Config | Config[]> | ((...args: [TCliOptions] extends [undefined] ? [] : [TCliOptions]) => PossiblePromise<Config | Config[]>);
1913
2146
  //#endregion
1914
2147
  export { defineParser as $, KubbPluginStartContext as A, Override as B, KubbGenerationSummaryContext as C, KubbLifecycleStartContext as D, KubbInfoContext as E, Logger as F, ResolveOptionsContext as G, PossibleConfig as H, LoggerContext as I, ResolverFileParams as J, Resolver as K, LoggerOptions as L, KubbSuccessContext as M, KubbVersionNewContext as N, KubbPluginEndContext as O, KubbWarnContext as P, Parser as Q, NormalizedPlugin as R, KubbGenerationStartContext as S, KubbHookStartContext as T, ResolveBannerContext as U, PluginFactoryOptions as V, ResolveNameParams as W, UserConfig as X, ResolverPathParams as Y, UserLogger as Z, KubbErrorContext as _, logLevel as _t, Config as a, createKubb as at, KubbFilesProcessingStartContext as b, GeneratorContext as c, Plugin as ct, InputData as d, defineGenerator as dt, Middleware as et, InputPath as f, Storage as ft, KubbDebugContext as g, createRenderer as gt, KubbConfigEndContext as h, RendererFactory as ht, CLIOptions as i, BuildOutput as it, KubbPluginsEndContext as j, KubbPluginSetupContext as k, Group as l, definePlugin as lt, KubbBuildStartContext as m, Renderer as mt, AdapterFactoryOptions as n, Kubb$1 as nt, DevtoolsOptions as o, PluginDriver as ot, KubbBuildEndContext as p, createStorage as pt, ResolverContext as q, AdapterSource as r, KubbHooks as rt, Exclude$1 as s, FileManager as st, Adapter as t, defineMiddleware as tt, Include as u, Generator as ut, KubbFileProcessingUpdateContext as v, AsyncEventEmitter as vt, KubbHookEndContext as w, KubbGenerationEndContext as x, KubbFilesProcessingEndContext as y, Output as z };
1915
- //# sourceMappingURL=types-bVvdPbki.d.ts.map
2148
+ //# sourceMappingURL=types-CuNocrbJ.d.ts.map