@kubb/plugin-oas 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Oas--cvTRMTA.cjs → Oas-BzrQ6RGC.cjs} +11 -11
- package/dist/Oas-BzrQ6RGC.cjs.map +1 -0
- package/dist/{Oas-DoN76W2_.js → Oas-CIeHKOo0.js} +3 -3
- package/dist/Oas-CIeHKOo0.js.map +1 -0
- package/dist/{OperationGenerator-ki8g970_.d.ts → OperationGenerator-BZPWkxw4.d.ts} +164 -92
- package/dist/{OperationGenerator-XkW6FZJh.d.cts → OperationGenerator-CJTAer7l.d.cts} +163 -91
- package/dist/{Schema-CHstINXC.d.ts → Schema-CjraJhJi.d.ts} +7 -6
- package/dist/{Schema-BXYfUkqN.d.cts → Schema-zcZF0UIp.d.cts} +6 -5
- package/dist/{SchemaGenerator-B07tXh1b.js → SchemaGenerator-7wBwdv8G.js} +21 -4
- package/dist/{SchemaGenerator-B07tXh1b.js.map → SchemaGenerator-7wBwdv8G.js.map} +1 -1
- package/dist/{SchemaGenerator-DsK0wuii.cjs → SchemaGenerator-DzVHk6OP.cjs} +22 -5
- package/dist/SchemaGenerator-DzVHk6OP.cjs.map +1 -0
- package/dist/{SchemaMapper-qjB3rBph.d.ts → SchemaMapper-CqBW0VOy.d.ts} +1 -1
- package/dist/{SchemaMapper-CM1eXksi.js → SchemaMapper-Cx4X1al6.js} +1 -1
- package/dist/{SchemaMapper-CM1eXksi.js.map → SchemaMapper-Cx4X1al6.js.map} +1 -1
- package/dist/{SchemaMapper-CpAbmGiH.cjs → SchemaMapper-DoL-a6qq.cjs} +1 -1
- package/dist/{SchemaMapper-CpAbmGiH.cjs.map → SchemaMapper-DoL-a6qq.cjs.map} +1 -1
- package/dist/chunk-BEV-X5tz.js +27 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +7 -6
- package/dist/components.d.ts +8 -7
- package/dist/components.js +1 -1
- package/dist/generators-B27La9Vd.cjs +99 -0
- package/dist/generators-B27La9Vd.cjs.map +1 -0
- package/dist/generators-C61FxVIj.js +80 -0
- package/dist/generators-C61FxVIj.js.map +1 -0
- package/dist/generators.cjs +9 -3
- package/dist/generators.d.cts +2 -7
- package/dist/generators.d.ts +3 -8
- package/dist/generators.js +5 -4
- package/dist/{getFooter-pQXwqM81.cjs → getFooter-CwjCW4h5.cjs} +3 -3
- package/dist/{getFooter-pQXwqM81.cjs.map → getFooter-CwjCW4h5.cjs.map} +1 -1
- package/dist/{getFooter-CvTKkK7-.js → getFooter-D5MdeUVv.js} +2 -2
- package/dist/{getFooter-CvTKkK7-.js.map → getFooter-D5MdeUVv.js.map} +1 -1
- package/dist/{getSchemas-CvUX0jWa.js → getSchemas-Bdg6n9Qk.js} +1 -1
- package/dist/{getSchemas-CvUX0jWa.js.map → getSchemas-Bdg6n9Qk.js.map} +1 -1
- package/dist/{getSchemas-08CU8KWq.cjs → getSchemas-DY8s2CSl.cjs} +1 -1
- package/dist/{getSchemas-08CU8KWq.cjs.map → getSchemas-DY8s2CSl.cjs.map} +1 -1
- package/dist/hooks.cjs +12 -11
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +6 -5
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -8
- package/dist/index.d.ts +3 -9
- package/dist/index.js +33 -9
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{parseFromConfig-DSI6Meg0.js → parseFromConfig-CqiiLCPe.js} +1 -1
- package/dist/{parseFromConfig-DSI6Meg0.js.map → parseFromConfig-CqiiLCPe.js.map} +1 -1
- package/dist/{parseFromConfig-o3tU1XJt.cjs → parseFromConfig-RR31a98-.cjs} +1 -1
- package/dist/{parseFromConfig-o3tU1XJt.cjs.map → parseFromConfig-RR31a98-.cjs.map} +1 -1
- package/dist/utils-BnkB1ikY.js +99 -0
- package/dist/utils-BnkB1ikY.js.map +1 -0
- package/dist/utils-nzdccPlU.cjs +119 -0
- package/dist/utils-nzdccPlU.cjs.map +1 -0
- package/dist/utils.cjs +3 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +3 -2
- package/dist/utils.d.ts +4 -3
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +6 -7
- package/src/OperationGenerator.ts +36 -7
- package/src/SchemaGenerator.ts +25 -1
- package/src/components/Oas.tsx +5 -7
- package/src/components/Operation.tsx +3 -3
- package/src/components/Schema.tsx +3 -4
- package/src/generators/createGenerator.ts +34 -0
- package/src/generators/createReactGenerator.ts +41 -0
- package/src/generators/index.ts +4 -0
- package/src/generators/jsonGenerator.ts +1 -1
- package/src/generators/types.ts +35 -0
- package/src/generators/utils.tsx +114 -0
- package/src/hooks/useOas.ts +1 -1
- package/src/hooks/useOperation.ts +1 -1
- package/src/hooks/useOperationManager.ts +1 -1
- package/src/hooks/useOperations.ts +1 -1
- package/src/hooks/useSchema.ts +1 -1
- package/src/index.ts +3 -5
- package/src/plugin.ts +2 -0
- package/src/types.ts +1 -1
- package/src/utils/getParams.ts +1 -1
- package/dist/Oas--cvTRMTA.cjs.map +0 -1
- package/dist/Oas-DoN76W2_.js.map +0 -1
- package/dist/SchemaGenerator-DsK0wuii.cjs.map +0 -1
- package/dist/generators-BUNmB1lx.js +0 -154
- package/dist/generators-BUNmB1lx.js.map +0 -1
- package/dist/generators-CoiXCnDY.cjs +0 -175
- package/dist/generators-CoiXCnDY.cjs.map +0 -1
- package/src/generator.tsx +0 -139
package/dist/mocks.cjs
CHANGED
package/dist/mocks.d.ts
CHANGED
package/dist/mocks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFromConfig-
|
|
1
|
+
{"version":3,"file":"parseFromConfig-CqiiLCPe.js","names":[],"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { merge, parse } from '@kubb/oas'\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 (Array.isArray(config.input)) {\n return merge(\n config.input.map((input) => input.path),\n { oasClass },\n )\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"],"mappings":";;;;;;AAUA,SAAgB,gBAAgB,QAAgB,WAAuB,KAAmB;AACxF,KAAI,UAAU,OAAO,OAAO;AAC1B,MAAI,OAAO,OAAO,MAAM,SAAS,SAE/B,QAAO,MAD2B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAC7D,EAAE,UAAU,CAAC;AAGjC,MAAI;AAGF,UAAO,MAFa,KAAK,MAAM,OAAO,MAAM,KAAe,EAEzC,EAAE,UAAU,CAAC;WACxB,IAAI;AAMb,SAAO,MAF2B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAE7D,EAAE,UAAU,CAAC;;AAGjC,KAAI,MAAM,QAAQ,OAAO,MAAM,CAC7B,QAAO,MACL,OAAO,MAAM,KAAK,UAAU,MAAM,KAAK,EACvC,EAAE,UAAU,CACb;AAGH,KAAI,IAAI,QAAQ,OAAO,MAAM,KAAK,CAAC,MACjC,QAAO,MAAM,OAAO,MAAM,MAAM,EAAE,UAAU,CAAC;AAG/C,QAAO,MAAM,QAAQ,OAAO,MAAM,OAAO,MAAM,KAAK,EAAE,EAAE,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFromConfig-
|
|
1
|
+
{"version":3,"file":"parseFromConfig-RR31a98-.cjs","names":["Oas","yaml","URLPath"],"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { merge, parse } from '@kubb/oas'\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 (Array.isArray(config.input)) {\n return merge(\n config.input.map((input) => input.path),\n { oasClass },\n )\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"],"mappings":";;;;;;;;;;;AAUA,SAAgB,gBAAgB,QAAgB,WAAuBA,gBAAmB;AACxF,KAAI,UAAU,OAAO,OAAO;AAC1B,MAAI,OAAO,OAAO,MAAM,SAAS,SAE/B,8BADkC,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAC7D,EAAE,UAAU,CAAC;AAGjC,MAAI;AAGF,gCAFoBC,yBAAK,MAAM,OAAO,MAAM,KAAe,EAEzC,EAAE,UAAU,CAAC;WACxB,IAAI;AAMb,+BAFkC,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC,EAE7D,EAAE,UAAU,CAAC;;AAGjC,KAAI,MAAM,QAAQ,OAAO,MAAM,CAC7B,8BACE,OAAO,MAAM,KAAK,UAAU,MAAM,KAAK,EACvC,EAAE,UAAU,CACb;AAGH,KAAI,IAAIC,0BAAQ,OAAO,MAAM,KAAK,CAAC,MACjC,8BAAa,OAAO,MAAM,MAAM,EAAE,UAAU,CAAC;AAG/C,qDAAqB,OAAO,MAAM,OAAO,MAAM,KAAK,EAAE,EAAE,UAAU,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { t as Oas } from "./Oas-CIeHKOo0.js";
|
|
2
|
+
import { App, createReactFabric } from "@kubb/react-fabric";
|
|
3
|
+
import { jsx } from "@kubb/react-fabric/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/generators/utils.tsx
|
|
6
|
+
async function buildOperations(operations, { fabric, options, instance, generator }) {
|
|
7
|
+
if (!generator.Operations) return;
|
|
8
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
9
|
+
function Component() {
|
|
10
|
+
return /* @__PURE__ */ jsx(App, {
|
|
11
|
+
meta: {
|
|
12
|
+
pluginManager,
|
|
13
|
+
plugin,
|
|
14
|
+
mode
|
|
15
|
+
},
|
|
16
|
+
children: /* @__PURE__ */ jsx(Oas, {
|
|
17
|
+
oas,
|
|
18
|
+
operations,
|
|
19
|
+
generator: instance,
|
|
20
|
+
children: /* @__PURE__ */ jsx(generator.Operations, {
|
|
21
|
+
operations,
|
|
22
|
+
instance,
|
|
23
|
+
options
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const fabricChild = createReactFabric();
|
|
29
|
+
fabricChild.render(Component);
|
|
30
|
+
await fabric.context.fileManager.add(...fabricChild.files);
|
|
31
|
+
}
|
|
32
|
+
async function buildOperation(operation, { fabric, options, instance, generator }) {
|
|
33
|
+
if (!generator.Operation) return;
|
|
34
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
35
|
+
function Component() {
|
|
36
|
+
return /* @__PURE__ */ jsx(App, {
|
|
37
|
+
meta: {
|
|
38
|
+
pluginManager,
|
|
39
|
+
plugin: {
|
|
40
|
+
...plugin,
|
|
41
|
+
options
|
|
42
|
+
},
|
|
43
|
+
mode
|
|
44
|
+
},
|
|
45
|
+
children: /* @__PURE__ */ jsx(Oas, {
|
|
46
|
+
oas,
|
|
47
|
+
operations: [operation],
|
|
48
|
+
generator: instance,
|
|
49
|
+
children: /* @__PURE__ */ jsx(Oas.Operation, {
|
|
50
|
+
operation,
|
|
51
|
+
children: /* @__PURE__ */ jsx(generator.Operation, {
|
|
52
|
+
operation,
|
|
53
|
+
options,
|
|
54
|
+
instance
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const fabricChild = createReactFabric();
|
|
61
|
+
fabricChild.render(Component);
|
|
62
|
+
await fabric.context.fileManager.add(...fabricChild.files);
|
|
63
|
+
}
|
|
64
|
+
async function buildSchema(schema, { fabric, options, instance, generator }) {
|
|
65
|
+
if (!generator.Schema) return;
|
|
66
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
67
|
+
function Component() {
|
|
68
|
+
return /* @__PURE__ */ jsx(App, {
|
|
69
|
+
meta: {
|
|
70
|
+
pluginManager,
|
|
71
|
+
plugin: {
|
|
72
|
+
...plugin,
|
|
73
|
+
options
|
|
74
|
+
},
|
|
75
|
+
mode
|
|
76
|
+
},
|
|
77
|
+
children: /* @__PURE__ */ jsx(Oas, {
|
|
78
|
+
oas,
|
|
79
|
+
children: /* @__PURE__ */ jsx(Oas.Schema, {
|
|
80
|
+
name: schema.name,
|
|
81
|
+
schemaObject: schema.value,
|
|
82
|
+
tree: schema.tree,
|
|
83
|
+
children: /* @__PURE__ */ jsx(generator.Schema, {
|
|
84
|
+
schema,
|
|
85
|
+
options,
|
|
86
|
+
instance
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const fabricChild = createReactFabric();
|
|
93
|
+
fabricChild.render(Component);
|
|
94
|
+
await fabric.context.fileManager.add(...fabricChild.files);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
export { buildOperations as n, buildSchema as r, buildOperation as t };
|
|
99
|
+
//# sourceMappingURL=utils-BnkB1ikY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-BnkB1ikY.js","names":[],"sources":["../src/generators/utils.tsx"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createReactFabric, type Fabric } from '@kubb/react-fabric'\nimport { Oas } from '../components/Oas.tsx'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper.ts'\nimport type { ReactGenerator } from './/createReactGenerator.ts'\n\ntype BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {\n fabric: Fabric\n generator: ReactGenerator<any>\n /**\n * @deprecated\n */\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n}\n\nexport async function buildOperations<TOptions extends PluginFactoryOptions>(\n operations: Array<Operation>,\n { fabric, options, instance, generator }: BuildOperationsOptions<TOptions>,\n): Promise<void> {\n if (!generator.Operations) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin, mode }}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <generator.Operations operations={operations} instance={instance} options={options} />\n </Oas>\n </App>\n )\n }\n\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n\ntype BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>\n\nexport async function buildOperation<TOptions extends PluginFactoryOptions>(\n operation: Operation,\n { fabric, options, instance, generator }: BuildOperationOptions<TOptions>,\n): Promise<void> {\n if (!generator.Operation) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <generator.Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>\n )\n }\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n\ntype BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {\n fabric: Fabric\n generator: ReactGenerator<any>\n /**\n * @deprecated\n */\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n}\n\nexport async function buildSchema<TOptions extends PluginFactoryOptions>(\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n },\n { fabric, options, instance, generator }: BuildSchemaOptions<TOptions>,\n): Promise<void> {\n if (!generator.Schema) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <generator.Schema schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>\n )\n }\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n"],"mappings":";;;;;AAmBA,eAAsB,gBACpB,YACA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,WACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,oBAAC;GAAI,MAAM;IAAE;IAAe;IAAQ;IAAM;aACxC,oBAAC;IAAS;IAAiB;IAAY,WAAW;cAChD,oBAAC,UAAU;KAAuB;KAAsB;KAAmB;MAAW;KAClF;IACF;;CAIV,MAAM,cAAc,mBAAmB;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM;;AAK5D,eAAsB,eACpB,WACA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,UACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,oBAAC;GAAI,MAAM;IAAE;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAE;IAAM;aAChE,oBAAC;IAAS;IAAK,YAAY,CAAC,UAAU;IAAE,WAAW;cACjD,oBAAC,IAAI;KAAqB;eACxB,oBAAC,UAAU;MAAqB;MAAoB;MAAmB;OAAY;MACrE;KACZ;IACF;;CAGV,MAAM,cAAc,mBAAmB;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM;;AAa5D,eAAsB,YACpB,QAKA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,OACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,oBAAC;GAAI,MAAM;IAAE;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAE;IAAM;aAChE,oBAAC;IAAS;cACR,oBAAC,IAAI;KAAO,MAAM,OAAO;KAAM,cAAc,OAAO;KAAO,MAAM,OAAO;eACtE,oBAAC,UAAU;MAAe;MAAiB;MAAmB;OAAY;MAC/D;KACT;IACF;;CAGV,MAAM,cAAc,mBAAmB;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_Oas = require('./Oas-BzrQ6RGC.cjs');
|
|
3
|
+
let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
4
|
+
__kubb_react_fabric = require_chunk.__toESM(__kubb_react_fabric);
|
|
5
|
+
let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
6
|
+
__kubb_react_fabric_jsx_runtime = require_chunk.__toESM(__kubb_react_fabric_jsx_runtime);
|
|
7
|
+
|
|
8
|
+
//#region src/generators/utils.tsx
|
|
9
|
+
async function buildOperations(operations, { fabric, options, instance, generator }) {
|
|
10
|
+
if (!generator.Operations) return;
|
|
11
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
12
|
+
function Component() {
|
|
13
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.App, {
|
|
14
|
+
meta: {
|
|
15
|
+
pluginManager,
|
|
16
|
+
plugin,
|
|
17
|
+
mode
|
|
18
|
+
},
|
|
19
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas, {
|
|
20
|
+
oas,
|
|
21
|
+
operations,
|
|
22
|
+
generator: instance,
|
|
23
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(generator.Operations, {
|
|
24
|
+
operations,
|
|
25
|
+
instance,
|
|
26
|
+
options
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const fabricChild = (0, __kubb_react_fabric.createReactFabric)();
|
|
32
|
+
fabricChild.render(Component);
|
|
33
|
+
await fabric.context.fileManager.add(...fabricChild.files);
|
|
34
|
+
}
|
|
35
|
+
async function buildOperation(operation, { fabric, options, instance, generator }) {
|
|
36
|
+
if (!generator.Operation) return;
|
|
37
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
38
|
+
function Component() {
|
|
39
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.App, {
|
|
40
|
+
meta: {
|
|
41
|
+
pluginManager,
|
|
42
|
+
plugin: {
|
|
43
|
+
...plugin,
|
|
44
|
+
options
|
|
45
|
+
},
|
|
46
|
+
mode
|
|
47
|
+
},
|
|
48
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas, {
|
|
49
|
+
oas,
|
|
50
|
+
operations: [operation],
|
|
51
|
+
generator: instance,
|
|
52
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas.Operation, {
|
|
53
|
+
operation,
|
|
54
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(generator.Operation, {
|
|
55
|
+
operation,
|
|
56
|
+
options,
|
|
57
|
+
instance
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const fabricChild = (0, __kubb_react_fabric.createReactFabric)();
|
|
64
|
+
fabricChild.render(Component);
|
|
65
|
+
await fabric.context.fileManager.add(...fabricChild.files);
|
|
66
|
+
}
|
|
67
|
+
async function buildSchema(schema, { fabric, options, instance, generator }) {
|
|
68
|
+
if (!generator.Schema) return;
|
|
69
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
70
|
+
function Component() {
|
|
71
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.App, {
|
|
72
|
+
meta: {
|
|
73
|
+
pluginManager,
|
|
74
|
+
plugin: {
|
|
75
|
+
...plugin,
|
|
76
|
+
options
|
|
77
|
+
},
|
|
78
|
+
mode
|
|
79
|
+
},
|
|
80
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas, {
|
|
81
|
+
oas,
|
|
82
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_Oas.Oas.Schema, {
|
|
83
|
+
name: schema.name,
|
|
84
|
+
schemaObject: schema.value,
|
|
85
|
+
tree: schema.tree,
|
|
86
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(generator.Schema, {
|
|
87
|
+
schema,
|
|
88
|
+
options,
|
|
89
|
+
instance
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const fabricChild = (0, __kubb_react_fabric.createReactFabric)();
|
|
96
|
+
fabricChild.render(Component);
|
|
97
|
+
await fabric.context.fileManager.add(...fabricChild.files);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
Object.defineProperty(exports, 'buildOperation', {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return buildOperation;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, 'buildOperations', {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () {
|
|
110
|
+
return buildOperations;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, 'buildSchema', {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return buildSchema;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=utils-nzdccPlU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-nzdccPlU.cjs","names":["App","Oas"],"sources":["../src/generators/utils.tsx"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createReactFabric, type Fabric } from '@kubb/react-fabric'\nimport { Oas } from '../components/Oas.tsx'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper.ts'\nimport type { ReactGenerator } from './/createReactGenerator.ts'\n\ntype BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {\n fabric: Fabric\n generator: ReactGenerator<any>\n /**\n * @deprecated\n */\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n}\n\nexport async function buildOperations<TOptions extends PluginFactoryOptions>(\n operations: Array<Operation>,\n { fabric, options, instance, generator }: BuildOperationsOptions<TOptions>,\n): Promise<void> {\n if (!generator.Operations) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin, mode }}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <generator.Operations operations={operations} instance={instance} options={options} />\n </Oas>\n </App>\n )\n }\n\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n\ntype BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>\n\nexport async function buildOperation<TOptions extends PluginFactoryOptions>(\n operation: Operation,\n { fabric, options, instance, generator }: BuildOperationOptions<TOptions>,\n): Promise<void> {\n if (!generator.Operation) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <generator.Operation operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>\n )\n }\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n\ntype BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {\n fabric: Fabric\n generator: ReactGenerator<any>\n /**\n * @deprecated\n */\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n}\n\nexport async function buildSchema<TOptions extends PluginFactoryOptions>(\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n },\n { fabric, options, instance, generator }: BuildSchemaOptions<TOptions>,\n): Promise<void> {\n if (!generator.Schema) {\n return undefined\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n function Component() {\n return (\n <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <generator.Schema schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>\n )\n }\n const fabricChild = createReactFabric()\n fabricChild.render(Component)\n\n await fabric.context.fileManager.add(...fabricChild.files)\n}\n"],"mappings":";;;;;;;;AAmBA,eAAsB,gBACpB,YACA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,WACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,yDAACA;GAAI,MAAM;IAAE;IAAe;IAAQ;IAAM;aACxC,yDAACC;IAAS;IAAiB;IAAY,WAAW;cAChD,yDAAC,UAAU;KAAuB;KAAsB;KAAmB;MAAW;KAClF;IACF;;CAIV,MAAM,0DAAiC;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM;;AAK5D,eAAsB,eACpB,WACA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,UACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,yDAACD;GAAI,MAAM;IAAE;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAE;IAAM;aAChE,yDAACC;IAAS;IAAK,YAAY,CAAC,UAAU;IAAE,WAAW;cACjD,yDAACA,gBAAI;KAAqB;eACxB,yDAAC,UAAU;MAAqB;MAAoB;MAAmB;OAAY;MACrE;KACZ;IACF;;CAGV,MAAM,0DAAiC;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM;;AAa5D,eAAsB,YACpB,QAKA,EAAE,QAAQ,SAAS,UAAU,aACd;AACf,KAAI,CAAC,UAAU,OACb;CAGF,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;CAEtD,SAAS,YAAY;AACnB,SACE,yDAACD;GAAI,MAAM;IAAE;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAE;IAAM;aAChE,yDAACC;IAAS;cACR,yDAACA,gBAAI;KAAO,MAAM,OAAO;KAAM,cAAc,OAAO;KAAO,MAAM,OAAO;eACtE,yDAAC,UAAU;MAAe;MAAiB;MAAmB;OAAY;MAC/D;KACT;IACF;;CAGV,MAAM,0DAAiC;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_getFooter = require('./getFooter-
|
|
3
|
-
const require_getSchemas = require('./getSchemas-
|
|
4
|
-
const require_parseFromConfig = require('./parseFromConfig-
|
|
2
|
+
const require_getFooter = require('./getFooter-CwjCW4h5.cjs');
|
|
3
|
+
const require_getSchemas = require('./getSchemas-DY8s2CSl.cjs');
|
|
4
|
+
const require_parseFromConfig = require('./parseFromConfig-RR31a98-.cjs');
|
|
5
5
|
let __kubb_core_transformers = require("@kubb/core/transformers");
|
|
6
6
|
__kubb_core_transformers = require_chunk.__toESM(__kubb_core_transformers);
|
|
7
7
|
let __kubb_core_utils = require("@kubb/core/utils");
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["URLPath","transformers","data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n"],"mappings":";;;;;;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAIA,0BAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAASC,iCAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACD3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,4CAA4B,OAAO;EACzC,MAAMC,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,oDAAsB,KAAK,KAAK,GAAG,KAAK,+CAAiB,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,gDAAiB,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["URLPath","transformers","data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n"],"mappings":";;;;;;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAIA,0BAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAASC,iCAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACD3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,4CAA4B,OAAO;EACzC,MAAMC,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,oDAAsB,KAAK,KAAK,GAAG,KAAK,+CAAiB,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,gDAAiB,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as Config, B as SchemaObject$1, I as OasTypes, L as OpenAPIV3$1, P as Oas, R as OpenAPIV3_1, V as contentType, j as Output, v as OperationSchema, z as Operation } from "./OperationGenerator-CJTAer7l.cjs";
|
|
2
2
|
import "./SchemaMapper-MiRB5_Zp.cjs";
|
|
3
3
|
import { OASDocument, SchemaObject } from "oas/types";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
|
+
import { Params } from "@kubb/react-fabric/types";
|
|
5
6
|
|
|
6
7
|
//#region ../oas/src/utils.d.ts
|
|
7
8
|
|
|
@@ -47,7 +48,7 @@ declare function getPathParams(operationSchema: OperationSchema | undefined, opt
|
|
|
47
48
|
typed?: boolean;
|
|
48
49
|
casing?: 'camelcase';
|
|
49
50
|
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
50
|
-
}):
|
|
51
|
+
}): Params;
|
|
51
52
|
//#endregion
|
|
52
53
|
//#region src/utils/getSchemaFactory.d.ts
|
|
53
54
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./SchemaMapper-
|
|
1
|
+
import { A as Config, B as SchemaObject$1, I as OasTypes, L as OpenAPIV3$1, P as Oas, R as OpenAPIV3_1, V as contentType, j as Output, v as OperationSchema, z as Operation } from "./OperationGenerator-BZPWkxw4.js";
|
|
2
|
+
import "./SchemaMapper-CqBW0VOy.js";
|
|
3
3
|
import { OASDocument, SchemaObject } from "oas/types";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
|
+
import { Params } from "@kubb/react-fabric/types";
|
|
5
6
|
|
|
6
7
|
//#region ../oas/src/utils.d.ts
|
|
7
8
|
|
|
@@ -47,7 +48,7 @@ declare function getPathParams(operationSchema: OperationSchema | undefined, opt
|
|
|
47
48
|
typed?: boolean;
|
|
48
49
|
casing?: 'camelcase';
|
|
49
50
|
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
50
|
-
}):
|
|
51
|
+
}): Params;
|
|
51
52
|
//#endregion
|
|
52
53
|
//#region src/utils/getSchemaFactory.d.ts
|
|
53
54
|
/**
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as getBanner, t as getFooter } from "./getFooter-
|
|
2
|
-
import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-
|
|
3
|
-
import { t as parseFromConfig } from "./parseFromConfig-
|
|
1
|
+
import { n as getBanner, t as getFooter } from "./getFooter-D5MdeUVv.js";
|
|
2
|
+
import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-Bdg6n9Qk.js";
|
|
3
|
+
import { t as parseFromConfig } from "./parseFromConfig-CqiiLCPe.js";
|
|
4
4
|
import transformers, { camelCase, isValidVarName } from "@kubb/core/transformers";
|
|
5
5
|
import { URLPath } from "@kubb/core/utils";
|
|
6
6
|
import { isOptional, isParameterObject } from "@kubb/oas";
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAI,QAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAAS,aAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACD3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAMA,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,OAAO,eAAe,KAAK,KAAK,GAAG,KAAK,OAAO,UAAU,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,QAAO,UAAU,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":["data: FunctionParamsAST"],"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,YAAY,WAAgC;AAC1D,QAAO;EACL,UAAU,gBAAgB,IAAI,gBAAgB,UAAU,gBAAgB;EACxE,UAAU,YAAY,IAAI,YAAY,UAAU,YAAY;EAC5D,UAAU,QAAQ,UAAU,IAAI,QAAQ,UAAU,KAAK,CAAC,IAAI;EAC5D,UAAU,cAAc,IAAI;EAC7B,CACE,OAAO,QAAQ,CACf,KAAK,SAAS,aAAa,KAAK,KAAK,CAAC;;;;;;;;;;ACD3C,SAAgB,aACd,iBACA,EACE,QAAQ,OACR,aAIE,EAAE,EACe;AACrB,KAAI,CAAC,mBAAmB,CAAC,gBAAgB,OAAO,cAAc,CAAC,gBAAgB,KAC7E,QAAO,EAAE;AAGX,QAAO,OAAO,QAAQ,gBAAgB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,YAA6C;EAChH,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAMA,OAA0B;GAC9B;GACA,SAAS,CAAC,CAAC;GACX,UAAU,UAAU,OAAO,WAAW;GACtC,MAAM,QAAQ,GAAG,gBAAgB,KAAK,IAAI,KAAK,MAAM;GACtD;AAED,SAAO,WAAW,SAAS,KAAK,GAAG;GACnC;;AAGJ,SAAgB,cACd,iBACA,UAII,EAAE,EACN;AACA,QAAO,aAAa,iBAAiB,QAAQ,CAAC,QAAQ,KAAK,SAAS;AAClE,MAAI,KAAK,QAAQ,KAAK,SAAS;GAC7B,IAAI,OAAO,eAAe,KAAK,KAAK,GAAG,KAAK,OAAO,UAAU,KAAK,KAAK;AAEvE,OAAI,QAAQ,WAAW,YACrB,QAAO,UAAU,KAAK;AAGxB,OAAI,QAAQ;IACV,SAAS,KAAK;IACd,MAAM,KAAK;IACX,UAAU,CAAC,KAAK;IACjB;;AAGH,SAAO;IACN,EAAE,CAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -79,20 +79,19 @@
|
|
|
79
79
|
"!/**/__tests__/**"
|
|
80
80
|
],
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@kubb/react-fabric": "0.
|
|
82
|
+
"@kubb/react-fabric": "0.2.8",
|
|
83
83
|
"@stoplight/yaml": "^4.3.0",
|
|
84
84
|
"p-limit": "^7.2.0",
|
|
85
85
|
"remeda": "^2.32.0",
|
|
86
|
-
"@kubb/core": "4.
|
|
87
|
-
"@kubb/oas": "4.
|
|
88
|
-
"@kubb/react": "4.3.0"
|
|
86
|
+
"@kubb/core": "4.4.0",
|
|
87
|
+
"@kubb/oas": "4.4.0"
|
|
89
88
|
},
|
|
90
89
|
"devDependencies": {
|
|
91
|
-
"tsdown": "^0.15.
|
|
90
|
+
"tsdown": "^0.15.11",
|
|
92
91
|
"typescript": "^5.9.3"
|
|
93
92
|
},
|
|
94
93
|
"peerDependencies": {
|
|
95
|
-
"@kubb/react": "
|
|
94
|
+
"@kubb/react-fabric": "0.2.8"
|
|
96
95
|
},
|
|
97
96
|
"engines": {
|
|
98
97
|
"node": ">=20"
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import type { Plugin, PluginFactoryOptions, PluginManager } from '@kubb/core'
|
|
1
2
|
import { BaseGenerator, type FileMetaBase } from '@kubb/core'
|
|
2
|
-
import transformers from '@kubb/core/transformers'
|
|
3
|
-
|
|
4
|
-
import type { PluginFactoryOptions, PluginManager } from '@kubb/core'
|
|
5
3
|
import type { KubbFile } from '@kubb/core/fs'
|
|
6
|
-
import
|
|
7
|
-
import type { HttpMethod, Oas, OasTypes, Operation, SchemaObject
|
|
8
|
-
import type {
|
|
9
|
-
import type { Exclude, Include, OperationSchemas, Override } from './types.ts'
|
|
4
|
+
import transformers from '@kubb/core/transformers'
|
|
5
|
+
import type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'
|
|
6
|
+
import type { Fabric } from '@kubb/react-fabric'
|
|
10
7
|
import pLimit from 'p-limit'
|
|
8
|
+
import type { Generator } from './generators/types.ts'
|
|
9
|
+
import { buildOperation, buildOperations } from './generators/utils.tsx'
|
|
10
|
+
import type { Exclude, Include, OperationSchemas, Override } from './types.ts'
|
|
11
11
|
|
|
12
12
|
export type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
|
|
13
13
|
|
|
14
14
|
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
15
|
+
fabric: Fabric
|
|
15
16
|
oas: Oas
|
|
16
17
|
exclude: Array<Exclude> | undefined
|
|
17
18
|
include: Array<Include> | undefined
|
|
@@ -226,6 +227,20 @@ export class OperationGenerator<
|
|
|
226
227
|
operationLimit(async () => {
|
|
227
228
|
const options = this.#getOptions(operation, method)
|
|
228
229
|
|
|
230
|
+
if (generator.type === 'react') {
|
|
231
|
+
await buildOperation(operation, {
|
|
232
|
+
fabric: this.context.fabric,
|
|
233
|
+
generator,
|
|
234
|
+
instance: this,
|
|
235
|
+
options: {
|
|
236
|
+
...this.options,
|
|
237
|
+
...options,
|
|
238
|
+
},
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
return []
|
|
242
|
+
}
|
|
243
|
+
|
|
229
244
|
const result = await generator.operation?.({
|
|
230
245
|
instance: this,
|
|
231
246
|
operation,
|
|
@@ -239,6 +254,20 @@ export class OperationGenerator<
|
|
|
239
254
|
const operationResults = await Promise.all(operationTasks)
|
|
240
255
|
const opResultsFlat = operationResults.flat()
|
|
241
256
|
|
|
257
|
+
if (generator.type === 'react') {
|
|
258
|
+
await buildOperations(
|
|
259
|
+
operations.map((op) => op.operation),
|
|
260
|
+
{
|
|
261
|
+
fabric: this.context.fabric,
|
|
262
|
+
generator,
|
|
263
|
+
instance: this,
|
|
264
|
+
options: this.options,
|
|
265
|
+
},
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
return []
|
|
269
|
+
}
|
|
270
|
+
|
|
242
271
|
const operationsResult = await generator.operations?.({
|
|
243
272
|
instance: this,
|
|
244
273
|
operations: operations.map((op) => op.operation),
|
package/src/SchemaGenerator.ts
CHANGED
|
@@ -5,9 +5,11 @@ import transformers, { pascalCase } from '@kubb/core/transformers'
|
|
|
5
5
|
import { getUniqueName } from '@kubb/core/utils'
|
|
6
6
|
import type { contentType, Oas, OpenAPIV3, SchemaObject } from '@kubb/oas'
|
|
7
7
|
import { isDiscriminator, isNullable, isReference } from '@kubb/oas'
|
|
8
|
+
import type { Fabric } from '@kubb/react-fabric'
|
|
8
9
|
import pLimit from 'p-limit'
|
|
9
10
|
import { isDeepEqual, isNumber, uniqueWith } from 'remeda'
|
|
10
|
-
import type { Generator } from './
|
|
11
|
+
import type { Generator } from './generators/types.ts'
|
|
12
|
+
import { buildSchema } from './generators/utils.tsx'
|
|
11
13
|
import type { Schema, SchemaKeywordMapper } from './SchemaMapper.ts'
|
|
12
14
|
import { isKeyword, schemaKeywords } from './SchemaMapper.ts'
|
|
13
15
|
import type { OperationSchema, Override, Refs } from './types.ts'
|
|
@@ -19,6 +21,7 @@ export type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>>
|
|
|
19
21
|
export type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
|
|
20
22
|
|
|
21
23
|
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
24
|
+
fabric: Fabric
|
|
22
25
|
oas: Oas
|
|
23
26
|
pluginManager: PluginManager
|
|
24
27
|
/**
|
|
@@ -1116,6 +1119,27 @@ export class SchemaGenerator<
|
|
|
1116
1119
|
const options = this.#getOptions({ name })
|
|
1117
1120
|
const tree = this.parse({ name, schemaObject })
|
|
1118
1121
|
|
|
1122
|
+
if (generator.type === 'react') {
|
|
1123
|
+
await buildSchema(
|
|
1124
|
+
{
|
|
1125
|
+
name,
|
|
1126
|
+
value: schemaObject,
|
|
1127
|
+
tree,
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
fabric: this.context.fabric,
|
|
1131
|
+
generator,
|
|
1132
|
+
instance: this,
|
|
1133
|
+
options: {
|
|
1134
|
+
...this.options,
|
|
1135
|
+
...options,
|
|
1136
|
+
},
|
|
1137
|
+
},
|
|
1138
|
+
)
|
|
1139
|
+
|
|
1140
|
+
return []
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1119
1143
|
const result = await generator.schema?.({
|
|
1120
1144
|
instance: this,
|
|
1121
1145
|
schema: {
|
package/src/components/Oas.tsx
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { createContext } from '@kubb/react'
|
|
2
|
-
|
|
3
|
-
import { Operation } from './Operation.tsx'
|
|
4
|
-
import { Schema } from './Schema.tsx'
|
|
5
|
-
|
|
6
1
|
import type { Oas as OasType, Operation as OperationType } from '@kubb/oas'
|
|
7
|
-
import
|
|
2
|
+
import { createContext } from '@kubb/react-fabric'
|
|
3
|
+
import type { KubbNode } from '@kubb/react-fabric/types'
|
|
8
4
|
import type { OperationGenerator } from '../OperationGenerator.ts'
|
|
5
|
+
import { Operation } from './Operation.tsx'
|
|
6
|
+
import { Schema } from './Schema.tsx'
|
|
9
7
|
|
|
10
8
|
type Props = {
|
|
11
9
|
oas: OasType
|
|
@@ -28,7 +26,7 @@ type OasContextProps = {
|
|
|
28
26
|
|
|
29
27
|
const OasContext = createContext<OasContextProps>({})
|
|
30
28
|
|
|
31
|
-
export function Oas({ oas, children, operations, generator }: Props) {
|
|
29
|
+
export function Oas({ oas, children, operations, generator }: Props): KubbNode {
|
|
32
30
|
return <OasContext.Provider value={{ oas, generator, operations }}>{children}</OasContext.Provider>
|
|
33
31
|
}
|
|
34
32
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Operation as OperationType } from '@kubb/oas'
|
|
2
|
-
import { createContext } from '@kubb/react'
|
|
3
|
-
import type { KubbNode } from '@kubb/react/types'
|
|
2
|
+
import { createContext } from '@kubb/react-fabric'
|
|
3
|
+
import type { KubbNode } from '@kubb/react-fabric/types'
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
operation: OperationType
|
|
@@ -13,7 +13,7 @@ type OperationContextProps = {
|
|
|
13
13
|
|
|
14
14
|
const OperationContext = createContext<OperationContextProps>({})
|
|
15
15
|
|
|
16
|
-
export function Operation({ operation, children }: Props) {
|
|
16
|
+
export function Operation({ operation, children }: Props): KubbNode {
|
|
17
17
|
return <OperationContext.Provider value={{ operation }}>{children}</OperationContext.Provider>
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { createContext } from '@kubb/react'
|
|
2
|
-
|
|
3
1
|
import type { SchemaObject } from '@kubb/oas'
|
|
4
|
-
import
|
|
2
|
+
import { createContext } from '@kubb/react-fabric'
|
|
3
|
+
import type { Key, KubbNode } from '@kubb/react-fabric/types'
|
|
5
4
|
import type { Schema as SchemaType } from '../SchemaMapper.ts'
|
|
6
5
|
|
|
7
6
|
export type SchemaContextProps = {
|
|
@@ -32,7 +31,7 @@ const SchemaContext = createContext<SchemaContextProps>({
|
|
|
32
31
|
* @param schemaObject - The schema object to provide in context, if available.
|
|
33
32
|
* @param tree - An array representing the schema type hierarchy.
|
|
34
33
|
*/
|
|
35
|
-
export function Schema({ name, schemaObject, tree = [], children }: Props) {
|
|
34
|
+
export function Schema({ name, schemaObject, tree = [], children }: Props): KubbNode {
|
|
36
35
|
return <SchemaContext.Provider value={{ name, schemaObject, tree }}>{children}</SchemaContext.Provider>
|
|
37
36
|
}
|
|
38
37
|
|