@kubb/plugin-ts 4.4.1 → 4.5.0

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.
@@ -557,170 +557,6 @@ type FileMetaBase = {
557
557
  pluginKey?: Plugin['key'];
558
558
  };
559
559
  //#endregion
560
- //#region ../plugin-oas/src/generators/createReactGenerator.d.ts
561
- type ReactGenerator<TOptions extends PluginFactoryOptions> = {
562
- name: string;
563
- type: 'react';
564
- Operations: (props: OperationsProps<TOptions>) => KubbNode;
565
- Operation: (props: OperationProps<TOptions>) => KubbNode;
566
- Schema: (props: SchemaProps$1<TOptions>) => KubbNode;
567
- };
568
- //#endregion
569
- //#region ../plugin-oas/src/generators/types.d.ts
570
- type OperationsProps<TOptions extends PluginFactoryOptions> = {
571
- /**
572
- * @deprecated
573
- */
574
- instance: Omit<OperationGenerator<TOptions>, 'build'>;
575
- options: TOptions['resolvedOptions'];
576
- operations: Array<Operation$1>;
577
- };
578
- type OperationProps<TOptions extends PluginFactoryOptions> = {
579
- /**
580
- * @deprecated
581
- */
582
- instance: Omit<OperationGenerator<TOptions>, 'build'>;
583
- options: TOptions['resolvedOptions'];
584
- operation: Operation$1;
585
- };
586
- type SchemaProps$1<TOptions extends PluginFactoryOptions> = {
587
- instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
588
- options: TOptions['resolvedOptions'];
589
- schema: {
590
- name: string;
591
- tree: Array<Schema>;
592
- value: SchemaObject$1;
593
- };
594
- };
595
- type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
596
- //#endregion
597
- //#region ../plugin-oas/src/generators/createGenerator.d.ts
598
- type CoreGenerator<TOptions extends PluginFactoryOptions> = {
599
- name: string;
600
- type: 'core';
601
- operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
602
- operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
603
- schema: (props: SchemaProps$1<TOptions>) => Promise<KubbFile.File[]>;
604
- };
605
- //#endregion
606
- //#region ../plugin-oas/src/types.d.ts
607
- type ResolvePathOptions = {
608
- pluginKey?: Plugin['key'];
609
- group?: {
610
- tag?: string;
611
- path?: string;
612
- };
613
- type?: ResolveNameParams['type'];
614
- };
615
- /**
616
- * `propertyName` is the ref name + resolved with the nameResolver
617
- * @example import { Pet } from './Pet'
618
- *
619
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
620
- *
621
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
622
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
623
- */
624
- type Ref = {
625
- propertyName: string;
626
- originalName: string;
627
- path: KubbFile.OptionalPath;
628
- pluginKey?: Plugin['key'];
629
- };
630
- type Refs = Record<string, Ref>;
631
- type OperationSchema = {
632
- /**
633
- * Converted name, contains already `PathParams`, `QueryParams`, ...
634
- */
635
- name: string;
636
- schema: SchemaObject$1;
637
- operation?: Operation$1;
638
- /**
639
- * OperationName in PascalCase, only being used in OperationGenerator
640
- */
641
- operationName: string;
642
- description?: string;
643
- statusCode?: number;
644
- keys?: string[];
645
- keysToOmit?: string[];
646
- withData?: boolean;
647
- };
648
- type OperationSchemas = {
649
- pathParams?: OperationSchema & {
650
- keysToOmit?: never;
651
- };
652
- queryParams?: OperationSchema & {
653
- keysToOmit?: never;
654
- };
655
- headerParams?: OperationSchema & {
656
- keysToOmit?: never;
657
- };
658
- request?: OperationSchema;
659
- response: OperationSchema;
660
- responses: Array<OperationSchema>;
661
- statusCodes?: Array<OperationSchema>;
662
- errors?: Array<OperationSchema>;
663
- };
664
- type ByTag = {
665
- type: 'tag';
666
- pattern: string | RegExp;
667
- };
668
- type ByOperationId = {
669
- type: 'operationId';
670
- pattern: string | RegExp;
671
- };
672
- type ByPath = {
673
- type: 'path';
674
- pattern: string | RegExp;
675
- };
676
- type ByMethod = {
677
- type: 'method';
678
- pattern: HttpMethod | RegExp;
679
- };
680
- type BySchemaName = {
681
- type: 'schemaName';
682
- pattern: string | RegExp;
683
- };
684
- type ByContentType = {
685
- type: 'contentType';
686
- pattern: string | RegExp;
687
- };
688
- type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
689
- type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
690
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
691
- options: Partial<TOptions>;
692
- };
693
- //#endregion
694
- //#region ../plugin-oas/src/OperationGenerator.d.ts
695
- type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
696
- fabric: Fabric;
697
- oas: Oas;
698
- exclude: Array<Exclude$1> | undefined;
699
- include: Array<Include> | undefined;
700
- override: Array<Override<TOptions>> | undefined;
701
- contentType: contentType | undefined;
702
- pluginManager: PluginManager;
703
- /**
704
- * Current plugin
705
- */
706
- plugin: Plugin<TPluginOptions>;
707
- mode: KubbFile.Mode;
708
- };
709
- declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
710
- #private;
711
- getSchemas(operation: Operation$1, {
712
- resolveName
713
- }?: {
714
- resolveName?: (name: string) => string;
715
- }): OperationSchemas;
716
- getOperations(): Promise<Array<{
717
- path: string;
718
- method: HttpMethod;
719
- operation: Operation$1;
720
- }>>;
721
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
722
- }
723
- //#endregion
724
560
  //#region ../plugin-oas/src/SchemaMapper.d.ts
