@kubb/plugin-oas 3.16.1 → 3.16.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/Oas-CuqAnIw-.js +60 -0
- package/dist/Oas-CuqAnIw-.js.map +1 -0
- package/dist/Oas-Cv_pyXRM.cjs +78 -0
- package/dist/Oas-Cv_pyXRM.cjs.map +1 -0
- package/dist/OperationGenerator-CgbXErhW.d.cts +900 -0
- package/dist/OperationGenerator-OtLcGk2y.d.ts +900 -0
- package/dist/Schema-DJshqHto.d.cts +38 -0
- package/dist/Schema-DOXGUW1m.d.ts +38 -0
- package/dist/SchemaGenerator-8205BXCp.cjs +942 -0
- package/dist/SchemaGenerator-8205BXCp.cjs.map +1 -0
- package/dist/SchemaGenerator-B8Io6kky.js +930 -0
- package/dist/SchemaGenerator-B8Io6kky.js.map +1 -0
- package/dist/SchemaMapper-BaZQKrQB.js +54 -0
- package/dist/SchemaMapper-BaZQKrQB.js.map +1 -0
- package/dist/SchemaMapper-BiagBQN4.d.cts +388 -0
- package/dist/SchemaMapper-C2J2d3o4.d.ts +388 -0
- package/dist/SchemaMapper-D8J0V9Pj.cjs +66 -0
- package/dist/SchemaMapper-D8J0V9Pj.cjs.map +1 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/components.cjs +4 -19
- package/dist/components.d.cts +42 -35
- package/dist/components.d.ts +42 -35
- package/dist/components.js +3 -3
- package/dist/generators-BhLMlRNk.js +137 -0
- package/dist/generators-BhLMlRNk.js.map +1 -0
- package/dist/generators-DLH2kvlh.cjs +155 -0
- package/dist/generators-DLH2kvlh.cjs.map +1 -0
- package/dist/generators.cjs +4 -13
- package/dist/generators.d.cts +5 -7
- package/dist/generators.d.ts +5 -7
- package/dist/generators.js +5 -5
- package/dist/getFooter-BChY2kC1.cjs +43 -0
- package/dist/getFooter-BChY2kC1.cjs.map +1 -0
- package/dist/getFooter-T7_pZ6f8.js +31 -0
- package/dist/getFooter-T7_pZ6f8.js.map +1 -0
- package/dist/getSchemas-D8mP129c.cjs +67 -0
- package/dist/getSchemas-D8mP129c.cjs.map +1 -0
- package/dist/getSchemas-WoSBIxG8.js +55 -0
- package/dist/getSchemas-WoSBIxG8.js.map +1 -0
- package/dist/hooks.cjs +213 -195
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +91 -86
- package/dist/hooks.d.ts +91 -86
- package/dist/hooks.js +212 -193
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +280 -344
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -10
- package/dist/index.d.ts +7 -10
- package/dist/index.js +274 -318
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +802 -737
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +12 -11
- package/dist/mocks.d.ts +12 -11
- package/dist/mocks.js +802 -735
- package/dist/mocks.js.map +1 -1
- package/dist/parseFromConfig-CMNGsef2.cjs +33 -0
- package/dist/parseFromConfig-CMNGsef2.cjs.map +1 -0
- package/dist/parseFromConfig-yAiFK03V.js +27 -0
- package/dist/parseFromConfig-yAiFK03V.js.map +1 -0
- package/dist/utils.cjs +58 -74
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +96 -42
- package/dist/utils.d.ts +96 -42
- package/dist/utils.js +47 -46
- package/dist/utils.js.map +1 -1
- package/package.json +28 -36
- package/src/SchemaGenerator.ts +6 -1
- package/src/components/Operation.tsx +1 -2
- package/src/mocks/schemas.ts +39 -0
- package/src/utils/getBanner.ts +5 -5
- package/src/utils/getFooter.ts +4 -4
- package/dist/OperationGenerator-C7NPZtOM.d.ts +0 -288
- package/dist/OperationGenerator-DJE2XQ83.d.cts +0 -288
- package/dist/Schema-AjebpeVY.d.ts +0 -32
- package/dist/Schema-M6983FL1.d.cts +0 -32
- package/dist/SchemaMapper-B21ZmWag.d.cts +0 -275
- package/dist/SchemaMapper-B21ZmWag.d.ts +0 -275
- package/dist/chunk-6S7YFY6F.js +0 -33
- package/dist/chunk-6S7YFY6F.js.map +0 -1
- package/dist/chunk-76E35IZ2.js +0 -56
- package/dist/chunk-76E35IZ2.js.map +0 -1
- package/dist/chunk-7RFNM43R.cjs +0 -41
- package/dist/chunk-7RFNM43R.cjs.map +0 -1
- package/dist/chunk-DTD4ZUDA.cjs +0 -36
- package/dist/chunk-DTD4ZUDA.cjs.map +0 -1
- package/dist/chunk-G3FDK7YW.js +0 -35
- package/dist/chunk-G3FDK7YW.js.map +0 -1
- package/dist/chunk-JNN4JPWK.js +0 -28
- package/dist/chunk-JNN4JPWK.js.map +0 -1
- package/dist/chunk-MBX66JAT.js +0 -93
- package/dist/chunk-MBX66JAT.js.map +0 -1
- package/dist/chunk-NFLZLRQS.cjs +0 -869
- package/dist/chunk-NFLZLRQS.cjs.map +0 -1
- package/dist/chunk-P2VXWGXZ.js +0 -862
- package/dist/chunk-P2VXWGXZ.js.map +0 -1
- package/dist/chunk-PORSNYI5.js +0 -47
- package/dist/chunk-PORSNYI5.js.map +0 -1
- package/dist/chunk-QJMOOF2A.cjs +0 -97
- package/dist/chunk-QJMOOF2A.cjs.map +0 -1
- package/dist/chunk-YWMMI3MO.cjs +0 -59
- package/dist/chunk-YWMMI3MO.cjs.map +0 -1
- package/dist/chunk-Z2NREI4X.cjs +0 -32
- package/dist/chunk-Z2NREI4X.cjs.map +0 -1
- package/dist/chunk-ZVFL3NXX.cjs +0 -50
- package/dist/chunk-ZVFL3NXX.cjs.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
package/dist/components.d.ts
CHANGED
|
@@ -1,46 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { b as OperationGenerator } from './OperationGenerator-C7NPZtOM.js';
|
|
6
|
-
import './SchemaMapper-B21ZmWag.js';
|
|
7
|
-
import '@kubb/core/fs';
|
|
8
|
-
import '@kubb/core';
|
|
1
|
+
import { KubbNode, Oas, Operation, OperationGenerator } from "./OperationGenerator-OtLcGk2y.js";
|
|
2
|
+
import "./SchemaMapper-C2J2d3o4.js";
|
|
3
|
+
import { Schema } from "./Schema-DOXGUW1m.js";
|
|
4
|
+
import * as react1 from "react";
|
|
9
5
|
|
|
6
|
+
//#region src/components/Operation.d.ts
|
|
10
7
|
type Props$1 = {
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
operation: Operation;
|
|
9
|
+
children?: KubbNode;
|
|
13
10
|
};
|
|
14
11
|
type OperationContextProps = {
|
|
15
|
-
|
|
12
|
+
operation?: Operation;
|
|
16
13
|
};
|
|
17
|
-
declare function Operation({
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
declare function Operation$1({
|
|
15
|
+
operation,
|
|
16
|
+
children
|
|
17
|
+
}: Props$1): any;
|
|
18
|
+
declare namespace Operation$1 {
|
|
19
|
+
var Context: react1.Context<OperationContextProps>;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/components/Oas.d.ts
|
|
22
23
|
type Props = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
oas: Oas;
|
|
25
|
+
operations?: Operation[];
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated
|
|
28
|
+
*/
|
|
29
|
+
generator?: Omit<OperationGenerator, 'build'>;
|
|
30
|
+
children?: KubbNode;
|
|
30
31
|
};
|
|
31
32
|
type OasContextProps = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
oas?: Oas;
|
|
34
|
+
operations?: Operation[];
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated
|
|
37
|
+
*/
|
|
38
|
+
generator?: Omit<OperationGenerator, 'build'>;
|
|
38
39
|
};
|
|
39
|
-
declare function Oas({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
declare function Oas$1({
|
|
41
|
+
oas,
|
|
42
|
+
children,
|
|
43
|
+
operations,
|
|
44
|
+
generator
|
|
45
|
+
}: Props): any;
|
|
46
|
+
declare namespace Oas$1 {
|
|
47
|
+
var Context: react1.Context<OasContextProps>;
|
|
48
|
+
var Operation: typeof Operation$1;
|
|
49
|
+
var Schema: typeof Schema;
|
|
44
50
|
}
|
|
45
|
-
|
|
46
|
-
export { Oas, Operation, Schema };
|
|
51
|
+
//#endregion
|
|
52
|
+
export { Oas$1 as Oas, Operation$1 as Operation, Schema };
|
|
53
|
+
//# sourceMappingURL=components.d.ts.map
|
package/dist/components.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Oas, Operation, Schema } from "./Oas-CuqAnIw-.js";
|
|
2
|
+
|
|
3
|
+
export { Oas, Operation, Schema };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Oas } from "./Oas-CuqAnIw-.js";
|
|
2
|
+
import { getBanner, getFooter } from "./getFooter-T7_pZ6f8.js";
|
|
3
|
+
import { camelCase } from "@kubb/core/transformers";
|
|
4
|
+
import { App, createRoot } from "@kubb/react";
|
|
5
|
+
import { jsx } from "@kubb/react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/generator.tsx
|
|
8
|
+
function createGenerator(parseOptions) {
|
|
9
|
+
return parseOptions;
|
|
10
|
+
}
|
|
11
|
+
/****
|
|
12
|
+
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
13
|
+
*
|
|
14
|
+
* The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
|
|
15
|
+
*
|
|
16
|
+
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
17
|
+
*/
|
|
18
|
+
function createReactGenerator(parseOptions) {
|
|
19
|
+
return {
|
|
20
|
+
...parseOptions,
|
|
21
|
+
async operations({ instance, options, operations }) {
|
|
22
|
+
if (!parseOptions.Operations) return [];
|
|
23
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
24
|
+
const root = createRoot({ logger: pluginManager.logger });
|
|
25
|
+
const Component = parseOptions.Operations.bind(this);
|
|
26
|
+
root.render(/* @__PURE__ */ jsx(App, {
|
|
27
|
+
pluginManager,
|
|
28
|
+
plugin,
|
|
29
|
+
mode,
|
|
30
|
+
children: /* @__PURE__ */ jsx(Oas, {
|
|
31
|
+
oas,
|
|
32
|
+
operations,
|
|
33
|
+
generator: instance,
|
|
34
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
35
|
+
operations,
|
|
36
|
+
instance,
|
|
37
|
+
options
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
}));
|
|
41
|
+
return root.files;
|
|
42
|
+
},
|
|
43
|
+
async operation({ instance, operation, options }) {
|
|
44
|
+
if (!parseOptions.Operation) return [];
|
|
45
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
46
|
+
const root = createRoot({ logger: pluginManager.logger });
|
|
47
|
+
const Component = parseOptions.Operation.bind(this);
|
|
48
|
+
root.render(/* @__PURE__ */ jsx(App, {
|
|
49
|
+
pluginManager,
|
|
50
|
+
plugin: {
|
|
51
|
+
...plugin,
|
|
52
|
+
options
|
|
53
|
+
},
|
|
54
|
+
mode,
|
|
55
|
+
children: /* @__PURE__ */ jsx(Oas, {
|
|
56
|
+
oas,
|
|
57
|
+
operations: [operation],
|
|
58
|
+
generator: instance,
|
|
59
|
+
children: /* @__PURE__ */ jsx(Oas.Operation, {
|
|
60
|
+
operation,
|
|
61
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
62
|
+
operation,
|
|
63
|
+
options,
|
|
64
|
+
instance
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}));
|
|
69
|
+
return root.files;
|
|
70
|
+
},
|
|
71
|
+
async schema({ instance, schema, options }) {
|
|
72
|
+
if (!parseOptions.Schema) return [];
|
|
73
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
74
|
+
const Component = parseOptions.Schema.bind(this);
|
|
75
|
+
const root = createRoot({ logger: pluginManager.logger });
|
|
76
|
+
root.render(/* @__PURE__ */ jsx(App, {
|
|
77
|
+
pluginManager,
|
|
78
|
+
plugin: {
|
|
79
|
+
...plugin,
|
|
80
|
+
options
|
|
81
|
+
},
|
|
82
|
+
mode,
|
|
83
|
+
children: /* @__PURE__ */ jsx(Oas, {
|
|
84
|
+
oas,
|
|
85
|
+
children: /* @__PURE__ */ jsx(Oas.Schema, {
|
|
86
|
+
name: schema.name,
|
|
87
|
+
schemaObject: schema.value,
|
|
88
|
+
tree: schema.tree,
|
|
89
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
90
|
+
schema,
|
|
91
|
+
options,
|
|
92
|
+
instance
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
}));
|
|
97
|
+
return root.files;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/generators/jsonGenerator.ts
|
|
104
|
+
const jsonGenerator = createGenerator({
|
|
105
|
+
name: "plugin-oas",
|
|
106
|
+
async schema({ schema, instance }) {
|
|
107
|
+
const { pluginManager, plugin } = instance.context;
|
|
108
|
+
const file = pluginManager.getFile({
|
|
109
|
+
name: camelCase(schema.name),
|
|
110
|
+
extname: ".json",
|
|
111
|
+
mode: "split",
|
|
112
|
+
pluginKey: plugin.key
|
|
113
|
+
});
|
|
114
|
+
return [{
|
|
115
|
+
...file,
|
|
116
|
+
sources: [{
|
|
117
|
+
name: camelCase(schema.name),
|
|
118
|
+
isExportable: false,
|
|
119
|
+
isIndexable: false,
|
|
120
|
+
value: JSON.stringify(schema.value)
|
|
121
|
+
}],
|
|
122
|
+
banner: getBanner({
|
|
123
|
+
oas: instance.context.oas,
|
|
124
|
+
output: plugin.options.output,
|
|
125
|
+
config: pluginManager.config
|
|
126
|
+
}),
|
|
127
|
+
format: getFooter({
|
|
128
|
+
oas: instance.context.oas,
|
|
129
|
+
output: plugin.options.output
|
|
130
|
+
})
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
export { createGenerator, createReactGenerator, jsonGenerator };
|
|
137
|
+
//# sourceMappingURL=generators-BhLMlRNk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-BhLMlRNk.js","names":["parseOptions: GeneratorOptions<TOptions>","parseOptions: ReactGeneratorOptions<TOptions>"],"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\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'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component operations={operations} instance={instance} options={options} />\n </Oas>\n </App>,\n )\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n const Component = parseOptions.Operation.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Component operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n return root.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n const Component = parseOptions.Schema.bind(this)\n const root = createRoot({\n logger: pluginManager.logger,\n })\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n return root.files\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;;AAyCA,SAAgB,gBAAuDA,cAA+D;AACpI,QAAO;AACR;;;;;;;;AAgBD,SAAgB,qBAA4DC,cAAoE;AAC9I,QAAO;EACL,GAAG;EACH,MAAM,WAAW,EAAE,UAAU,SAAS,YAAY,EAAE;AAClD,OAAI,CAAC,aAAa,WAChB,QAAO,CAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,MAAM,GAAG,SAAS;GACtD,MAAM,OAAO,WAAW,EACtB,QAAQ,cAAc,OACvB,EAAC;GACF,MAAM,YAAY,aAAa,WAAW,KAAK,KAAK;GAEpD,KAAK,2BACF;IAAmB;IAAuB;IAAc;kCACtD;KAAS;KAAiB;KAAY,WAAW;mCAC/C;MAAsB;MAAsB;MAAmB;OAAW;MACvE;KACF,CACP;AACD,UAAO,KAAK;EACb;EACD,MAAM,UAAU,EAAE,UAAU,WAAW,SAAS,EAAE;AAChD,OAAI,CAAC,aAAa,UAChB,QAAO,CAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,MAAM,GAAG,SAAS;GACtD,MAAM,OAAO,WAAW,EACtB,QAAQ,cAAc,OACvB,EAAC;GACF,MAAM,YAAY,aAAa,UAAU,KAAK,KAAK;GAEnD,KAAK,2BACF;IAAmB;IAAe,QAAQ;KAAE,GAAG;KAAQ;IAAS;IAAQ;kCACtE;KAAS;KAAK,YAAY,CAAC,SAAU;KAAE,WAAW;mCAChD,IAAI;MAAqB;oCACvB;OAAqB;OAAoB;OAAmB;QAAY;OAC3D;MACZ;KACF,CACP;AACD,UAAO,KAAK;EACb;EACD,MAAM,OAAO,EAAE,UAAU,QAAQ,SAAS,EAAE;AAC1C,OAAI,CAAC,aAAa,OAChB,QAAO,CAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,MAAM,GAAG,SAAS;GAEtD,MAAM,YAAY,aAAa,OAAO,KAAK,KAAK;GAChD,MAAM,OAAO,WAAW,EACtB,QAAQ,cAAc,OACvB,EAAC;GACF,KAAK,2BACF;IAAmB;IAAe,QAAQ;KAAE,GAAG;KAAQ;IAAS;IAAQ;kCACtE;KAAS;mCACP,IAAI;MAAO,MAAM,OAAO;MAAM,cAAc,OAAO;MAAO,MAAM,OAAO;oCACrE;OAAkB;OAAiB;OAAmB;QAAY;OACxD;MACT;KACF,CACP;AACD,UAAO,KAAK;EACb;CACF;AACF;;;;ACzHD,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,UAAU,EAAE;EACjC,MAAM,EAAE,eAAe,QAAQ,GAAG,SAAS;EAC3C,MAAM,OAAO,cAAc,QAAQ;GACjC,MAAM,UAAU,OAAO,KAAK;GAC5B,SAAS;GACT,MAAM;GACN,WAAW,OAAO;EACnB,EAAC;AAEF,SAAO,CACL;GACE,GAAG;GACH,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;GACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;GACvB,EAAC;GACF,QAAQ,UAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;GAAQ,EAAC;EAChF,CACF;CACF;AACF,EAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_Oas = require('./Oas-Cv_pyXRM.cjs');
|
|
3
|
+
const require_getFooter = require('./getFooter-BChY2kC1.cjs');
|
|
4
|
+
const __kubb_core_transformers = require_chunk.__toESM(require("@kubb/core/transformers"));
|
|
5
|
+
const __kubb_react = require_chunk.__toESM(require("@kubb/react"));
|
|
6
|
+
const __kubb_react_jsx_runtime = require_chunk.__toESM(require("@kubb/react/jsx-runtime"));
|
|
7
|
+
|
|
8
|
+
//#region src/generator.tsx
|
|
9
|
+
function createGenerator(parseOptions) {
|
|
10
|
+
return parseOptions;
|
|
11
|
+
}
|
|
12
|
+
/****
|
|
13
|
+
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
14
|
+
*
|
|
15
|
+
* The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
|
|
16
|
+
*
|
|
17
|
+
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
18
|
+
*/
|
|
19
|
+
function createReactGenerator(parseOptions) {
|
|
20
|
+
return {
|
|
21
|
+
...parseOptions,
|
|
22
|
+
async operations({ instance, options, operations }) {
|
|
23
|
+
if (!parseOptions.Operations) return [];
|
|
24
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
25
|
+
const root = (0, __kubb_react.createRoot)({ logger: pluginManager.logger });
|
|
26
|
+
const Component = parseOptions.Operations.bind(this);
|
|
27
|
+
root.render(/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.App, {
|
|
28
|
+
pluginManager,
|
|
29
|
+
plugin,
|
|
30
|
+
mode,
|
|
31
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_Oas.Oas, {
|
|
32
|
+
oas,
|
|
33
|
+
operations,
|
|
34
|
+
generator: instance,
|
|
35
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(Component, {
|
|
36
|
+
operations,
|
|
37
|
+
instance,
|
|
38
|
+
options
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
}));
|
|
42
|
+
return root.files;
|
|
43
|
+
},
|
|
44
|
+
async operation({ instance, operation, options }) {
|
|
45
|
+
if (!parseOptions.Operation) return [];
|
|
46
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
47
|
+
const root = (0, __kubb_react.createRoot)({ logger: pluginManager.logger });
|
|
48
|
+
const Component = parseOptions.Operation.bind(this);
|
|
49
|
+
root.render(/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.App, {
|
|
50
|
+
pluginManager,
|
|
51
|
+
plugin: {
|
|
52
|
+
...plugin,
|
|
53
|
+
options
|
|
54
|
+
},
|
|
55
|
+
mode,
|
|
56
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_Oas.Oas, {
|
|
57
|
+
oas,
|
|
58
|
+
operations: [operation],
|
|
59
|
+
generator: instance,
|
|
60
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_Oas.Oas.Operation, {
|
|
61
|
+
operation,
|
|
62
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(Component, {
|
|
63
|
+
operation,
|
|
64
|
+
options,
|
|
65
|
+
instance
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
}));
|
|
70
|
+
return root.files;
|
|
71
|
+
},
|
|
72
|
+
async schema({ instance, schema, options }) {
|
|
73
|
+
if (!parseOptions.Schema) return [];
|
|
74
|
+
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
75
|
+
const Component = parseOptions.Schema.bind(this);
|
|
76
|
+
const root = (0, __kubb_react.createRoot)({ logger: pluginManager.logger });
|
|
77
|
+
root.render(/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.App, {
|
|
78
|
+
pluginManager,
|
|
79
|
+
plugin: {
|
|
80
|
+
...plugin,
|
|
81
|
+
options
|
|
82
|
+
},
|
|
83
|
+
mode,
|
|
84
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_Oas.Oas, {
|
|
85
|
+
oas,
|
|
86
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_Oas.Oas.Schema, {
|
|
87
|
+
name: schema.name,
|
|
88
|
+
schemaObject: schema.value,
|
|
89
|
+
tree: schema.tree,
|
|
90
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(Component, {
|
|
91
|
+
schema,
|
|
92
|
+
options,
|
|
93
|
+
instance
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
}));
|
|
98
|
+
return root.files;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/generators/jsonGenerator.ts
|
|
105
|
+
const jsonGenerator = createGenerator({
|
|
106
|
+
name: "plugin-oas",
|
|
107
|
+
async schema({ schema, instance }) {
|
|
108
|
+
const { pluginManager, plugin } = instance.context;
|
|
109
|
+
const file = pluginManager.getFile({
|
|
110
|
+
name: (0, __kubb_core_transformers.camelCase)(schema.name),
|
|
111
|
+
extname: ".json",
|
|
112
|
+
mode: "split",
|
|
113
|
+
pluginKey: plugin.key
|
|
114
|
+
});
|
|
115
|
+
return [{
|
|
116
|
+
...file,
|
|
117
|
+
sources: [{
|
|
118
|
+
name: (0, __kubb_core_transformers.camelCase)(schema.name),
|
|
119
|
+
isExportable: false,
|
|
120
|
+
isIndexable: false,
|
|
121
|
+
value: JSON.stringify(schema.value)
|
|
122
|
+
}],
|
|
123
|
+
banner: require_getFooter.getBanner({
|
|
124
|
+
oas: instance.context.oas,
|
|
125
|
+
output: plugin.options.output,
|
|
126
|
+
config: pluginManager.config
|
|
127
|
+
}),
|
|
128
|
+
format: require_getFooter.getFooter({
|
|
129
|
+
oas: instance.context.oas,
|
|
130
|
+
output: plugin.options.output
|
|
131
|
+
})
|
|
132
|
+
}];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
Object.defineProperty(exports, 'createGenerator', {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () {
|
|
140
|
+
return createGenerator;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(exports, 'createReactGenerator', {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function () {
|
|
146
|
+
return createReactGenerator;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(exports, 'jsonGenerator', {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function () {
|
|
152
|
+
return jsonGenerator;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
//# sourceMappingURL=generators-DLH2kvlh.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-DLH2kvlh.cjs","names":["parseOptions: GeneratorOptions<TOptions>","parseOptions: ReactGeneratorOptions<TOptions>","App","Oas","getBanner","getFooter"],"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\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'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component operations={operations} instance={instance} options={options} />\n </Oas>\n </App>,\n )\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n const Component = parseOptions.Operation.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Component operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n return root.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n\n const Component = parseOptions.Schema.bind(this)\n const root = createRoot({\n logger: pluginManager.logger,\n })\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n return root.files\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;;;AAyCA,SAAgB,gBAAuDA,cAA+D;AACpI,QAAO;AACR;;;;;;;;AAgBD,SAAgB,qBAA4DC,cAAoE;AAC9I,QAAO;EACL,GAAG;EACH,MAAM,WAAW,EAAE,UAAU,SAAS,YAAY,EAAE;AAClD,OAAI,CAAC,aAAa,WAChB,QAAO,CAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,MAAM,GAAG,SAAS;GACtD,MAAM,oCAAkB,EACtB,QAAQ,cAAc,OACvB,EAAC;GACF,MAAM,YAAY,aAAa,WAAW,KAAK,KAAK;GAEpD,KAAK,yDACFC;IAAmB;IAAuB;IAAc;gEACtDC;KAAS;KAAiB;KAAY,WAAW;iEAC/C;MAAsB;MAAsB;MAAmB;OAAW;MACvE;KACF,CACP;AACD,UAAO,KAAK;EACb;EACD,MAAM,UAAU,EAAE,UAAU,WAAW,SAAS,EAAE;AAChD,OAAI,CAAC,aAAa,UAChB,QAAO,CAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,MAAM,GAAG,SAAS;GACtD,MAAM,oCAAkB,EACtB,QAAQ,cAAc,OACvB,EAAC;GACF,MAAM,YAAY,aAAa,UAAU,KAAK,KAAK;GAEnD,KAAK,yDACFD;IAAmB;IAAe,QAAQ;KAAE,GAAG;KAAQ;IAAS;IAAQ;gEACtEC;KAAS;KAAK,YAAY,CAAC,SAAU;KAAE,WAAW;iEAChDA,gBAAI;MAAqB;kEACvB;OAAqB;OAAoB;OAAmB;QAAY;OAC3D;MACZ;KACF,CACP;AACD,UAAO,KAAK;EACb;EACD,MAAM,OAAO,EAAE,UAAU,QAAQ,SAAS,EAAE;AAC1C,OAAI,CAAC,aAAa,OAChB,QAAO,CAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,MAAM,GAAG,SAAS;GAEtD,MAAM,YAAY,aAAa,OAAO,KAAK,KAAK;GAChD,MAAM,oCAAkB,EACtB,QAAQ,cAAc,OACvB,EAAC;GACF,KAAK,yDACFD;IAAmB;IAAe,QAAQ;KAAE,GAAG;KAAQ;IAAS;IAAQ;gEACtEC;KAAS;iEACPA,gBAAI;MAAO,MAAM,OAAO;MAAM,cAAc,OAAO;MAAO,MAAM,OAAO;kEACrE;OAAkB;OAAiB;OAAmB;QAAY;OACxD;MACT;KACF,CACP;AACD,UAAO,KAAK;EACb;CACF;AACF;;;;ACzHD,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,UAAU,EAAE;EACjC,MAAM,EAAE,eAAe,QAAQ,GAAG,SAAS;EAC3C,MAAM,OAAO,cAAc,QAAQ;GACjC,8CAAgB,OAAO,KAAK;GAC5B,SAAS;GACT,MAAM;GACN,WAAW,OAAO;EACnB,EAAC;AAEF,SAAO,CACL;GACE,GAAG;GACH,SAAS,CACP;IACE,8CAAgB,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;GACpC,CACF;GACD,QAAQC,4BAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;GACvB,EAAC;GACF,QAAQC,4BAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;GAAQ,EAAC;EAChF,CACF;CACF;AACF,EAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
require('./Oas-Cv_pyXRM.cjs');
|
|
2
|
+
const require_generators = require('./generators-DLH2kvlh.cjs');
|
|
3
|
+
require('./getFooter-BChY2kC1.cjs');
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
require('./chunk-DTD4ZUDA.cjs');
|
|
5
|
-
require('./chunk-Z2NREI4X.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "jsonGenerator", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return chunkQJMOOF2A_cjs.jsonGenerator; }
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=generators.cjs.map
|
|
14
|
-
//# sourceMappingURL=generators.cjs.map
|
|
5
|
+
exports.jsonGenerator = require_generators.jsonGenerator;
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import '@kubb/core/fs';
|
|
4
|
-
import '@kubb/oas';
|
|
5
|
-
import '@kubb/react/types';
|
|
6
|
-
import './SchemaMapper-B21ZmWag.cjs';
|
|
1
|
+
import { Generator, PluginOas } from "./OperationGenerator-CgbXErhW.cjs";
|
|
2
|
+
import "./SchemaMapper-BiagBQN4.cjs";
|
|
7
3
|
|
|
4
|
+
//#region src/generators/jsonGenerator.d.ts
|
|
8
5
|
declare const jsonGenerator: Generator<PluginOas>;
|
|
9
|
-
|
|
6
|
+
//#endregion
|
|
10
7
|
export { jsonGenerator };
|
|
8
|
+
//# sourceMappingURL=generators.d.cts.map
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import '@kubb/core/fs';
|
|
4
|
-
import '@kubb/oas';
|
|
5
|
-
import '@kubb/react/types';
|
|
6
|
-
import './SchemaMapper-B21ZmWag.js';
|
|
1
|
+
import { Generator, PluginOas } from "./OperationGenerator-OtLcGk2y.js";
|
|
2
|
+
import "./SchemaMapper-C2J2d3o4.js";
|
|
7
3
|
|
|
4
|
+
//#region src/generators/jsonGenerator.d.ts
|
|
8
5
|
declare const jsonGenerator: Generator<PluginOas>;
|
|
9
|
-
|
|
6
|
+
//#endregion
|
|
10
7
|
export { jsonGenerator };
|
|
8
|
+
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import "./Oas-CuqAnIw-.js";
|
|
2
|
+
import { jsonGenerator } from "./generators-BhLMlRNk.js";
|
|
3
|
+
import "./getFooter-T7_pZ6f8.js";
|
|
4
|
+
|
|
5
|
+
export { jsonGenerator };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const __kubb_core = require_chunk.__toESM(require("@kubb/core"));
|
|
3
|
+
const remeda = require_chunk.__toESM(require("remeda"));
|
|
4
|
+
|
|
5
|
+
//#region src/utils/getBanner.ts
|
|
6
|
+
function getBanner({ output, oas, config }) {
|
|
7
|
+
let banner = "";
|
|
8
|
+
if (config?.output?.defaultBanner !== false && config) {
|
|
9
|
+
const { title, description, version } = oas.api?.info || {};
|
|
10
|
+
banner = (0, __kubb_core.getDefaultBanner)({
|
|
11
|
+
title,
|
|
12
|
+
description,
|
|
13
|
+
version,
|
|
14
|
+
config
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (!output.banner) return banner;
|
|
18
|
+
if ((0, remeda.isFunction)(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
19
|
+
return `${output.banner}\n${banner}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/utils/getFooter.ts
|
|
24
|
+
function getFooter({ output, oas }) {
|
|
25
|
+
if (!output.footer) return void 0;
|
|
26
|
+
if ((0, remeda.isFunction)(output.footer)) return output.footer(oas);
|
|
27
|
+
return output.footer;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
Object.defineProperty(exports, 'getBanner', {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return getBanner;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, 'getFooter', {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return getFooter;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=getFooter-BChY2kC1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFooter-BChY2kC1.cjs","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import { type Config, getDefaultBanner, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;;AAUA,SAAgB,UAA4B,EAAE,QAAQ,KAAK,QAAqB,EAAU;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,SAAS,GAAG,IAAI,KAAK,QAAQ,CAAE;EAE3D,2CAA0B;GAAE;GAAO;GAAa;GAAS;EAAQ,EAAC;CACnE;AAED,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,4BAAe,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,EAAE,EAAE,QAAQ;AAG3C,QAAO,GAAG,OAAO,OAAO,EAAE,EAAE,QAAQ;AACrC;;;;AClBD,SAAgB,UAA4B,EAAE,QAAQ,KAAkB,EAAE;AACxE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,4BAAe,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO;AACf"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getDefaultBanner } from "@kubb/core";
|
|
2
|
+
import { isFunction } from "remeda";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/getBanner.ts
|
|
5
|
+
function getBanner({ output, oas, config }) {
|
|
6
|
+
let banner = "";
|
|
7
|
+
if (config?.output?.defaultBanner !== false && config) {
|
|
8
|
+
const { title, description, version } = oas.api?.info || {};
|
|
9
|
+
banner = getDefaultBanner({
|
|
10
|
+
title,
|
|
11
|
+
description,
|
|
12
|
+
version,
|
|
13
|
+
config
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (!output.banner) return banner;
|
|
17
|
+
if (isFunction(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
18
|
+
return `${output.banner}\n${banner}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/utils/getFooter.ts
|
|
23
|
+
function getFooter({ output, oas }) {
|
|
24
|
+
if (!output.footer) return void 0;
|
|
25
|
+
if (isFunction(output.footer)) return output.footer(oas);
|
|
26
|
+
return output.footer;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getBanner, getFooter };
|
|
31
|
+
//# sourceMappingURL=getFooter-T7_pZ6f8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFooter-T7_pZ6f8.js","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import { type Config, getDefaultBanner, type Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;AAUA,SAAgB,UAA4B,EAAE,QAAQ,KAAK,QAAqB,EAAU;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,SAAS,GAAG,IAAI,KAAK,QAAQ,CAAE;EAE3D,SAAS,iBAAiB;GAAE;GAAO;GAAa;GAAS;EAAQ,EAAC;CACnE;AAED,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,EAAE,EAAE,QAAQ;AAG3C,QAAO,GAAG,OAAO,OAAO,EAAE,EAAE,QAAQ;AACrC;;;;AClBD,SAAgB,UAA4B,EAAE,QAAQ,KAAkB,EAAE;AACxE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO;AACf"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const __kubb_oas = require_chunk.__toESM(require("@kubb/oas"));
|
|
3
|
+
|
|
4
|
+
//#region src/utils/getSchemaFactory.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates a factory function that generates a versioned OpenAPI schema result.
|
|
7
|
+
*
|
|
8
|
+
* The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').
|
|
9
|
+
*
|
|
10
|
+
* @returns A function that takes an optional schema and returns a versioned schema result.
|
|
11
|
+
*/
|
|
12
|
+
function getSchemaFactory(oas) {
|
|
13
|
+
return (schema) => {
|
|
14
|
+
const version = (0, __kubb_oas.isOpenApiV3_1Document)(oas.api) ? "3.1" : "3.0";
|
|
15
|
+
return {
|
|
16
|
+
schemaObject: oas.dereferenceWithRef(schema),
|
|
17
|
+
version
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/utils/getSchemas.ts
|
|
24
|
+
function getSchemas({ oas, contentType, includes = [
|
|
25
|
+
"schemas",
|
|
26
|
+
"requestBodies",
|
|
27
|
+
"responses"
|
|
28
|
+
] }) {
|
|
29
|
+
const components = oas.getDefinition().components;
|
|
30
|
+
let schemas = {};
|
|
31
|
+
if (includes.includes("schemas")) schemas = {
|
|
32
|
+
...schemas,
|
|
33
|
+
...components?.schemas || {}
|
|
34
|
+
};
|
|
35
|
+
const requestBodies = components?.requestBodies || {};
|
|
36
|
+
if (includes.includes("responses")) {
|
|
37
|
+
const responses = components?.responses || {};
|
|
38
|
+
Object.entries(responses).forEach(([name, response]) => {
|
|
39
|
+
if (response.content && !schemas[name]) {
|
|
40
|
+
const firstContentType = Object.keys(response.content)[0] || "application/json";
|
|
41
|
+
schemas[name] = response.content?.[contentType || firstContentType]?.schema;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (includes.includes("requestBodies")) Object.entries(requestBodies).forEach(([name, request]) => {
|
|
46
|
+
if (request.content && !schemas[name]) {
|
|
47
|
+
const firstContentType = Object.keys(request.content)[0] || "application/json";
|
|
48
|
+
schemas[name] = request.content?.[contentType || firstContentType]?.schema;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return schemas;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
Object.defineProperty(exports, 'getSchemaFactory', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return getSchemaFactory;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, 'getSchemas', {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return getSchemas;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=getSchemas-D8mP129c.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSchemas-D8mP129c.cjs","names":["oas: Oas","schema?: SchemaObject","schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAgB,iBAAmDA,KAA6D;AAC9H,QAAO,CAACC,WAA0B;EAChC,MAAM,gDAAgC,IAAI,IAAI,GAAG,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB,OAAO;GAC5C;EACD;CACF;AACF;;;;AC7BD,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;AAAY,GAAmB,EAAyC;CAC7J,MAAM,aAAa,IAAI,eAAe,CAAC;CAEvC,IAAIC,UAAiD,CAAE;AAEvD,KAAI,SAAS,SAAS,UAAU,EAC9B,UAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,CAAE;CACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,CAAE;AACrD,KAAI,SAAS,SAAS,YAAY,EAAE;EAClC,MAAM,YAAY,YAAY,aAAa,CAAE;EAE7C,OAAO,QAAQ,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,SAA4C,KAAK;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,QAAQ,CAAC,MAAM;IAC7D,QAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;GACtE;EACF,EAAC;CACH;AAED,KAAI,SAAS,SAAS,gBAAgB,EACpC,OAAO,QAAQ,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,QAA8C,KAAK;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,QAAQ,CAAC,MAAM;GAC5D,QAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;EACrE;CACF,EAAC;AAGJ,QAAO;AACR"}
|