@kubb/plugin-oas 4.4.1 → 4.5.1
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/{SchemaGenerator-b7XixzRv.js → SchemaGenerator-BwYbrh7a.js} +93 -36
- package/dist/SchemaGenerator-BwYbrh7a.js.map +1 -0
- package/dist/{SchemaGenerator-DWj6buY0.cjs → SchemaGenerator-C81yEgKY.cjs} +114 -37
- package/dist/SchemaGenerator-C81yEgKY.cjs.map +1 -0
- package/dist/{SchemaMapper-DoL-a6qq.cjs → SchemaMapper-BUV8vhg0.cjs} +1 -1
- package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -0
- package/dist/{SchemaMapper-CtfTw3hq.d.ts → SchemaMapper-CgGWx6jF.d.cts} +14 -2
- package/dist/{SchemaMapper-CX7sIIuZ.d.cts → SchemaMapper-Cj3vjPGs.d.ts} +14 -2
- package/dist/{SchemaMapper-Cx4X1al6.js → SchemaMapper-D30tqRoX.js} +1 -1
- package/dist/SchemaMapper-D30tqRoX.js.map +1 -0
- package/dist/{OperationGenerator-CRZpkIpZ.d.ts → createGenerator-BvCDyuKS.d.ts} +112 -176
- package/dist/{OperationGenerator-S_1PevQN.d.cts → createGenerator-CPNglV1d.d.cts} +113 -177
- package/dist/{generators-C61FxVIj.js → generators-CJDEf8Kn.js} +6 -6
- package/dist/{generators-C61FxVIj.js.map → generators-CJDEf8Kn.js.map} +1 -1
- package/dist/{generators-B27La9Vd.cjs → generators-udGOxdUV.cjs} +6 -6
- package/dist/{generators-B27La9Vd.cjs.map → generators-udGOxdUV.cjs.map} +1 -1
- package/dist/generators.cjs +2 -7
- package/dist/generators.d.cts +8 -3
- package/dist/generators.d.ts +8 -3
- package/dist/generators.js +3 -5
- package/dist/{getFooter-D5MdeUVv.js → getFooter-CV73pVXj.js} +2 -2
- package/dist/{getFooter-D5MdeUVv.js.map → getFooter-CV73pVXj.js.map} +1 -1
- package/dist/{getFooter-CwjCW4h5.cjs → getFooter-DPh4lxBH.cjs} +3 -3
- package/dist/{getFooter-CwjCW4h5.cjs.map → getFooter-DPh4lxBH.cjs.map} +1 -1
- package/dist/getSchemas-32BHoMO-.js +100 -0
- package/dist/getSchemas-32BHoMO-.js.map +1 -0
- package/dist/getSchemas-Cl0TZ4XY.cjs +113 -0
- package/dist/getSchemas-Cl0TZ4XY.cjs.map +1 -0
- package/dist/hooks.cjs +4 -29
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +4 -18
- package/dist/hooks.d.ts +4 -18
- package/dist/hooks.js +6 -29
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -3
- package/dist/index.d.ts +58 -3
- package/dist/index.js +32 -24
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{parseFromConfig-CqiiLCPe.js → parseFromConfig-BkUoWC2U.js} +1 -1
- package/dist/parseFromConfig-BkUoWC2U.js.map +1 -0
- package/dist/{parseFromConfig-RR31a98-.cjs → parseFromConfig-EjsCZ0-8.cjs} +1 -1
- package/dist/parseFromConfig-EjsCZ0-8.cjs.map +1 -0
- package/dist/utils.cjs +3 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +28 -24
- package/dist/utils.d.ts +28 -24
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +5 -12
- package/src/OperationGenerator.ts +26 -13
- package/src/SchemaGenerator.ts +24 -46
- package/src/SchemaMapper.ts +2 -0
- package/src/generators/index.ts +0 -1
- package/src/generators/jsonGenerator.ts +4 -4
- package/src/generators/types.ts +13 -14
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useOperationManager.ts +2 -4
- package/src/index.ts +1 -1
- package/src/utils/getBanner.ts +1 -1
- package/src/utils/getParams.ts +1 -2
- package/src/utils/getSchemaFactory.ts +1 -2
- package/src/utils/getSchemas.ts +89 -15
- package/src/utils/index.ts +3 -4
- package/src/utils/parseFromConfig.ts +2 -6
- package/src/utils.tsx +101 -0
- package/dist/Oas-CHC1IC5D.js +0 -56
- package/dist/Oas-CHC1IC5D.js.map +0 -1
- package/dist/Oas-CQrRP_NH.cjs +0 -76
- package/dist/Oas-CQrRP_NH.cjs.map +0 -1
- package/dist/Schema-CZsDEhET.d.cts +0 -38
- package/dist/Schema-DBvtiLS7.d.ts +0 -38
- package/dist/SchemaGenerator-DWj6buY0.cjs.map +0 -1
- package/dist/SchemaGenerator-b7XixzRv.js.map +0 -1
- package/dist/SchemaMapper-Cx4X1al6.js.map +0 -1
- package/dist/SchemaMapper-DoL-a6qq.cjs.map +0 -1
- package/dist/components.cjs +0 -5
- package/dist/components.d.cts +0 -38
- package/dist/components.d.ts +0 -38
- package/dist/components.js +0 -3
- package/dist/getSchemas-Bdg6n9Qk.js +0 -55
- package/dist/getSchemas-Bdg6n9Qk.js.map +0 -1
- package/dist/getSchemas-DY8s2CSl.cjs +0 -68
- package/dist/getSchemas-DY8s2CSl.cjs.map +0 -1
- package/dist/parseFromConfig-CqiiLCPe.js.map +0 -1
- package/dist/parseFromConfig-RR31a98-.cjs.map +0 -1
- package/dist/utils-DYf-j63H.cjs +0 -115
- package/dist/utils-DYf-j63H.cjs.map +0 -1
- package/dist/utils-DaV25sy8.js +0 -95
- package/dist/utils-DaV25sy8.js.map +0 -1
- package/src/components/Oas.tsx +0 -30
- package/src/components/Operation.tsx +0 -20
- package/src/components/Schema.tsx +0 -38
- package/src/components/index.ts +0 -3
- package/src/generators/utils.tsx +0 -114
- package/src/hooks/useOperation.ts +0 -18
- package/src/hooks/useSchema.ts +0 -16
package/dist/utils-DaV25sy8.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { t as Oas } from "./Oas-CHC1IC5D.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
|
-
oas
|
|
16
|
-
},
|
|
17
|
-
children: /* @__PURE__ */ jsx(Oas, {
|
|
18
|
-
generator: instance,
|
|
19
|
-
children: /* @__PURE__ */ jsx(generator.Operations, {
|
|
20
|
-
operations,
|
|
21
|
-
instance,
|
|
22
|
-
options
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const fabricChild = createReactFabric();
|
|
28
|
-
fabricChild.render(Component);
|
|
29
|
-
await fabric.context.fileManager.add(...fabricChild.files);
|
|
30
|
-
}
|
|
31
|
-
async function buildOperation(operation, { fabric, options, instance, generator }) {
|
|
32
|
-
if (!generator.Operation) return;
|
|
33
|
-
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
34
|
-
function Component() {
|
|
35
|
-
return /* @__PURE__ */ jsx(App, {
|
|
36
|
-
meta: {
|
|
37
|
-
pluginManager,
|
|
38
|
-
plugin: {
|
|
39
|
-
...plugin,
|
|
40
|
-
options
|
|
41
|
-
},
|
|
42
|
-
mode,
|
|
43
|
-
oas
|
|
44
|
-
},
|
|
45
|
-
children: /* @__PURE__ */ jsx(Oas, {
|
|
46
|
-
generator: instance,
|
|
47
|
-
children: /* @__PURE__ */ jsx(Oas.Operation, {
|
|
48
|
-
operation,
|
|
49
|
-
children: /* @__PURE__ */ jsx(generator.Operation, {
|
|
50
|
-
operation,
|
|
51
|
-
options,
|
|
52
|
-
instance
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const fabricChild = createReactFabric();
|
|
59
|
-
fabricChild.render(Component);
|
|
60
|
-
await fabric.context.fileManager.add(...fabricChild.files);
|
|
61
|
-
}
|
|
62
|
-
async function buildSchema(schema, { fabric, options, instance, generator }) {
|
|
63
|
-
if (!generator.Schema) return;
|
|
64
|
-
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
65
|
-
function Component() {
|
|
66
|
-
return /* @__PURE__ */ jsx(App, {
|
|
67
|
-
meta: {
|
|
68
|
-
pluginManager,
|
|
69
|
-
plugin: {
|
|
70
|
-
...plugin,
|
|
71
|
-
options
|
|
72
|
-
},
|
|
73
|
-
mode,
|
|
74
|
-
oas
|
|
75
|
-
},
|
|
76
|
-
children: /* @__PURE__ */ jsx(Oas, { children: /* @__PURE__ */ jsx(Oas.Schema, {
|
|
77
|
-
name: schema.name,
|
|
78
|
-
schemaObject: schema.value,
|
|
79
|
-
tree: schema.tree,
|
|
80
|
-
children: /* @__PURE__ */ jsx(generator.Schema, {
|
|
81
|
-
schema,
|
|
82
|
-
options,
|
|
83
|
-
instance
|
|
84
|
-
})
|
|
85
|
-
}) })
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
const fabricChild = createReactFabric();
|
|
89
|
-
fabricChild.render(Component);
|
|
90
|
-
await fabric.context.fileManager.add(...fabricChild.files);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
export { buildOperations as n, buildSchema as r, buildOperation as t };
|
|
95
|
-
//# sourceMappingURL=utils-DaV25sy8.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-DaV25sy8.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, oas }}>\n <Oas 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, oas }}>\n <Oas 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, oas }}>\n <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;IAAK;aAC7C,oBAAC;IAAI,WAAW;cACd,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;IAAK;aACrE,oBAAC;IAAI,WAAW;cACd,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;IAAK;aACrE,oBAAC,iBACC,oBAAC,IAAI;IAAO,MAAM,OAAO;IAAM,cAAc,OAAO;IAAO,MAAM,OAAO;cACtE,oBAAC,UAAU;KAAe;KAAiB;KAAmB;MAAY;KAC/D,GACT;IACF;;CAGV,MAAM,cAAc,mBAAmB;AACvC,aAAY,OAAO,UAAU;AAE7B,OAAM,OAAO,QAAQ,YAAY,IAAI,GAAG,YAAY,MAAM"}
|
package/src/components/Oas.tsx
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createContext } from '@kubb/react-fabric'
|
|
2
|
-
import type { KubbNode } from '@kubb/react-fabric/types'
|
|
3
|
-
import type { OperationGenerator } from '../OperationGenerator.ts'
|
|
4
|
-
import { Operation } from './Operation.tsx'
|
|
5
|
-
import { Schema } from './Schema.tsx'
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated
|
|
10
|
-
*/
|
|
11
|
-
generator?: Omit<OperationGenerator, 'build'>
|
|
12
|
-
children?: KubbNode
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type OasContextProps = {
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated
|
|
18
|
-
*/
|
|
19
|
-
generator?: Omit<OperationGenerator, 'build'>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const OasContext = createContext<OasContextProps>({})
|
|
23
|
-
|
|
24
|
-
export function Oas({ children, generator }: Props): KubbNode {
|
|
25
|
-
return <OasContext.Provider value={{ generator }}>{children}</OasContext.Provider>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Oas.Context = OasContext
|
|
29
|
-
Oas.Operation = Operation
|
|
30
|
-
Oas.Schema = Schema
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Operation as OperationType } from '@kubb/oas'
|
|
2
|
-
import { createContext } from '@kubb/react-fabric'
|
|
3
|
-
import type { KubbNode } from '@kubb/react-fabric/types'
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
operation: OperationType
|
|
7
|
-
children?: KubbNode
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type OperationContextProps = {
|
|
11
|
-
operation?: OperationType
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const OperationContext = createContext<OperationContextProps>({})
|
|
15
|
-
|
|
16
|
-
export function Operation({ operation, children }: Props): KubbNode {
|
|
17
|
-
return <OperationContext.Provider value={{ operation }}>{children}</OperationContext.Provider>
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
Operation.Context = OperationContext
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { SchemaObject } from '@kubb/oas'
|
|
2
|
-
import { createContext } from '@kubb/react-fabric'
|
|
3
|
-
import type { Key, KubbNode } from '@kubb/react-fabric/types'
|
|
4
|
-
import type { Schema as SchemaType } from '../SchemaMapper.ts'
|
|
5
|
-
|
|
6
|
-
export type SchemaContextProps = {
|
|
7
|
-
name: string
|
|
8
|
-
schemaObject?: SchemaObject
|
|
9
|
-
tree: Array<SchemaType>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type Props = {
|
|
13
|
-
key?: Key
|
|
14
|
-
name: string
|
|
15
|
-
schemaObject?: SchemaObject
|
|
16
|
-
tree?: Array<SchemaType>
|
|
17
|
-
children?: KubbNode
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const SchemaContext = createContext<SchemaContextProps>({
|
|
21
|
-
name: 'unknown',
|
|
22
|
-
tree: [],
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Provides schema-related context to descendant components.
|
|
27
|
-
*
|
|
28
|
-
* Wraps its children with a context containing the schema name, optional schema object, and an optional schema type tree.
|
|
29
|
-
*
|
|
30
|
-
* @param name - The name of the schema.
|
|
31
|
-
* @param schemaObject - The schema object to provide in context, if available.
|
|
32
|
-
* @param tree - An array representing the schema type hierarchy.
|
|
33
|
-
*/
|
|
34
|
-
export function Schema({ name, schemaObject, tree = [], children }: Props): KubbNode {
|
|
35
|
-
return <SchemaContext.Provider value={{ name, schemaObject, tree }}>{children}</SchemaContext.Provider>
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
Schema.Context = SchemaContext
|
package/src/components/index.ts
DELETED
package/src/generators/utils.tsx
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import type { PluginFactoryOptions } from '@kubb/core'
|
|
2
|
-
import type { Operation, SchemaObject } from '@kubb/oas'
|
|
3
|
-
import { App, createReactFabric, type Fabric } from '@kubb/react-fabric'
|
|
4
|
-
import { Oas } from '../components/Oas.tsx'
|
|
5
|
-
import type { OperationGenerator } from '../OperationGenerator.ts'
|
|
6
|
-
import type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'
|
|
7
|
-
import type { Schema } from '../SchemaMapper.ts'
|
|
8
|
-
import type { ReactGenerator } from './/createReactGenerator.ts'
|
|
9
|
-
|
|
10
|
-
type BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {
|
|
11
|
-
fabric: Fabric
|
|
12
|
-
generator: ReactGenerator<any>
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated
|
|
15
|
-
*/
|
|
16
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>
|
|
17
|
-
options: TOptions['resolvedOptions']
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function buildOperations<TOptions extends PluginFactoryOptions>(
|
|
21
|
-
operations: Array<Operation>,
|
|
22
|
-
{ fabric, options, instance, generator }: BuildOperationsOptions<TOptions>,
|
|
23
|
-
): Promise<void> {
|
|
24
|
-
if (!generator.Operations) {
|
|
25
|
-
return undefined
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const { pluginManager, oas, plugin, mode } = instance.context
|
|
29
|
-
|
|
30
|
-
function Component() {
|
|
31
|
-
return (
|
|
32
|
-
<App meta={{ pluginManager, plugin, mode, oas }}>
|
|
33
|
-
<Oas generator={instance}>
|
|
34
|
-
<generator.Operations operations={operations} instance={instance} options={options} />
|
|
35
|
-
</Oas>
|
|
36
|
-
</App>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const fabricChild = createReactFabric()
|
|
41
|
-
fabricChild.render(Component)
|
|
42
|
-
|
|
43
|
-
await fabric.context.fileManager.add(...fabricChild.files)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>
|
|
47
|
-
|
|
48
|
-
export async function buildOperation<TOptions extends PluginFactoryOptions>(
|
|
49
|
-
operation: Operation,
|
|
50
|
-
{ fabric, options, instance, generator }: BuildOperationOptions<TOptions>,
|
|
51
|
-
): Promise<void> {
|
|
52
|
-
if (!generator.Operation) {
|
|
53
|
-
return undefined
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const { pluginManager, oas, plugin, mode } = instance.context
|
|
57
|
-
|
|
58
|
-
function Component() {
|
|
59
|
-
return (
|
|
60
|
-
<App meta={{ pluginManager, plugin: { ...plugin, options }, mode, oas }}>
|
|
61
|
-
<Oas generator={instance}>
|
|
62
|
-
<Oas.Operation operation={operation}>
|
|
63
|
-
<generator.Operation operation={operation} options={options} instance={instance} />
|
|
64
|
-
</Oas.Operation>
|
|
65
|
-
</Oas>
|
|
66
|
-
</App>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
const fabricChild = createReactFabric()
|
|
70
|
-
fabricChild.render(Component)
|
|
71
|
-
|
|
72
|
-
await fabric.context.fileManager.add(...fabricChild.files)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
type BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {
|
|
76
|
-
fabric: Fabric
|
|
77
|
-
generator: ReactGenerator<any>
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated
|
|
80
|
-
*/
|
|
81
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>
|
|
82
|
-
options: TOptions['resolvedOptions']
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export async function buildSchema<TOptions extends PluginFactoryOptions>(
|
|
86
|
-
schema: {
|
|
87
|
-
name: string
|
|
88
|
-
tree: Array<Schema>
|
|
89
|
-
value: SchemaObject
|
|
90
|
-
},
|
|
91
|
-
{ fabric, options, instance, generator }: BuildSchemaOptions<TOptions>,
|
|
92
|
-
): Promise<void> {
|
|
93
|
-
if (!generator.Schema) {
|
|
94
|
-
return undefined
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const { pluginManager, oas, plugin, mode } = instance.context
|
|
98
|
-
|
|
99
|
-
function Component() {
|
|
100
|
-
return (
|
|
101
|
-
<App meta={{ pluginManager, plugin: { ...plugin, options }, mode, oas }}>
|
|
102
|
-
<Oas>
|
|
103
|
-
<Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>
|
|
104
|
-
<generator.Schema schema={schema} options={options} instance={instance} />
|
|
105
|
-
</Oas.Schema>
|
|
106
|
-
</Oas>
|
|
107
|
-
</App>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
const fabricChild = createReactFabric()
|
|
111
|
-
fabricChild.render(Component)
|
|
112
|
-
|
|
113
|
-
await fabric.context.fileManager.add(...fabricChild.files)
|
|
114
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useContext } from '@kubb/react-fabric'
|
|
2
|
-
|
|
3
|
-
import { Operation } from '../components/Operation.tsx'
|
|
4
|
-
|
|
5
|
-
import type { Operation as OperationType } from '@kubb/oas'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* `useOperation` will return the current `Operation`
|
|
9
|
-
*/
|
|
10
|
-
export function useOperation(): OperationType {
|
|
11
|
-
const { operation } = useContext(Operation.Context)
|
|
12
|
-
|
|
13
|
-
if (!operation) {
|
|
14
|
-
throw new Error('Operation is not defined')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return operation
|
|
18
|
-
}
|
package/src/hooks/useSchema.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useContext } from '@kubb/react-fabric'
|
|
2
|
-
|
|
3
|
-
import { Schema } from '../components/Schema.tsx'
|
|
4
|
-
|
|
5
|
-
import type { SchemaContextProps } from '../components/Schema.tsx'
|
|
6
|
-
|
|
7
|
-
type UseSchemaResult = SchemaContextProps
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* `useSchema` will return the current `schema properties`
|
|
11
|
-
*/
|
|
12
|
-
export function useSchema(): UseSchemaResult {
|
|
13
|
-
const props = useContext(Schema.Context)
|
|
14
|
-
|
|
15
|
-
return props as UseSchemaResult
|
|
16
|
-
}
|