725
561
  type SchemaKeywordMapper = {
726
562
  object: {
@@ -938,8 +774,96 @@ type Schema = {
938
774
  keyword: string;
939
775
  } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
940
776
  //#endregion
777
+ //#region ../plugin-oas/src/types.d.ts
778
+ type ResolvePathOptions = {
779
+ pluginKey?: Plugin['key'];
780
+ group?: {
781
+ tag?: string;
782
+ path?: string;
783
+ };
784
+ type?: ResolveNameParams['type'];
785
+ };
786
+ /**
787
+ * `propertyName` is the ref name + resolved with the nameResolver
788
+ * @example import { Pet } from './Pet'
789
+ *
790
+ * `originalName` is the original name used(in PascalCase), only used to remove duplicates
791
+ *
792
+ * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
793
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
794
+ */
795
+ type Ref = {
796
+ propertyName: string;
797
+ originalName: string;
798
+ path: KubbFile.OptionalPath;
799
+ pluginKey?: Plugin['key'];
800
+ };
801
+ type Refs = Record<string, Ref>;
802
+ type OperationSchema = {
803
+ /**
804
+ * Converted name, contains already `PathParams`, `QueryParams`, ...
805
+ */
806
+ name: string;
807
+ schema: SchemaObject$1;
808
+ operation?: Operation$1;
809
+ /**
810
+ * OperationName in PascalCase, only being used in OperationGenerator
811
+ */
812
+ operationName: string;
813
+ description?: string;
814
+ statusCode?: number;
815
+ keys?: string[];
816
+ keysToOmit?: string[];
817
+ withData?: boolean;
818
+ };
819
+ type OperationSchemas = {
820
+ pathParams?: OperationSchema & {
821
+ keysToOmit?: never;
822
+ };
823
+ queryParams?: OperationSchema & {
824
+ keysToOmit?: never;
825
+ };
826
+ headerParams?: OperationSchema & {
827
+ keysToOmit?: never;
828
+ };
829
+ request?: OperationSchema;
830
+ response: OperationSchema;
831
+ responses: Array<OperationSchema>;
832
+ statusCodes?: Array<OperationSchema>;
833
+ errors?: Array<OperationSchema>;
834
+ };
835
+ type ByTag = {
836
+ type: 'tag';
837
+ pattern: string | RegExp;
838
+ };
839
+ type ByOperationId = {
840
+ type: 'operationId';
841
+ pattern: string | RegExp;
842
+ };
843
+ type ByPath = {
844
+ type: 'path';
845
+ pattern: string | RegExp;
846
+ };
847
+ type ByMethod = {
848
+ type: 'method';
849
+ pattern: HttpMethod | RegExp;
850
+ };
851
+ type BySchemaName = {
852
+ type: 'schemaName';
853
+ pattern: string | RegExp;
854
+ };
855
+ type ByContentType = {
856
+ type: 'contentType';
857
+ pattern: string | RegExp;
858
+ };
859
+ type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
860
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
861
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
862
+ options: Partial<TOptions>;
863
+ };
864
+ //#endregion
941
865
  //#region ../plugin-oas/src/SchemaGenerator.d.ts
942
- type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
866
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
943
867
  fabric: Fabric;
944
868
  oas: Oas;
945
869
  pluginManager: PluginManager;
@@ -972,15 +896,15 @@ type SchemaGeneratorOptions = {
972
896
  * TODO TODO add docs
973
897
  * @beta
974
898
  */
975
- schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
899
+ schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
976
900
  };
977
901
  };
