@kubb/plugin-oas 0.0.0-canary-20241214001945 → 0.0.0-canary-20250108203132

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.
Files changed (57) hide show
  1. package/dist/{OperationGenerator-DSwDeEnz.d.cts → OperationGenerator-zrV0FutY.d.cts} +4 -1
  2. package/dist/{OperationGenerator-DSwDeEnz.d.ts → OperationGenerator-zrV0FutY.d.ts} +4 -1
  3. package/dist/{Schema-CWTFm7te.d.ts → Schema-CAK3gCXL.d.ts} +4 -3
  4. package/dist/{Schema-akZJu96S.d.cts → Schema-CFpQnhg0.d.cts} +4 -3
  5. package/dist/{chunk-IHPQRZWD.js → chunk-ANLF5HAF.js} +8 -3
  6. package/dist/chunk-ANLF5HAF.js.map +1 -0
  7. package/dist/{chunk-GF26SDHQ.js → chunk-BAU7PO7T.js} +2 -2
  8. package/dist/chunk-BAU7PO7T.js.map +1 -0
  9. package/dist/{chunk-BG77DP54.js → chunk-BZOI3PL5.js} +3 -4
  10. package/dist/chunk-BZOI3PL5.js.map +1 -0
  11. package/dist/{chunk-2TGWPVZN.cjs → chunk-FSCYFGYN.cjs} +6 -6
  12. package/dist/{chunk-2TGWPVZN.cjs.map → chunk-FSCYFGYN.cjs.map} +1 -1
  13. package/dist/{chunk-ZWHQ54JM.cjs → chunk-KXB5DUFD.cjs} +2 -2
  14. package/dist/chunk-KXB5DUFD.cjs.map +1 -0
  15. package/dist/{chunk-ABOQ73FL.cjs → chunk-QXUSUL7H.cjs} +7 -8
  16. package/dist/chunk-QXUSUL7H.cjs.map +1 -0
  17. package/dist/{chunk-WSORDWRC.cjs → chunk-TYJKFH6V.cjs} +8 -3
  18. package/dist/chunk-TYJKFH6V.cjs.map +1 -0
  19. package/dist/{chunk-TNWNNVQW.js → chunk-WBHFV7C2.js} +3 -3
  20. package/dist/{chunk-TNWNNVQW.js.map → chunk-WBHFV7C2.js.map} +1 -1
  21. package/dist/components.cjs +4 -4
  22. package/dist/components.d.cts +4 -4
  23. package/dist/components.d.ts +4 -4
  24. package/dist/components.js +1 -1
  25. package/dist/generators.cjs +3 -3
  26. package/dist/generators.d.cts +1 -1
  27. package/dist/generators.d.ts +1 -1
  28. package/dist/generators.js +2 -2
  29. package/dist/hooks.cjs +15 -16
  30. package/dist/hooks.cjs.map +1 -1
  31. package/dist/hooks.d.cts +20 -8
  32. package/dist/hooks.d.ts +20 -8
  33. package/dist/hooks.js +9 -10
  34. package/dist/hooks.js.map +1 -1
  35. package/dist/index.cjs +13 -13
  36. package/dist/index.d.cts +2 -2
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.js +6 -6
  39. package/dist/utils.cjs +2 -2
  40. package/dist/utils.d.cts +2 -2
  41. package/dist/utils.d.ts +2 -2
  42. package/dist/utils.js +1 -1
  43. package/package.json +10 -10
  44. package/src/SchemaGenerator.ts +5 -0
  45. package/src/components/Oas.tsx +1 -1
  46. package/src/components/Operation.tsx +1 -1
  47. package/src/components/Schema.tsx +3 -2
  48. package/src/hooks/useOperationManager.ts +15 -14
  49. package/src/hooks/useSchemaManager.ts +16 -2
  50. package/src/types.ts +4 -1
  51. package/src/utils/parseFromConfig.ts +1 -1
  52. package/dist/chunk-ABOQ73FL.cjs.map +0 -1
  53. package/dist/chunk-BG77DP54.js.map +0 -1
  54. package/dist/chunk-GF26SDHQ.js.map +0 -1
  55. package/dist/chunk-IHPQRZWD.js.map +0 -1
  56. package/dist/chunk-WSORDWRC.cjs.map +0 -1
  57. package/dist/chunk-ZWHQ54JM.cjs.map +0 -1
package/dist/hooks.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Oas, Operation, HttpMethod } from '@kubb/oas';
2
- import { Plugin, ResolveNameParams, Group, FileMetaBase } from '@kubb/core';
2
+ import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
4
  import { Mode } from '@kubb/fs/types';
5
- import { w as OperationSchemas, f as Schema } from './OperationGenerator-DSwDeEnz.js';
6
- import { a as SchemaContextProps } from './Schema-CWTFm7te.js';
5
+ import { w as OperationSchemas, f as Schema } from './OperationGenerator-zrV0FutY.js';
6
+ import { a as SchemaContextProps } from './Schema-CAK3gCXL.js';
7
7
  import '@kubb/react/types';
8
8
  import 'react';
9
9
 
@@ -17,7 +17,10 @@ declare function useOperation(): Operation;
17
17
  type FileMeta$1 = FileMetaBase & {
18
18
  pluginKey: Plugin['key'];
19
19
  name: string;
20
- group?: string;
20
+ group?: {
21
+ tag?: string;
22
+ path?: string;
23
+ };
21
24
  };
