@kubb/plugin-oas 3.4.1 → 3.4.3
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.
- package/dist/{OperationGenerator-DSwDeEnz.d.cts → OperationGenerator-zrV0FutY.d.cts} +4 -1
- package/dist/{OperationGenerator-DSwDeEnz.d.ts → OperationGenerator-zrV0FutY.d.ts} +4 -1
- package/dist/{Schema-USOhIC2N.d.ts → Schema-CAK3gCXL.d.ts} +1 -1
- package/dist/{Schema-BWUassTg.d.cts → Schema-CFpQnhg0.d.cts} +1 -1
- package/dist/{chunk-IHPQRZWD.js → chunk-ANLF5HAF.js} +8 -3
- package/dist/chunk-ANLF5HAF.js.map +1 -0
- package/dist/{chunk-WSORDWRC.cjs → chunk-TYJKFH6V.cjs} +8 -3
- package/dist/chunk-TYJKFH6V.cjs.map +1 -0
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/hooks.cjs +9 -10
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +20 -8
- package/dist/hooks.d.ts +20 -8
- package/dist/hooks.js +8 -9
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +7 -7
- package/src/SchemaGenerator.ts +5 -0
- package/src/hooks/useOperationManager.ts +15 -14
- package/src/hooks/useSchemaManager.ts +16 -2
- package/src/types.ts +4 -1
- package/dist/chunk-IHPQRZWD.js.map +0 -1
- package/dist/chunk-WSORDWRC.cjs.map +0 -1
package/dist/hooks.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Oas, Operation, HttpMethod } from '@kubb/oas';
|
|
2
|
-
import { Plugin, ResolveNameParams,
|
|
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-
|
|
6
|
-
import { a as SchemaContextProps } from './Schema-
|
|
5
|
+
import { w as OperationSchemas, f as Schema } from './OperationGenerator-zrV0FutY.cjs';
|
|
6
|
+
import { a as SchemaContextProps } from './Schema-CFpQnhg0.cjs';
|
|
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?:
|
|
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?:
|
|
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
|
|
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?:
|
|
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?:
|
|
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.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Oas, Operation, HttpMethod } from '@kubb/oas';
|
|
2
|
-
import { Plugin, ResolveNameParams,
|
|
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-
|
|
6
|
-
import { a as SchemaContextProps } from './Schema-
|
|
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?:
|
|
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?:
|
|
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
|
|
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?:
|
|
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?:
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { SchemaGenerator, schemaKeywords } from './chunk-
|
|
1
|
+
import { SchemaGenerator, schemaKeywords } from './chunk-ANLF5HAF.js';
|
|
2
2
|
import './chunk-XNCEFOE6.js';
|
|
3
3
|
import { Oas, Operation, Schema } from './chunk-BAU7PO7T.js';
|
|
4
4
|
import { useContext, useApp } from '@kubb/react';
|
|
@@ -27,13 +27,11 @@ function useOperationManager() {
|
|
|
27
27
|
type
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
const getGroup = (operation
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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,
|
|
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,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;AC4CO,SAAS,mBAAiD,GAAA;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,aAAc,EAAA,GAAI,MAAO,EAAA;AACzC,EAAA,MAAM,EAAE,SAAA,EAAcA,GAAAA,UAAAA,CAAW,IAAI,OAAO,CAAA;AAE5C,EAAA,MAAM,OAAgD,GAAA,CAAC,SAAW,EAAA,EAAE,MAAS,GAAA,EAAA,EAAI,MAAS,GAAA,EAAA,EAAI,SAAY,GAAA,MAAA,CAAO,GAAK,EAAA,IAAA,EAAW,KAAA;AAC/H,IAAA,OAAO,cAAc,WAAY,CAAA;AAAA,MAC/B,IAAA,EAAM,GAAG,MAAM,CAAA,CAAA,EAAI,UAAU,cAAe,EAAC,IAAI,MAAM,CAAA,CAAA;AAAA,MACvD,SAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,GACH;AAEA,EAAM,MAAA,QAAA,GAAkD,CAAC,SAAA,EAAW,KAAU,KAAA;AAC5E,IAAI,IAAA,KAAA,EAAO,SAAS,KAAO,EAAA;AACzB,MAAA,OAAO,SAAU,CAAA,OAAA,EAAU,CAAA,EAAA,CA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AQ,WAAW,KAAM;AAAA,KAC3C,CAAA;AAED,IAAO,OAAA;AAAA,MACL,GAAG,IAAA;AAAA,MACH,IAAM,EAAA;AAAA,QACJ,GAAG,IAAK,CAAA,IAAA;AAAA,QACR,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,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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?: {\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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var chunkQXUSUL7H_cjs = require('./chunk-QXUSUL7H.cjs');
|
|
4
4
|
var chunkFSCYFGYN_cjs = require('./chunk-FSCYFGYN.cjs');
|
|
5
5
|
require('./chunk-PADR76WZ.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkTYJKFH6V_cjs = require('./chunk-TYJKFH6V.cjs');
|
|
7
7
|
var chunkQAFBZLJA_cjs = require('./chunk-QAFBZLJA.cjs');
|
|
8
8
|
require('./chunk-KXB5DUFD.cjs');
|
|
9
9
|
var core = require('@kubb/core');
|
|
@@ -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
|
|
328
|
+
const schemaGenerator = new chunkTYJKFH6V_cjs.SchemaGenerator(
|
|
329
329
|
{
|
|
330
330
|
unknownType: "unknown",
|
|
331
331
|
dateType: "date",
|
|
@@ -371,15 +371,15 @@ Object.defineProperty(exports, "createReactGenerator", {
|
|
|
371
371
|
});
|
|
372
372
|
Object.defineProperty(exports, "SchemaGenerator", {
|
|
373
373
|
enumerable: true,
|
|
374
|
-
get: function () { return
|
|
374
|
+
get: function () { return chunkTYJKFH6V_cjs.SchemaGenerator; }
|
|
375
375
|
});
|
|
376
376
|
Object.defineProperty(exports, "isKeyword", {
|
|
377
377
|
enumerable: true,
|
|
378
|
-
get: function () { return
|
|
378
|
+
get: function () { return chunkTYJKFH6V_cjs.isKeyword; }
|
|
379
379
|
});
|
|
380
380
|
Object.defineProperty(exports, "schemaKeywords", {
|
|
381
381
|
enumerable: true,
|
|
382
|
-
get: function () { return
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
@@ -2,8 +2,8 @@ import { parseFromConfig } from './chunk-BZOI3PL5.js';
|
|
|
2
2
|
import { jsonGenerator } from './chunk-WBHFV7C2.js';
|
|
3
3
|
export { createGenerator, createReactGenerator } from './chunk-WBHFV7C2.js';
|
|
4
4
|
import './chunk-R47XMJ32.js';
|
|
5
|
-
import { SchemaGenerator } from './chunk-
|
|
6
|
-
export { SchemaGenerator, isKeyword, schemaKeywords } from './chunk-
|
|
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
8
|
import './chunk-BAU7PO7T.js';
|
|
9
9
|
import { createPlugin, FileManager, BaseGenerator } from '@kubb/core';
|
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-
|
|
6
|
-
export { z as GetSchemasProps, B as getSchemas } from './OperationGenerator-
|
|
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-
|
|
6
|
-
export { z as GetSchemasProps, B as getSchemas } from './OperationGenerator-
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"description": "Generator swagger",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -76,18 +76,18 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@stoplight/yaml": "^4.3.0",
|
|
78
78
|
"remeda": "^2.19.0",
|
|
79
|
-
"@kubb/core": "3.4.
|
|
80
|
-
"@kubb/fs": "3.4.
|
|
81
|
-
"@kubb/oas": "3.4.
|
|
82
|
-
"@kubb/react": "3.4.
|
|
79
|
+
"@kubb/core": "3.4.3",
|
|
80
|
+
"@kubb/fs": "3.4.3",
|
|
81
|
+
"@kubb/oas": "3.4.3",
|
|
82
|
+
"@kubb/react": "3.4.3"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
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": "3.4.
|
|
90
|
-
"@kubb/config-tsup": "3.4.
|
|
89
|
+
"@kubb/config-ts": "3.4.3",
|
|
90
|
+
"@kubb/config-tsup": "3.4.3"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@kubb/react": "^3.0.0"
|
package/src/SchemaGenerator.ts
CHANGED
|
@@ -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
|
|
|
@@ -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?:
|
|
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?:
|
|
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
|
|
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
|
|
75
|
-
|
|
76
|
-
|
|
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?:
|
|
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: (
|
|
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