978
- type SchemaProps = {
902
+ type SchemaProps$1 = {
979
903
  schemaObject?: SchemaObject$1;
980
904
  name?: string;
981
905
  parentName?: string;
982
906
  };
983
- declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
907
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
984
908
  #private;
985
909
  refs: Refs;
986
910
  /**
@@ -988,16 +912,86 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
988
912
  * Delegates to getBaseTypeFromSchema internally and
989
913
  * optionally adds a union with null.
990
914
  */
991
- parse(props: SchemaProps): Schema[];
992
- deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
993
- find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
915
+ parse(props: SchemaProps$1): Schema[];
994
916
  static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
995
- static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
996
917
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
997
918
  static combineObjects(tree: Schema[] | undefined): Schema[];
998
919
  build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
999
920
  }
1000
921
  //#endregion
922
+ //#region ../plugin-oas/src/generators/createGenerator.d.ts
923
+ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
924
+ name: string;
925
+ type: 'core';
926
+ operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
927
+ operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
928
+ schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
929
+ };
930
+ //#endregion
931
+ //#region ../plugin-oas/src/generators/createReactGenerator.d.ts
932
+ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
933
+ name: string;
934
+ type: 'react';
935
+ Operations: (props: OperationsProps<TOptions>) => KubbNode;
936
+ Operation: (props: OperationProps<TOptions>) => KubbNode;
937
+ Schema: (props: SchemaProps<TOptions>) => KubbNode;
938
+ };
939
+ //#endregion
940
+ //#region ../plugin-oas/src/generators/types.d.ts
941
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
942
+ config: Config;
943
+ generator: Omit<OperationGenerator<TOptions>, 'build'>;
944
+ plugin: Plugin<TOptions>;
945
+ operations: Array<Operation$1>;
946
+ };
947
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
948
+ config: Config;
949
+ generator: Omit<OperationGenerator<TOptions>, 'build'>;
950
+ plugin: Plugin<TOptions>;
951
+ operation: Operation$1;
952
+ };
953
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
954
+ config: Config;
955
+ generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
956
+ plugin: Plugin<TOptions>;
957
+ schema: {
958
+ name: string;
959
+ tree: Array<Schema>;
960
+ value: SchemaObject$1;
961
+ };
962
+ };
963
+ type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
964
+ //#endregion
965
+ //#region ../plugin-oas/src/OperationGenerator.d.ts
966
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
967
+ fabric: Fabric;
968
+ oas: Oas;
969
+ exclude: Array<Exclude$1> | undefined;
970
+ include: Array<Include> | undefined;
971
+ override: Array<Override<TOptions>> | undefined;
972
+ contentType: contentType | undefined;
973
+ pluginManager: PluginManager;
974
+ /**
975
+ * Current plugin
976
+ */
977
+ plugin: Plugin<TPluginOptions>;
978
+ mode: KubbFile.Mode;
979
+ };
980
+ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
981
+ #private;
982
+ getSchemas(operation: Operation$1, {
983
+ resolveName
984
+ }?: {
985
+ resolveName?: (name: string) => string;
986
+ }): OperationSchemas;
987
+ getOperations(): Promise<Array<{
988
+ path: string;
989
+ method: HttpMethod;
990
+ operation: Operation$1;
991
+ }>>;
992
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
993
+ }
994
+ //#endregion
1001
995
  //#region src/types.d.ts