22
25
  type SchemaNames = {
23
26
  request: string | undefined;
@@ -43,7 +46,10 @@ type UseOperationManagerResult = {
43
46
  suffix?: string;
44
47
  pluginKey?: Plugin['key'];
45
48
  extname?: KubbFile.Extname;
46
- group?: string;
49
+ group?: {
50
+ tag?: string;
51
+ path?: string;
52
+ };
47
53
  }) => KubbFile.File<FileMeta$1>;
48
54
  groupSchemasByName: (operation: Operation, params: {
49
55
  pluginKey?: Plugin['key'];
@@ -53,7 +59,7 @@ type UseOperationManagerResult = {
53
59
  pluginKey?: Plugin['key'];
54
60
  type?: ResolveNameParams['type'];
55
61
  }) => OperationSchemas;
56
- getGroup: (operation: Operation, group: Group | undefined) => string | undefined;
62
+ getGroup: (operation: Operation) => FileMeta$1['group'] | undefined;
57
63
  };
58
64
  /**
59
65
  * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
@@ -86,7 +92,10 @@ declare function useSchema(): UseSchemaResult;
86
92
  type FileMeta = FileMetaBase & {
87
93
  pluginKey: Plugin['key'];
88
94
  name: string;
89
- group?: string;
95
+ group?: {
96
+ tag?: string;
97
+ path?: string;
98
+ };
90
99
  };
91
100
  type UseSchemaManagerResult = {
92
101
  getName: (name: string, params: {
@@ -97,7 +106,10 @@ type UseSchemaManagerResult = {
97
106
  pluginKey?: Plugin['key'];
98
107
  mode?: Mode;
99
108
  extname?: KubbFile.Extname;
100
- group?: string;
109
+ group?: {
110
+ tag?: string;
111
+ path?: string;
112
+ };
101
113
  }) => KubbFile.File<FileMeta>;
102
114
  getImports: (tree: Array<Schema>) => Array<KubbFile.Import>;
103
115
  };
package/dist/hooks.js CHANGED
@@ -1,6 +1,6 @@
1
- import { SchemaGenerator, schemaKeywords } from './chunk-IHPQRZWD.js';
1
+ import { SchemaGenerator, schemaKeywords } from './chunk-ANLF5HAF.js';
2
2
  import './chunk-XNCEFOE6.js';
3
- import { Oas, Operation, Schema } from './chunk-GF26SDHQ.js';
3
+ import { Oas, Operation, Schema } from './chunk-BAU7PO7T.js';
4
4
  import { useContext, useApp } from '@kubb/react';
5
5
 
6
6
  function useOas() {
@@ -27,13 +27,11 @@ function useOperationManager() {
27
27
  type
28
28
  });
29
29
  };
30
- const getGroup = (operation, group) => {
31
- if (group?.type === "tag") {
32
- return operation.getTags().at(0)?.name;
33
- }
34
- if (group?.type === "path") {
35
- return operation.path;
36
- }
30
+ const getGroup = (operation) => {
31
+ return {
32
+ tag: operation.getTags().at(0)?.name,
33
+ path: operation.path
34
+ };
37
35
  };
38
36
  const getSchemas = (operation, params) => {
39
37
  if (!generator) {
@@ -47,8 +45,9 @@ function useOperationManager() {
47
45
  })
48
46
  });
49
47
  };
50
- const getFile = (operation, { prefix, suffix, pluginKey = plugin.key, group = getGroup(operation, plugin.options?.group), extname = ".ts" } = {}) => {
48
+ const getFile = (operation, { prefix, suffix, pluginKey = plugin.key, extname = ".ts" } = {}) => {
51
49
  const name = getName(operation, { type: "file", pluginKey, prefix, suffix });
50
+ const group = getGroup(operation);
52
51
  const file = pluginManager.getFile({
53
52
  name,
54
53
  extname,
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"names":["useContext","useApp"],"mappings":";;;;;AAMO,SAAS,MAAkB,GAAA;AAChC,EAA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,IAAM,EAAA,YAAA;AAAA,QACN;AAAA;AACF,KACF;AAAA,GACF;AAEA,EAAM,MAAA,UAAA,GAAmD,CAAC,IAAS,KAAA;AACjE,IAAA,MAAM,IAAO,GAAA,eAAA,CAAgB,UAAW,CAAA,IAAA,EAAM,eAAe,GAAG,CAAA;AAEhE,IAAA,OAAO,IACH,EAAA,GAAA,CAAI,CAAC,IAAA,EAAM,CAAM,KAAA;AACjB,MAAA,IAAI,CAAC,IAAK,CAAA,IAAA,CAAK,QAAQ,CAAC,IAAA,CAAK,KAAK,YAAc,EAAA;AAC9C,QAAO,OAAA,KAAA,CAAA;AAAA;AAGT,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,CAAC,IAAK,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,QACrB,IAAA,EAAM,KAAK,IAAK,CAAA;AAAA,OAClB;AAAA,KACD,CACA,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,GACnB;AAEA,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"hooks.js","sourcesContent":["import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Group, Plugin, ResolveNameParams } from '@kubb/core'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: string\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: string\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation, group: Group | undefined) => string | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation, group) => {\n if (group?.type === 'tag') {\n return operation.getTags().at(0)?.name\n }\n\n if (group?.type === 'path') {\n return operation.path\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (\n operation,\n { prefix, suffix, pluginKey = plugin.key, group = getGroup(operation, (plugin.options as { group?: Group })?.group), extname = '.ts' } = {},\n ) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import { useApp } from '@kubb/react'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Mode } from '@kubb/fs/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: string\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (name: string, params?: { pluginKey?: Plugin['key']; mode?: Mode; extname?: KubbFile.Extname; group?: string }) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const { plugin, pluginManager } = useApp()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item, i) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts","../src/hooks/useSchema.ts","../src/hooks/useSchemaManager.ts"],"names":["useContext","useApp"],"mappings":";;;;;AAMO,SAAS,MAAkB,GAAA;AAChC,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAA,UAAA,CAAW,IAAI,OAAO,CAAA;AAEtC,EAAA,IAAI,CAAC,GAAK,EAAA;AACR,IAAM,MAAA,IAAI,MAAM,oBAAoB,CAAA;AAAA;AAGtC,EAAO,OAAA,GAAA;AACT;ACLO,SAAS,YAA8B,GAAA;AAC5C,EAAA,MAAM,EAAE,SAAA,EAAcA,GAAAA,UAAAA,CAAW,UAAU,OAAO,CAAA;AAElD,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA;AAAA;AAG5C,EAAO,OAAA,SAAA;AACT;ACkDO,SAAS,mBAAiD,GAAA;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,aAAc,EAAA,GAAI,MAAO,EAAA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A,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"hooks.js","sourcesContent":["import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Group, Plugin, ResolveNameParams } from '@kubb/core'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\nexport type SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (\n operation: OperationType,\n params: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => string\n getFile: (\n operation: OperationType,\n params?: {\n prefix?: string\n suffix?: string\n pluginKey?: Plugin['key']\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n groupSchemasByName: (\n operation: OperationType,\n params: {\n pluginKey?: Plugin['key']\n type: ResolveNameParams['type']\n },\n ) => SchemaNames\n getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas\n getGroup: (operation: Operation) => FileMeta['group'] | undefined\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: `${prefix} ${operation.getOperationId()} ${suffix}`,\n pluginKey,\n type,\n })\n }\n\n const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {\n return {\n tag: operation.getTags().at(0)?.name,\n path: operation.path,\n }\n }\n\n const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n return generator.getSchemas(operation, {\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {\n const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })\n const group = getGroup(operation)\n\n const file = pluginManager.getFile({\n name,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n group,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n const responses = (schemas.responses || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n ...responses,\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas,\n groupSchemasByName,\n getGroup,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n","import { useContext } from '@kubb/react'\n\nimport { Schema } from '../components/Schema.tsx'\n\nimport type { SchemaContextProps } from '../components/Schema.tsx'\n\ntype UseSchemaResult = SchemaContextProps\n\n/**\n * `useSchema` will return the current `schema properties`\n */\nexport function useSchema(): UseSchemaResult {\n const props = useContext(Schema.Context)\n\n return props as UseSchemaResult\n}\n","import { useApp } from '@kubb/react'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Mode } from '@kubb/fs/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport { type Schema, schemaKeywords } from '../SchemaMapper'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n group?: {\n tag?: string\n path?: string\n }\n}\n\ntype UseSchemaManagerResult = {\n getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (\n name: string,\n params?: {\n pluginKey?: Plugin['key']\n mode?: Mode\n extname?: KubbFile.Extname\n group?: {\n tag?: string\n path?: string\n }\n },\n ) => KubbFile.File<FileMeta>\n getImports: (tree: Array<Schema>) => Array<KubbFile.Import>\n}\n\n/**\n * `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.\n */\nexport function useSchemaManager(): UseSchemaManagerResult {\n const { plugin, pluginManager } = useApp()\n\n const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name,\n pluginKey,\n type,\n })\n }\n\n const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => {\n const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name: resolvedName,\n extname,\n pluginKey,\n options: { type: 'file', pluginKey, group },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name: resolvedName,\n pluginKey,\n },\n }\n }\n\n const getImports: UseSchemaManagerResult['getImports'] = (tree) => {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n return refs\n ?.map((item, i) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n }\n })\n .filter(Boolean)\n }\n\n return {\n getName,\n getFile,\n getImports,\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkABOQ73FL_cjs = require('./chunk-ABOQ73FL.cjs');
4
- var chunk2TGWPVZN_cjs = require('./chunk-2TGWPVZN.cjs');
3
+ var chunkQXUSUL7H_cjs = require('./chunk-QXUSUL7H.cjs');
4
+ var chunkFSCYFGYN_cjs = require('./chunk-FSCYFGYN.cjs');
5
5
  require('./chunk-PADR76WZ.cjs');
6
- var chunkWSORDWRC_cjs = require('./chunk-WSORDWRC.cjs');
6
+ var chunkTYJKFH6V_cjs = require('./chunk-TYJKFH6V.cjs');
7
7
  var chunkQAFBZLJA_cjs = require('./chunk-QAFBZLJA.cjs');
8
- require('./chunk-ZWHQ54JM.cjs');
8
+ require('./chunk-KXB5DUFD.cjs');
9
9
  var core = require('@kubb/core');
10
10
  var transformers = require('@kubb/core/transformers');
11
11
  var path = require('path');
@@ -264,14 +264,14 @@ var pluginOas = core.createPlugin((options) => {
264
264
  path: "schemas"
265
265
  },
266
266
  validate = true,
267
- generators = [chunk2TGWPVZN_cjs.jsonGenerator],
267
+ generators = [chunkFSCYFGYN_cjs.jsonGenerator],
268
268
  serverIndex,
269
269
  contentType,
270
270
  oasClass
271
271
  } = options;
272
272
  const getOas = async ({ config, logger }) => {
273
273
  try {
274
- const oas = await chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
274
+ const oas = await chunkQXUSUL7H_cjs.parseFromConfig(config, oasClass);
275
275
  if (validate) {
276
276
  await oas.valdiate();
277
277
  }
@@ -279,7 +279,7 @@ var pluginOas = core.createPlugin((options) => {
279
279
  } catch (e) {
280
280
  const error = e;
281
281
  logger.emit("warning", error?.message);
282
- return chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
282
+ return chunkQXUSUL7H_cjs.parseFromConfig(config, oasClass);
283
283
  }
284
284
  };
285
285
  return {
@@ -325,7 +325,7 @@ var pluginOas = core.createPlugin((options) => {
325
325
  logger: this.logger
326
326
  });
327
327
  await oas.dereference();
328
- const schemaGenerator = new chunkWSORDWRC_cjs.SchemaGenerator(
328
+ const schemaGenerator = new chunkTYJKFH6V_cjs.SchemaGenerator(
329
329
  {
330
330
  unknownType: "unknown",
331
331
  dateType: "date",
@@ -363,23 +363,23 @@ var pluginOas = core.createPlugin((options) => {
363
363
 
364
364
  Object.defineProperty(exports, "createGenerator", {
365
365
  enumerable: true,
366
- get: function () { return chunk2TGWPVZN_cjs.createGenerator; }
366
+ get: function () { return chunkFSCYFGYN_cjs.createGenerator; }
367
367
  });
368
368
  Object.defineProperty(exports, "createReactGenerator", {
369
369
  enumerable: true,
370
- get: function () { return chunk2TGWPVZN_cjs.createReactGenerator; }
370
+ get: function () { return chunkFSCYFGYN_cjs.createReactGenerator; }
371
371
  });
372
372
  Object.defineProperty(exports, "SchemaGenerator", {
373
373
  enumerable: true,
374
- get: function () { return chunkWSORDWRC_cjs.SchemaGenerator; }
374
+ get: function () { return chunkTYJKFH6V_cjs.SchemaGenerator; }
375
375
  });
376
376
  Object.defineProperty(exports, "isKeyword", {
377
377
  enumerable: true,
378
- get: function () { return chunkWSORDWRC_cjs.isKeyword; }
378
+ get: function () { return chunkTYJKFH6V_cjs.isKeyword; }
379
379
  });
380
380
  Object.defineProperty(exports, "schemaKeywords", {
381
381
  enumerable: true,
382
- get: function () { return chunkWSORDWRC_cjs.schemaKeywords; }
382
+ get: function () { return chunkTYJKFH6V_cjs.schemaKeywords; }
383
383
  });
384
384
  exports.OperationGenerator = OperationGenerator;
385
385
  exports.pluginOas = pluginOas;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as Options, P as PluginOas } from './OperationGenerator-DSwDeEnz.cjs';
2
- export { A as API, E as Exclude, o as Generator, p as GeneratorOptions, G as GetSchemaGeneratorOptions, I as Include, b as OperationGenerator, a as OperationMethodResult, v as OperationSchema, w as OperationSchemas, x as OperationsByMethod, y as Override, R as ReactGeneratorOptions, r as Ref, t as Refs, q as ResolvePathOptions, u as Resolver, f as Schema, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, h as SchemaKeyword, i as SchemaKeywordBase, j as SchemaKeywordMapper, k as SchemaMapper, d as SchemaMethodResult, g as SchemaTree, m as createGenerator, n as createReactGenerator, l as isKeyword, s as schemaKeywords } from './OperationGenerator-DSwDeEnz.cjs';
1
+ import { O as Options, P as PluginOas } from './OperationGenerator-zrV0FutY.cjs';
2
+ export { A as API, E as Exclude, o as Generator, p as GeneratorOptions, G as GetSchemaGeneratorOptions, I as Include, b as OperationGenerator, a as OperationMethodResult, v as OperationSchema, w as OperationSchemas, x as OperationsByMethod, y as Override, R as ReactGeneratorOptions, r as Ref, t as Refs, q as ResolvePathOptions, u as Resolver, f as Schema, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, h as SchemaKeyword, i as SchemaKeywordBase, j as SchemaKeywordMapper, k as SchemaMapper, d as SchemaMethodResult, g as SchemaTree, m as createGenerator, n as createReactGenerator, l as isKeyword, s as schemaKeywords } from './OperationGenerator-zrV0FutY.cjs';
3
3
  import * as _kubb_core from '@kubb/core';
4
4
  import '@kubb/fs/types';
5
5
  import '@kubb/oas';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as Options, P as PluginOas } from './OperationGenerator-DSwDeEnz.js';
2
- export { A as API, E as Exclude, o as Generator, p as GeneratorOptions, G as GetSchemaGeneratorOptions, I as Include, b as OperationGenerator, a as OperationMethodResult, v as OperationSchema, w as OperationSchemas, x as OperationsByMethod, y as Override, R as ReactGeneratorOptions, r as Ref, t as Refs, q as ResolvePathOptions, u as Resolver, f as Schema, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, h as SchemaKeyword, i as SchemaKeywordBase, j as SchemaKeywordMapper, k as SchemaMapper, d as SchemaMethodResult, g as SchemaTree, m as createGenerator, n as createReactGenerator, l as isKeyword, s as schemaKeywords } from './OperationGenerator-DSwDeEnz.js';
1
+ import { O as Options, P as PluginOas } from './OperationGenerator-zrV0FutY.js';
2
+ export { A as API, E as Exclude, o as Generator, p as GeneratorOptions, G as GetSchemaGeneratorOptions, I as Include, b as OperationGenerator, a as OperationMethodResult, v as OperationSchema, w as OperationSchemas, x as OperationsByMethod, y as Override, R as ReactGeneratorOptions, r as Ref, t as Refs, q as ResolvePathOptions, u as Resolver, f as Schema, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, h as SchemaKeyword, i as SchemaKeywordBase, j as SchemaKeywordMapper, k as SchemaMapper, d as SchemaMethodResult, g as SchemaTree, m as createGenerator, n as createReactGenerator, l as isKeyword, s as schemaKeywords } from './OperationGenerator-zrV0FutY.js';
3
3
  import * as _kubb_core from '@kubb/core';
4
4
  import '@kubb/fs/types';
5
5
  import '@kubb/oas';
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { parseFromConfig } from './chunk-BG77DP54.js';
2
- import { jsonGenerator } from './chunk-TNWNNVQW.js';
3
- export { createGenerator, createReactGenerator } from './chunk-TNWNNVQW.js';
1
+ import { parseFromConfig } from './chunk-BZOI3PL5.js';
2
+ import { jsonGenerator } from './chunk-WBHFV7C2.js';
3
+ export { createGenerator, createReactGenerator } from './chunk-WBHFV7C2.js';
4
4
  import './chunk-R47XMJ32.js';
5
- import { SchemaGenerator } from './chunk-IHPQRZWD.js';
6
- export { SchemaGenerator, isKeyword, schemaKeywords } from './chunk-IHPQRZWD.js';
5
+ import { SchemaGenerator } from './chunk-ANLF5HAF.js';
6
+ export { SchemaGenerator, isKeyword, schemaKeywords } from './chunk-ANLF5HAF.js';
7
7
  import { getSchemas } from './chunk-XNCEFOE6.js';
8
- import './chunk-GF26SDHQ.js';
8
+ import './chunk-BAU7PO7T.js';
9
9
  import { createPlugin, FileManager, BaseGenerator } from '@kubb/core';
10
10
  import transformers from '@kubb/core/transformers';
11
11
  import path from 'node:path';
package/dist/utils.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkABOQ73FL_cjs = require('./chunk-ABOQ73FL.cjs');
3
+ var chunkQXUSUL7H_cjs = require('./chunk-QXUSUL7H.cjs');
4
4
  var chunkQAFBZLJA_cjs = require('./chunk-QAFBZLJA.cjs');
5
5
  var transformers = require('@kubb/core/transformers');
6
6
  var utils = require('@kubb/core/utils');
@@ -55,7 +55,7 @@ function getPathParams(operationSchema, options = {}) {
55
55
 
56
56
  Object.defineProperty(exports, "parseFromConfig", {
57
57
  enumerable: true,
58
- get: function () { return chunkABOQ73FL_cjs.parseFromConfig; }
58
+ get: function () { return chunkQXUSUL7H_cjs.parseFromConfig; }
59
59
  });
60
60
  Object.defineProperty(exports, "getSchemaFactory", {
61
61
  enumerable: true,
package/dist/utils.d.cts CHANGED
@@ -2,8 +2,8 @@ import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1 } from '@kubb/oas'
2
2
  export { isOptional } from '@kubb/oas';
3
3
  import { FunctionParamsAST } from '@kubb/core/utils';
4
4
  import { Params } from '@kubb/react/types';
5
- import { v as OperationSchema } from './OperationGenerator-DSwDeEnz.cjs';
6
- export { z as GetSchemasProps, B as getSchemas } from './OperationGenerator-DSwDeEnz.cjs';
5
+ import { v as OperationSchema } from './OperationGenerator-zrV0FutY.cjs';
6
+ export { z as GetSchemasProps, B as getSchemas } from './OperationGenerator-zrV0FutY.cjs';
7
7
  import { Config } from '@kubb/core';
8
8
  import '@kubb/fs/types';
9
9
 
package/dist/utils.d.ts CHANGED
@@ -2,8 +2,8 @@ import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1 } from '@kubb/oas'
2
2
  export { isOptional } from '@kubb/oas';
3
3
  import { FunctionParamsAST } from '@kubb/core/utils';
4
4
  import { Params } from '@kubb/react/types';
5
- import { v as OperationSchema } from './OperationGenerator-DSwDeEnz.js';
6
- export { z as GetSchemasProps, B as getSchemas } from './OperationGenerator-DSwDeEnz.js';
5
+ import { v as OperationSchema } from './OperationGenerator-zrV0FutY.js';
6
+ export { z as GetSchemasProps, B as getSchemas } from './OperationGenerator-zrV0FutY.js';
7
7
  import { Config } from '@kubb/core';
8
8
  import '@kubb/fs/types';
9
9
 
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- export { parseFromConfig } from './chunk-BG77DP54.js';
1
+ export { parseFromConfig } from './chunk-BZOI3PL5.js';
2
2
  export { getSchemaFactory, getSchemas } from './chunk-XNCEFOE6.js';
3
3
  import transformers, { isValidVarName, camelCase } from '@kubb/core/transformers';
4
4
  import { URLPath } from '@kubb/core/utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "0.0.0-canary-20241214001945",
3
+ "version": "0.0.0-canary-20250108203132",
4
4
  "description": "Generator swagger",
5
5
  "keywords": [
6
6
  "typescript",
@@ -75,22 +75,22 @@
75
75
  ],
76
76
  "dependencies": {
77
77
  "@stoplight/yaml": "^4.3.0",
78
- "remeda": "^2.17.4",
79
- "@kubb/core": "0.0.0-canary-20241214001945",
80
- "@kubb/fs": "0.0.0-canary-20241214001945",
81
- "@kubb/oas": "0.0.0-canary-20241214001945",
82
- "@kubb/react": "0.0.0-canary-20241214001945"
78
+ "remeda": "^2.19.0",
79
+ "@kubb/core": "0.0.0-canary-20250108203132",
80
+ "@kubb/fs": "0.0.0-canary-20250108203132",
81
+ "@kubb/oas": "0.0.0-canary-20250108203132",
82
+ "@kubb/react": "0.0.0-canary-20250108203132"
83
83
  },
84
84
  "devDependencies": {
85
- "@types/react": "^18.3.16",
85
+ "@types/react": "^18.3.18",
86
86
  "react": "^18.3.1",
87
87
  "tsup": "^8.3.5",
88
88
  "typescript": "^5.7.2",
89
- "@kubb/config-ts": "0.0.0-canary-20241214001945",
90
- "@kubb/config-tsup": "0.0.0-canary-20241214001945"
89
+ "@kubb/config-ts": "0.0.0-canary-20250108203132",
90
+ "@kubb/config-tsup": "0.0.0-canary-20250108203132"
91
91
  },
92
92
  "peerDependencies": {
93
- "@kubb/react": "0.0.0-canary-20241214001945"
93
+ "@kubb/react": "0.0.0-canary-20250108203132"
94
94
  },
95
95
  "engines": {
96
96
  "node": ">=20"
@@ -554,6 +554,7 @@ export class SchemaGenerator<
554
554
  }
555
555
 
556
556
  if (schemaWithoutAllOf.required) {
557
+ // TODO use of Required ts helper instead
557
558
  const schemas = schema.allOf
558
559
  .map((item) => {
559
560
  if (isReference(item)) {
@@ -563,6 +564,10 @@ export class SchemaGenerator<
563
564
  .filter(Boolean)
564
565
 
565
566
  const items = schemaWithoutAllOf.required
567
+ .filter((key) =>
568
+ // filter out keys that are already part of the properties(reduce duplicated keys(https://github.com/kubb-labs/kubb/issues/1492)
569
+ schemaWithoutAllOf.properties ? !Object.keys(schemaWithoutAllOf.properties).includes(key) : false,
570
+ )
566
571
  .map((key) => {
567
572
  const schema = schemas.find((item) => item.properties && Object.keys(item.properties).find((propertyKey) => propertyKey === key))
568
573
 
@@ -28,7 +28,7 @@ type OasContextProps = {
28
28
 
29
29
  const OasContext = createContext<OasContextProps>({})
30
30
 
31
- export function Oas({ oas, children, operations, generator }: Props): KubbNode {
31
+ export function Oas({ oas, children, operations, generator }: Props) {
32
32
  return <OasContext.Provider value={{ oas, generator, operations }}>{children}</OasContext.Provider>
33
33
  }
34
34
 
@@ -14,7 +14,7 @@ type OperationContextProps = {
14
14
 
15
15
  const OperationContext = createContext<OperationContextProps>({})
16
16
 
17
- export function Operation({ operation, children }: Props): KubbNode {
17
+ export function Operation({ operation, children }: Props) {
18
18
  return <OperationContext.Provider value={{ operation }}>{children}</OperationContext.Provider>
19
19
  }
20
20
 
@@ -1,7 +1,7 @@
1
1
  import { createContext } from '@kubb/react'
2
2
 
3
3
  import type { SchemaObject } from '@kubb/oas'
4
- import type { KubbNode } from '@kubb/react/types'
4
+ import type { Key, KubbNode } from '@kubb/react/types'
5
5
  import type { Schema as SchemaType } from '../SchemaMapper.ts'
6
6
 
7
7
  export type SchemaContextProps = {
@@ -11,6 +11,7 @@ export type SchemaContextProps = {
11
11
  }
12
12
 
13
13
  type Props = {
14
+ key?: Key
14
15
  name: string
15
16
  value?: SchemaObject
16
17
  tree?: Array<SchemaType>
@@ -22,7 +23,7 @@ const SchemaContext = createContext<SchemaContextProps>({
22
23
  tree: [],
23
24
  })
24
25
 
25
- export function Schema({ name, value, tree = [], children }: Props): KubbNode {
26
+ export function Schema({ name, value, tree = [], children }: Props) {
26
27
  return <SchemaContext.Provider value={{ name, schema: value, tree }}>{children}</SchemaContext.Provider>
27
28
  }
28
29
 
@@ -11,7 +11,10 @@ import type { OperationSchemas } from '../types.ts'
11
11
  type FileMeta = FileMetaBase & {
12
12
  pluginKey: Plugin['key']
13
13
  name: string
14
- group?: string
14
+ group?: {
15
+ tag?: string
16
+ path?: string
17
+ }
15
18
  }
16
19
 
17
20
  export type SchemaNames = {
@@ -42,7 +45,10 @@ type UseOperationManagerResult = {
42
45
  suffix?: string
43
46
  pluginKey?: Plugin['key']
44
47
  extname?: KubbFile.Extname
45
- group?: string
48
+ group?: {
49
+ tag?: string
50
+ path?: string
51
+ }
46
52
  },
47
53
  ) => KubbFile.File<FileMeta>
48
54
  groupSchemasByName: (
@@ -53,7 +59,7 @@ type UseOperationManagerResult = {
53
59
  },
54
60
  ) => SchemaNames
55
61
  getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas
56
- getGroup: (operation: Operation, group: Group | undefined) => string | undefined
62
+ getGroup: (operation: Operation) => FileMeta['group'] | undefined
57
63
  }
58
64
 
59
65
  /**
@@ -71,13 +77,10 @@ export function useOperationManager(): UseOperationManagerResult {
71
77
  })
72
78
  }
73
79
 
74
- const getGroup: UseOperationManagerResult['getGroup'] = (operation, group) => {
75
- if (group?.type === 'tag') {
76
- return operation.getTags().at(0)?.name
77
- }
78
-
79
- if (group?.type === 'path') {
80
- return operation.path
80
+ const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {
81
+ return {
82
+ tag: operation.getTags().at(0)?.name,
83
+ path: operation.path,
81
84
  }
82
85
  }
83
86
 
@@ -96,11 +99,9 @@ export function useOperationManager(): UseOperationManagerResult {
96
99
  })
97
100
  }
98
101
 
99
- const getFile: UseOperationManagerResult['getFile'] = (
100
- operation,
101
- { prefix, suffix, pluginKey = plugin.key, group = getGroup(operation, (plugin.options as { group?: Group })?.group), extname = '.ts' } = {},
102
- ) => {
102
+ const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {
103
103
  const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })
104
+ const group = getGroup(operation)
104
105
 
105
106
  const file = pluginManager.getFile({
106
107
  name,
@@ -9,12 +9,26 @@ import { type Schema, schemaKeywords } from '../SchemaMapper'
9
9
  type FileMeta = FileMetaBase & {
10
10
  pluginKey: Plugin['key']
11
11
  name: string
12
- group?: string
12
+ group?: {
13
+ tag?: string
14
+ path?: string
15
+ }
13
16
  }
14
17
 
15
18
  type UseSchemaManagerResult = {
16
19
  getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string
17
- getFile: (name: string, params?: { pluginKey?: Plugin['key']; mode?: Mode; extname?: KubbFile.Extname; group?: string }) => KubbFile.File<FileMeta>
20
+ getFile: (
21
+ name: string,
22
+ params?: {
23
+ pluginKey?: Plugin['key']
24
+ mode?: Mode
25
+ extname?: KubbFile.Extname
26
+ group?: {
27
+ tag?: string
28
+ path?: string
29
+ }
30
+ },
31
+ ) => KubbFile.File<FileMeta>
18
32
  getImports: (tree: Array<Schema>) => Array<KubbFile.Import>
19
33
  }
20
34
 
package/src/types.ts CHANGED
@@ -8,7 +8,10 @@ import type { GetSchemasProps } from './utils/getSchemas.ts'
8
8
 
9
9
  export type ResolvePathOptions = {
10
10
  pluginKey?: Plugin['key']
11
- group?: string
11
+ group?: {
12
+ tag?: string
13
+ path?: string
14
+ }
12
15
  type?: ResolveNameParams['type']
13
16
  }
14
17
 
@@ -2,7 +2,7 @@ import { resolve } from 'node:path'
2
2
 
3
3
  import { URLPath } from '@kubb/core/utils'
4
4
 
5
- import { parse } from '@kubb/oas/parser'
5
+ import { parse } from '@kubb/oas'
6
6
 
7
7
  import type { Config } from '@kubb/core'
8
8
  import { Oas, type OasTypes } from '@kubb/oas'
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/parseFromConfig.ts"],"names":["Oas","api","parse","yaml","URLPath","resolve"],"mappings":";;;;;;;;;;;;;AAUO,SAAS,eAAA,CAAgB,MAAgB,EAAA,QAAA,GAAuBA,OAAmB,EAAA;AACxF,EAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,IAAA,IAAI,OAAO,MAAA,CAAO,KAAM,CAAA,IAAA,KAAS,QAAU,EAAA;AACzC,MAAMC,MAAAA,IAAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAO,OAAAC,YAAA,CAAMD,MAAK,QAAQ,CAAA;AAAA;AAG5B,IAAI,IAAA;AACF,MAAA,MAAMA,IAAc,GAAAE,qBAAA,CAAK,KAAM,CAAA,MAAA,CAAO,MAAM,IAAc,CAAA;AAE1D,MAAO,OAAAD,YAAA,CAAMD,MAAK,QAAQ,CAAA;AAAA,aACnB,CAAG,EAAA;AAAA;AAIZ,IAAM,MAAA,GAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAO,OAAAC,YAAA,CAAM,KAAK,QAAQ,CAAA;AAAA;AAG5B,EAAA,IAAI,IAAIE,aAAQ,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAAE,KAAO,EAAA;AACxC,IAAA,OAAOF,YAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA,EAAM,QAAQ,CAAA;AAAA;AAG1C,EAAO,OAAAA,YAAA,CAAMG,aAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,GAAG,QAAQ,CAAA;AAChE","file":"chunk-ABOQ73FL.cjs","sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), oasClass)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/parseFromConfig.ts"],"names":["api"],"mappings":";;;;;;;AAUO,SAAS,eAAA,CAAgB,MAAgB,EAAA,QAAA,GAAuB,GAAmB,EAAA;AACxF,EAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,IAAA,IAAI,OAAO,MAAA,CAAO,KAAM,CAAA,IAAA,KAAS,QAAU,EAAA;AACzC,MAAMA,MAAAA,IAAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAO,OAAA,KAAA,CAAMA,MAAK,QAAQ,CAAA;AAAA;AAG5B,IAAI,IAAA;AACF,MAAA,MAAMA,IAAc,GAAA,IAAA,CAAK,KAAM,CAAA,MAAA,CAAO,MAAM,IAAc,CAAA;AAE1D,MAAO,OAAA,KAAA,CAAMA,MAAK,QAAQ,CAAA;AAAA,aACnB,CAAG,EAAA;AAAA;AAIZ,IAAM,MAAA,GAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAO,OAAA,KAAA,CAAM,KAAK,QAAQ,CAAA;AAAA;AAG5B,EAAA,IAAI,IAAI,OAAQ,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAAE,KAAO,EAAA;AACxC,IAAA,OAAO,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA,EAAM,QAAQ,CAAA;AAAA;AAG1C,EAAO,OAAA,KAAA,CAAM,QAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,GAAG,QAAQ,CAAA;AAChE","file":"chunk-BG77DP54.js","sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), oasClass)\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Operation.tsx","../src/components/Schema.tsx","../src/components/Oas.tsx"],"names":["createContext","jsx"],"mappings":";;;;AAcA,IAAM,gBAAA,GAAmB,aAAqC,CAAA,EAAE,CAAA;AAEzD,SAAS,SAAU,CAAA,EAAE,SAAW,EAAA,QAAA,EAA6B,EAAA;AAClE,EAAO,uBAAA,GAAA,CAAC,iBAAiB,QAAjB,EAAA,EAA0B,OAAO,EAAE,SAAA,IAAc,QAAS,EAAA,CAAA;AACpE;AAEA,SAAA,CAAU,OAAU,GAAA,gBAAA;ACDpB,IAAM,gBAAgBA,aAAkC,CAAA;AAAA,EACtD,IAAM,EAAA,SAAA;AAAA,EACN,MAAM;AACR,CAAC,CAAA;AAEM,SAAS,MAAA,CAAO,EAAE,IAAM,EAAA,KAAA,EAAO,OAAO,EAAC,EAAG,UAA6B,EAAA;AAC5E,EAAA,uBAAOC,GAAAA,CAAC,aAAc,CAAA,QAAA,EAAd,EAAuB,KAAA,EAAO,EAAE,IAAA,EAAM,MAAQ,EAAA,KAAA,EAAO,IAAK,EAAA,EAAI,QAAS,EAAA,CAAA;AACjF;AAEA,MAAA,CAAO,OAAU,GAAA,aAAA;ACAjB,IAAM,UAAA,GAAaD,aAA+B,CAAA,EAAE,CAAA;AAE7C,SAAS,IAAI,EAAE,GAAA,EAAK,QAAU,EAAA,UAAA,EAAY,WAA8B,EAAA;AAC7E,EAAO,uBAAAC,GAAC,CAAA,UAAA,CAAW,QAAX,EAAA,EAAoB,KAAO,EAAA,EAAE,GAAK,EAAA,SAAA,EAAW,UAAW,EAAA,EAAI,QAAS,EAAA,CAAA;AAC/E;AAEA,GAAA,CAAI,OAAU,GAAA,UAAA;AACd,GAAA,CAAI,SAAY,GAAA,SAAA;AAChB,GAAA,CAAI,MAAS,GAAA,MAAA","file":"chunk-GF26SDHQ.js","sourcesContent":["import { createContext } from '@kubb/react'\n\nimport type { Operation as OperationType } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react/types'\n\ntype Props = {\n operation: OperationType\n children?: KubbNode\n}\n\ntype OperationContextProps = {\n operation?: OperationType\n}\n\nconst OperationContext = createContext<OperationContextProps>({})\n\nexport function Operation({ operation, children }: Props): KubbNode {\n return <OperationContext.Provider value={{ operation }}>{children}</OperationContext.Provider>\n}\n\nOperation.Context = OperationContext\n","import { createContext } from '@kubb/react'\n\nimport type { SchemaObject } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { Schema as SchemaType } from '../SchemaMapper.ts'\n\nexport type SchemaContextProps = {\n name: string\n schema?: SchemaObject\n tree: Array<SchemaType>\n}\n\ntype Props = {\n name: string\n value?: SchemaObject\n tree?: Array<SchemaType>\n children?: KubbNode\n}\n\nconst SchemaContext = createContext<SchemaContextProps>({\n name: 'unknown',\n tree: [],\n})\n\nexport function Schema({ name, value, tree = [], children }: Props): KubbNode {\n return <SchemaContext.Provider value={{ name, schema: value, tree }}>{children}</SchemaContext.Provider>\n}\n\nSchema.Context = SchemaContext\n","import { createContext } from '@kubb/react'\n\nimport { Operation } from './Operation.tsx'\nimport { Schema } from './Schema.tsx'\n\nimport type { Oas as OasType, Operation as OperationType } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\n\ntype Props = {\n oas: OasType\n operations?: OperationType[]\n /**\n * @deprecated\n */\n generator?: Omit<OperationGenerator, 'build'>\n children?: KubbNode\n}\n\ntype OasContextProps = {\n oas?: OasType\n operations?: OperationType[]\n /**\n * @deprecated\n */\n generator?: Omit<OperationGenerator, 'build'>\n}\n\nconst OasContext = createContext<OasContextProps>({})\n\nexport function Oas({ oas, children, operations, generator }: Props): KubbNode {\n return <OasContext.Provider value={{ oas, generator, operations }}>{children}</OasContext.Provider>\n}\n\nOas.Context = OasContext\nOas.Operation = Operation\nOas.Schema = Schema\n"]}