1002
996
  type Options$1 = {
1003
997
  /**
@@ -1110,5 +1104,5 @@ type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, {
1110
1104
  usedEnumNames: Record<string, number>;
1111
1105
  }, ResolvePathOptions>;
1112
1106
  //#endregion
1113
- export { UserPluginWithLifeCycle as a, ReactGenerator as i, PluginTs as n, OasTypes as o, Schema as r, SchemaObject$1 as s, Options$1 as t };
1114
- //# sourceMappingURL=types-DEsrThze.d.cts.map
1107
+ export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, ReactGenerator as r, SchemaObject$1 as s, Options$1 as t };
1108
+ //# sourceMappingURL=types-BdHzvKY0.d.cts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-ts",
3
- "version": "4.4.1",
3
+ "version": "4.5.0",
4
4
  "description": "TypeScript code generation plugin for Kubb, transforming OpenAPI schemas into TypeScript interfaces, types, and utility functions.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -64,19 +64,19 @@
64
64
  }
65
65
  ],
66
66
  "dependencies": {
67
- "@kubb/fabric-core": "0.2.10",
68
- "@kubb/react-fabric": "0.2.10",
67
+ "@kubb/fabric-core": "0.2.14",
68
+ "@kubb/react-fabric": "0.2.14",
69
69
  "remeda": "^2.32.0",
70
70
  "typescript": "5.9.3",
71
- "@kubb/core": "4.4.1",
72
- "@kubb/oas": "4.4.1",
73
- "@kubb/plugin-oas": "4.4.1"
71
+ "@kubb/core": "4.5.0",
72
+ "@kubb/oas": "4.5.0",
73
+ "@kubb/plugin-oas": "4.5.0"
74
74
  },
75
75
  "devDependencies": {
76
- "@kubb/plugin-oas": "4.4.1"
76
+ "@kubb/plugin-oas": "4.5.0"
77
77
  },
78
78
  "peerDependencies": {
79
- "@kubb/react-fabric": "0.2.10"
79
+ "@kubb/react-fabric": "0.2.14"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=20"
@@ -36,16 +36,11 @@ export function Type({ name, typedName, tree, keysToOmit, schema, optionalType,
36
36
  (tree
37
37
  .map((current, _index, siblings) =>
38
38
  parse(
39
- { parent: undefined, current, siblings },
39
+ { name, schema, parent: undefined, current, siblings },
40
40
  {
41
- name,
42
- typedName,
43
- description,
44
- keysToOmit,
45
41
  optionalType,
46
42
  enumType,
47
43
  mapper,
48
- syntaxType,
49
44
  },
50
45
  ),
51
46
  )
@@ -1,2 +1,2 @@
1
- export { typeGenerator } from './typeGenerator.tsx'
2
1
  export { oasGenerator } from './oasGenerator.tsx'
2
+ export { typeGenerator } from './typeGenerator.tsx'
@@ -1,5 +1,5 @@
1
- import { usePlugin, usePluginManager } from '@kubb/core/hooks'
2
- import { createReactGenerator } from '@kubb/plugin-oas'
1
+ import { usePluginManager } from '@kubb/core/hooks'
2
+ import { createReactGenerator } from '@kubb/plugin-oas/generators'
3
3
  import { useOas } from '@kubb/plugin-oas/hooks'
4
4
  import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
5
5
  import { File } from '@kubb/react-fabric'
@@ -8,11 +8,11 @@ import type { PluginTs } from '../types.ts'
8
8
 
9
9
  export const oasGenerator = createReactGenerator<PluginTs>({
10
10
  name: 'oas',
11
- Operations() {
11
+ Operations({ plugin }) {
12
12
  const {
13
13
  options: { output },
14
14
  key: pluginKey,
15
- } = usePlugin<PluginTs>()
15
+ } = plugin
16
16
  const pluginManager = usePluginManager()
17
17
  const oas = useOas()
18
18
 
@@ -1,16 +1,9 @@
1
1
  import type { PluginManager } from '@kubb/core'
2
- import { useMode, usePlugin, usePluginManager } from '@kubb/core/hooks'
2
+ import { useMode, usePluginManager } from '@kubb/core/hooks'
3
3
  import transformers from '@kubb/core/transformers'
4
4
  import { print } from '@kubb/fabric-core/parsers/typescript'
5
- import {
6
- createReactGenerator,
7
- isKeyword,
8
- type OperationSchemas,
9
- type OperationSchema as OperationSchemaType,
10
- SchemaGenerator,
11
- schemaKeywords,
12
- } from '@kubb/plugin-oas'
13
- import { Oas } from '@kubb/plugin-oas/components'
5
+ import { isKeyword, type OperationSchemas, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'
6
+ import { createReactGenerator } from '@kubb/plugin-oas/generators'
14
7
  import { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'
15
8
  import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
16
9
  import { File } from '@kubb/react-fabric'
@@ -112,15 +105,17 @@ function printCombinedSchema({ name, schemas, pluginManager }: { name: string; s
112
105
 
113
106
  export const typeGenerator = createReactGenerator<PluginTs>({
114
107
  name: 'typescript',
115
- Operation({ operation, options, instance }) {
116
- const { mapper, enumType, syntaxType, optionalType } = options
108
+ Operation({ operation, generator, plugin }) {
109
+ const {
110
+ options,
111
+ options: { mapper, enumType, syntaxType, optionalType },
112
+ } = plugin
117
113
 
118
- const plugin = usePlugin<PluginTs>()
119
114
  const mode = useMode()
120
115
  const pluginManager = usePluginManager()
121
116
 
122
117
  const oas = useOas()
123
- const { getSchemas, getFile, getName, getGroup } = useOperationManager()
118
+ const { getSchemas, getFile, getName, getGroup } = useOperationManager(generator)
124
119
  const schemaManager = useSchemaManager()
125
120
 
126
121
  const file = getFile(operation)
@@ -128,7 +123,7 @@ export const typeGenerator = createReactGenerator<PluginTs>({
128
123
  const type = getName(operation, { type: 'function', pluginKey: [pluginTsName] })
129
124
  const combinedSchemaName = operation.method === 'get' ? `${type}Query` : `${type}Mutation`
130
125
  const schemaGenerator = new SchemaGenerator(options, {
131
- fabric: instance.context.fabric,
126
+ fabric: generator.context.fabric,
132
127
  oas,
133
128
  plugin,
134
129
  pluginManager,
@@ -152,7 +147,7 @@ export const typeGenerator = createReactGenerator<PluginTs>({
152
147
  }
153
148
 
154
149
  return (
155
- <Oas.Schema key={[name, schemaObject.$ref].join('-')} name={name} schemaObject={schemaObject} tree={tree}>
150
+ <>
156
151
  {mode === 'split' &&
157
152
  imports.map((imp) => (
158
153
  <File.Import key={[name, imp.name, imp.path, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} isTypeOnly />
@@ -169,7 +164,7 @@ export const typeGenerator = createReactGenerator<PluginTs>({
169
164
  keysToOmit={keysToOmit}
170
165
  syntaxType={syntaxType}
171
166
  />
172
- </Oas.Schema>
167
+ </>
173
168
  )
174
169
  }
175
170
 
@@ -189,11 +184,10 @@ export const typeGenerator = createReactGenerator<PluginTs>({
189
184
  </File>
190
185
  )
191
186
  },
192
- Schema({ schema, options }) {
193
- const { mapper, enumType, syntaxType, optionalType } = options
187
+ Schema({ schema, plugin }) {
194
188
  const {
195
- options: { output },
196
- } = usePlugin<PluginTs>()
189
+ options: { mapper, enumType, syntaxType, optionalType, output },
190
+ } = plugin
197
191
  const mode = useMode()
198
192
 
199
193
  const oas = useOas()
package/src/parser.ts CHANGED
@@ -138,9 +138,6 @@ export const typeKeywordMapper = {
138
138
  } satisfies SchemaMapper<ts.TypeNode | null | undefined>
139
139
 
140
140
  type ParserOptions = {
141
- name: string
142
- typedName?: string
143
- description?: string
144
141
  /**
145
142
  * @default `'questionToken'`
146
143
  */
@@ -150,8 +147,6 @@ type ParserOptions = {
150
147
  * asPascalConst is deprecated
151
148
  */
152
149
  enumType: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'
153
- syntaxType: 'type' | 'interface'
154
- keysToOmit?: string[]
155
150
  mapper?: Record<string, ts.PropertySignature>
156
151
  }
157
152
 
@@ -166,7 +161,7 @@ type ParserOptions = {
166
161
  * @param options - Parsing options controlling output style, property handling, and custom mappers.
167
162
  * @returns The generated TypeScript AST node, or `undefined` if the schema keyword is not mapped.
168
163
  */
169
- export function parse({ current, siblings, name }: SchemaTree, options: ParserOptions): ts.Node | null | undefined {
164
+ export function parse({ schema, current, siblings, name }: SchemaTree, options: ParserOptions): ts.Node | null | undefined {
170
165
  const value = typeKeywordMapper[current.keyword as keyof typeof typeKeywordMapper]
171
166
 
172
167
  if (!value) {
@@ -175,19 +170,19 @@ export function parse({ current, siblings, name }: SchemaTree, options: ParserOp
175
170
 
176
171
  if (isKeyword(current, schemaKeywords.union)) {
177
172
  return typeKeywordMapper.union(
178
- current.args.map((schema) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
173
+ current.args.map((it) => parse({ schema, parent: current, name, current: it, siblings }, options)).filter(Boolean) as ts.TypeNode[],
179
174
  )
180
175
  }
181
176
 
182
177
  if (isKeyword(current, schemaKeywords.and)) {
183
178
  return typeKeywordMapper.and(
184
- current.args.map((schema) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
179
+ current.args.map((it) => parse({ schema, parent: current, name, current: it, siblings }, options)).filter(Boolean) as ts.TypeNode[],
185
180
  )
186
181
  }
187
182
 
188
183
  if (isKeyword(current, schemaKeywords.array)) {
189
184
  return typeKeywordMapper.array(
190
- current.args.items.map((schema) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
185
+ current.args.items.map((it) => parse({ schema, parent: current, name, current: it, siblings }, options)).filter(Boolean) as ts.TypeNode[],
191
186
  )
192
187
  }
193
188
 
@@ -206,8 +201,8 @@ export function parse({ current, siblings, name }: SchemaTree, options: ParserOp
206
201
 
207
202
  if (isKeyword(current, schemaKeywords.tuple)) {
208
203
  return typeKeywordMapper.tuple(
209
- current.args.items.map((schema) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
210
- current.args.rest && ((parse({ parent: current, name: name, current: current.args.rest, siblings }, options) ?? undefined) as ts.TypeNode | undefined),
204
+ current.args.items.map((it) => parse({ schema, parent: current, name, current: it, siblings }, options)).filter(Boolean) as ts.TypeNode[],
205
+ current.args.rest && ((parse({ schema, parent: current, name, current: current.args.rest, siblings }, options) ?? undefined) as ts.TypeNode | undefined),
211
206
  current.args.min,
212
207
  current.args.max,
213
208
  )
@@ -246,12 +241,13 @@ export function parse({ current, siblings, name }: SchemaTree, options: ParserOp
246
241
  const matchesSchema = schemas.find((schema) => schema.keyword === schemaKeywords.matches) as SchemaKeywordMapper['matches'] | undefined
247
242
 
248
243
  let type = schemas
249
- .map((schema) =>
244
+ .map((it) =>
250
245
  parse(
251
246
  {
247
+ schema,
252
248
  parent: current,
253
- name: name,
254
- current: schema,
249
+ name,
250
+ current: it,
255
251
  siblings: schemas,
256
252
  },
257
253
  options,
@@ -305,7 +301,7 @@ export function parse({ current, siblings, name }: SchemaTree, options: ParserOp
305
301
 
306
302
  if (current.args?.additionalProperties?.length) {
307
303
  additionalProperties = current.args.additionalProperties
308
- .map((schema) => parse({ parent: current, name: name, current: schema, siblings }, options))
304
+ .map((it) => parse({ schema, parent: current, name, current: it, siblings }, options))
309
305
  .filter(Boolean)
310
306
  .at(0) as ts.TypeNode
311
307
 
package/src/types.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
2
  import type { contentType, Oas } from '@kubb/oas'
3
- import type { Exclude, Generator, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
3
+ import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
4
+ import type { Generator } from '@kubb/plugin-oas/generators'
4
5
  import type ts from 'typescript'
5
6
 
6
7
  export type Options = {