@kubb/plugin-oas 3.4.5 → 3.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/{OperationGenerator-zrV0FutY.d.cts → OperationGenerator-4qu2F0-Y.d.cts} +8 -4
- package/dist/{OperationGenerator-zrV0FutY.d.ts → OperationGenerator-4qu2F0-Y.d.ts} +8 -4
- package/dist/{Schema-CAK3gCXL.d.ts → Schema-BZZ5PnvL.d.ts} +1 -1
- package/dist/{Schema-CFpQnhg0.d.cts → Schema-hC9ySN2i.d.cts} +1 -1
- package/dist/chunk-6BM3CVIN.js +92 -0
- package/dist/chunk-6BM3CVIN.js.map +1 -0
- package/dist/{chunk-FSCYFGYN.cjs → chunk-W5N2APGH.cjs} +5 -4
- package/dist/chunk-W5N2APGH.cjs.map +1 -0
- package/dist/chunk-XXKSJDBY.cjs +107 -0
- package/dist/chunk-XXKSJDBY.cjs.map +1 -0
- package/dist/{chunk-WBHFV7C2.js → chunk-Y2G53DHK.js} +5 -4
- package/dist/chunk-Y2G53DHK.js.map +1 -0
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/generators.cjs +4 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +3 -1
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/index.cjs +25 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +26 -57
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +16 -4
- package/dist/utils.d.ts +16 -4
- package/dist/utils.js +1 -50
- package/dist/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/OperationGenerator.ts +1 -1
- package/src/generators/jsonGenerator.ts +3 -2
- package/src/plugin.ts +23 -1
- package/src/types.ts +8 -4
- package/src/utils/getBanner.ts +20 -0
- package/src/utils/getFooter.ts +20 -0
- package/src/utils/index.ts +2 -0
- package/dist/chunk-BZOI3PL5.js +0 -29
- package/dist/chunk-BZOI3PL5.js.map +0 -1
- package/dist/chunk-FSCYFGYN.cjs.map +0 -1
- package/dist/chunk-QXUSUL7H.cjs +0 -35
- package/dist/chunk-QXUSUL7H.cjs.map +0 -1
- package/dist/chunk-WBHFV7C2.js.map +0 -1
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "Generator swagger",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -75,19 +75,19 @@
|
|
|
75
75
|
],
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@stoplight/yaml": "^4.3.0",
|
|
78
|
-
"remeda": "^2.19.
|
|
79
|
-
"@kubb/core": "3.
|
|
80
|
-
"@kubb/fs": "3.
|
|
81
|
-
"@kubb/oas": "3.
|
|
82
|
-
"@kubb/react": "3.
|
|
78
|
+
"remeda": "^2.19.1",
|
|
79
|
+
"@kubb/core": "3.5.1",
|
|
80
|
+
"@kubb/fs": "3.5.1",
|
|
81
|
+
"@kubb/oas": "3.5.1",
|
|
82
|
+
"@kubb/react": "3.5.1"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/react": "^18.3.18",
|
|
86
86
|
"react": "^18.3.1",
|
|
87
87
|
"tsup": "^8.3.5",
|
|
88
88
|
"typescript": "^5.7.3",
|
|
89
|
-
"@kubb/config-ts": "3.
|
|
90
|
-
"@kubb/config-tsup": "3.
|
|
89
|
+
"@kubb/config-ts": "3.5.1",
|
|
90
|
+
"@kubb/config-tsup": "3.5.1"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@kubb/react": "^3.0.0"
|
|
@@ -235,7 +235,7 @@ export class OperationGenerator<
|
|
|
235
235
|
|
|
236
236
|
methods.forEach((method) => {
|
|
237
237
|
const operation = oas.operation(path, method)
|
|
238
|
-
if (operation &&
|
|
238
|
+
if (operation && method === operation.method) {
|
|
239
239
|
const isExcluded = this.#isExcluded(operation, method)
|
|
240
240
|
const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true
|
|
241
241
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { camelCase } from '@kubb/core/transformers'
|
|
2
|
+
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
2
3
|
import { createGenerator } from '../generator.tsx'
|
|
3
4
|
import type { PluginOas } from '../types.ts'
|
|
4
5
|
|
|
@@ -24,8 +25,8 @@ export const jsonGenerator = createGenerator<PluginOas>({
|
|
|
24
25
|
value: JSON.stringify(schema.value),
|
|
25
26
|
},
|
|
26
27
|
],
|
|
27
|
-
banner: plugin.options.output
|
|
28
|
-
format: plugin.options.output
|
|
28
|
+
banner: getBanner({ oas: instance.context.oas, output: plugin.options.output }),
|
|
29
|
+
format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),
|
|
29
30
|
},
|
|
30
31
|
]
|
|
31
32
|
},
|
package/src/plugin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FileManager, createPlugin } from '@kubb/core'
|
|
1
|
+
import { FileManager, type Group, createPlugin } from '@kubb/core'
|
|
2
2
|
|
|
3
3
|
import { getSchemas } from './utils/getSchemas.ts'
|
|
4
4
|
import { parseFromConfig } from './utils/parseFromConfig.ts'
|
|
@@ -6,6 +6,7 @@ import { parseFromConfig } from './utils/parseFromConfig.ts'
|
|
|
6
6
|
import path from 'node:path'
|
|
7
7
|
import type { Config } from '@kubb/core'
|
|
8
8
|
import type { Logger } from '@kubb/core/logger'
|
|
9
|
+
import { camelCase } from '@kubb/core/transformers'
|
|
9
10
|
import type { Oas } from '@kubb/oas'
|
|
10
11
|
import { OperationGenerator } from './OperationGenerator.ts'
|
|
11
12
|
import { SchemaGenerator } from './SchemaGenerator.ts'
|
|
@@ -19,6 +20,7 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
19
20
|
output = {
|
|
20
21
|
path: 'schemas',
|
|
21
22
|
},
|
|
23
|
+
group,
|
|
22
24
|
validate = true,
|
|
23
25
|
generators = [jsonGenerator],
|
|
24
26
|
serverIndex,
|
|
@@ -84,6 +86,26 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
84
86
|
return path.resolve(root, output.path)
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
90
|
+
const groupName: Group['name'] = group?.name
|
|
91
|
+
? group.name
|
|
92
|
+
: (ctx) => {
|
|
93
|
+
if (group?.type === 'path') {
|
|
94
|
+
return `${ctx.group.split('/')[1]}`
|
|
95
|
+
}
|
|
96
|
+
return `${camelCase(ctx.group)}Controller`
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return path.resolve(
|
|
100
|
+
root,
|
|
101
|
+
output.path,
|
|
102
|
+
groupName({
|
|
103
|
+
group: group.type === 'path' ? options.group.path! : options.group.tag!,
|
|
104
|
+
}),
|
|
105
|
+
baseName,
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
87
109
|
return path.resolve(root, output.path, baseName)
|
|
88
110
|
},
|
|
89
111
|
async buildStart() {
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Output, Plugin } from '@kubb/core'
|
|
1
|
+
import type { Group, Output, Plugin } from '@kubb/core'
|
|
2
2
|
import type { PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
|
|
3
3
|
import type * as KubbFile from '@kubb/fs/types'
|
|
4
4
|
|
|
@@ -32,7 +32,11 @@ export type Options = {
|
|
|
32
32
|
* Specify the export location for the files and define the behavior of the output
|
|
33
33
|
* @default { path: 'schemas', barrelType: 'named' }
|
|
34
34
|
*/
|
|
35
|
-
output?: Output
|
|
35
|
+
output?: Output<Oas>
|
|
36
|
+
/**
|
|
37
|
+
* Group the JSON files based on the provided name.
|
|
38
|
+
*/
|
|
39
|
+
group?: Group
|
|
36
40
|
/**
|
|
37
41
|
* Which server to use from the array of `servers.url[serverIndex]`
|
|
38
42
|
* @example
|
|
@@ -149,7 +153,7 @@ export type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | By
|
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
type ResolvedOptions = Options & {
|
|
152
|
-
output: Output
|
|
156
|
+
output: Output<Oas>
|
|
153
157
|
}
|
|
154
158
|
|
|
155
|
-
export type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API,
|
|
159
|
+
export type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, ResolvePathOptions>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Output } from '@kubb/core'
|
|
2
|
+
import type { Oas } from '@kubb/oas'
|
|
3
|
+
import { isFunction } from 'remeda'
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
oas: Oas
|
|
7
|
+
output: Output<Oas>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getBanner({ output, oas }: Props) {
|
|
11
|
+
if (!output.banner) {
|
|
12
|
+
return undefined
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (isFunction(output.banner)) {
|
|
16
|
+
return output.banner(oas)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return output.banner
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Output } from '@kubb/core'
|
|
2
|
+
import type { Oas } from '@kubb/oas'
|
|
3
|
+
import { isFunction } from 'remeda'
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
oas: Oas
|
|
7
|
+
output: Output<Oas>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getFooter({ output, oas }: Props) {
|
|
11
|
+
if (!output.footer) {
|
|
12
|
+
return undefined
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (isFunction(output.footer)) {
|
|
16
|
+
return output.footer(oas)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return output.footer
|
|
20
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -4,5 +4,7 @@ export { getSchemaFactory } from './getSchemaFactory.ts'
|
|
|
4
4
|
export type { GetSchemasProps } from './getSchemas.ts'
|
|
5
5
|
export { getSchemas } from './getSchemas.ts'
|
|
6
6
|
export { parseFromConfig } from './parseFromConfig.ts'
|
|
7
|
+
export { getBanner } from './getBanner.ts'
|
|
8
|
+
export { getFooter } from './getFooter.ts'
|
|
7
9
|
|
|
8
10
|
export { isOptional } from '@kubb/oas'
|
package/dist/chunk-BZOI3PL5.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import { URLPath } from '@kubb/core/utils';
|
|
3
|
-
import { parse, Oas } from '@kubb/oas';
|
|
4
|
-
import yaml from '@stoplight/yaml';
|
|
5
|
-
|
|
6
|
-
// src/utils/parseFromConfig.ts
|
|
7
|
-
function parseFromConfig(config, oasClass = Oas) {
|
|
8
|
-
if ("data" in config.input) {
|
|
9
|
-
if (typeof config.input.data === "object") {
|
|
10
|
-
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
11
|
-
return parse(api2, oasClass);
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
const api2 = yaml.parse(config.input.data);
|
|
15
|
-
return parse(api2, oasClass);
|
|
16
|
-
} catch (e) {
|
|
17
|
-
}
|
|
18
|
-
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
19
|
-
return parse(api, oasClass);
|
|
20
|
-
}
|
|
21
|
-
if (new URLPath(config.input.path).isURL) {
|
|
22
|
-
return parse(config.input.path, oasClass);
|
|
23
|
-
}
|
|
24
|
-
return parse(resolve(config.root, config.input.path), oasClass);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { parseFromConfig };
|
|
28
|
-
//# sourceMappingURL=chunk-BZOI3PL5.js.map
|
|
29
|
-
//# sourceMappingURL=chunk-BZOI3PL5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/parseFromConfig.ts"],"names":["api"],"mappings":";;;;;;AAUO,SAAS,eAAA,CAAgB,MAAgB,EAAA,QAAA,GAAuB,GAAmB,EAAA;AACxF,EAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,IAAA,IAAI,OAAO,MAAA,CAAO,KAAM,CAAA,IAAA,KAAS,QAAU,EAAA;AACzC,MAAMA,MAAAA,IAAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAO,OAAA,KAAA,CAAMA,MAAK,QAAQ,CAAA;AAAA;AAG5B,IAAI,IAAA;AACF,MAAA,MAAMA,IAAc,GAAA,IAAA,CAAK,KAAM,CAAA,MAAA,CAAO,MAAM,IAAc,CAAA;AAE1D,MAAO,OAAA,KAAA,CAAMA,MAAK,QAAQ,CAAA;AAAA,aACnB,CAAG,EAAA;AAAA;AAIZ,IAAM,MAAA,GAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAO,OAAA,KAAA,CAAM,KAAK,QAAQ,CAAA;AAAA;AAG5B,EAAA,IAAI,IAAI,OAAQ,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAAE,KAAO,EAAA;AACxC,IAAA,OAAO,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA,EAAM,QAAQ,CAAA;AAAA;AAG1C,EAAO,OAAA,KAAA,CAAM,QAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,GAAG,QAAQ,CAAA;AAChE","file":"chunk-BZOI3PL5.js","sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { 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 (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), oasClass)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":["createRoot","App","jsx","Oas","camelCase"],"mappings":";;;;;;;AA2CO,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA;AACT;AASO,SAAS,qBAA4D,YAAoE,EAAA;AAC9I,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,MAAM,UAAW,CAAA,EAAE,UAAU,OAAS,EAAA,UAAA,EAAY,oBAAsB,EAAA;AACtE,MAAI,IAAA,CAAC,aAAa,UAAY,EAAA;AAC5B,QAAA,OAAO,EAAC;AAAA;AAGV,MAAA,MAAM,EAAE,aAAe,EAAA,GAAA,EAAK,MAAQ,EAAA,IAAA,KAAS,QAAS,CAAA,OAAA;AACtD,MAAA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,aAAA,EAAe,MAAO,EAAA,GAAI,QAAS,CAAA,OAAA;AAC3C,IAAM,MAAA,IAAA,GAAO,cAAc,OAAQ,CAAA;AAAA,MACjC,IAAA,EAAME,sBAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,MAC3B,OAAS,EAAA,OAAA;AAAA,MACT,IAAM,EAAA,OAAA;AAAA,MACN,WAAW,MAAO,CAAA;AAAA,KACnB,CAAA;AAED,IAAO,OAAA;AAAA,MACL;AAAA,QACE,GAAG,IAAA;AAAA,QACH,OAAS,EAAA;AAAA,UACP;AAAA,YACE,IAAA,EAAMA,sBAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,YAC3B,YAAc,EAAA,KAAA;AAAA,YACd,WAAa,EAAA,KAAA;AAAA,YACb,KAAO,EAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAK;AAAA;AACpC,SACF;AAAA,QACA,MAAA,EAAQ,MAAO,CAAA,OAAA,CAAQ,MAAQ,EAAA,MAAA;AAAA,QAC/B,MAAA,EAAQ,MAAO,CAAA,OAAA,CAAQ,MAAQ,EAAA;AAAA;AACjC,KACF;AAAA;AAEJ,CAAC","file":"chunk-FSCYFGYN.cjs","sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\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\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\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\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} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\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\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\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 const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\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'\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: plugin.options.output?.banner,\n format: plugin.options.output?.footer,\n },\n ]\n },\n})\n"]}
|
package/dist/chunk-QXUSUL7H.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('path');
|
|
4
|
-
var utils = require('@kubb/core/utils');
|
|
5
|
-
var oas = require('@kubb/oas');
|
|
6
|
-
var yaml = require('@stoplight/yaml');
|
|
7
|
-
|
|
8
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
|
|
10
|
-
var yaml__default = /*#__PURE__*/_interopDefault(yaml);
|
|
11
|
-
|
|
12
|
-
// src/utils/parseFromConfig.ts
|
|
13
|
-
function parseFromConfig(config, oasClass = oas.Oas) {
|
|
14
|
-
if ("data" in config.input) {
|
|
15
|
-
if (typeof config.input.data === "object") {
|
|
16
|
-
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
17
|
-
return oas.parse(api2, oasClass);
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const api2 = yaml__default.default.parse(config.input.data);
|
|
21
|
-
return oas.parse(api2, oasClass);
|
|
22
|
-
} catch (e) {
|
|
23
|
-
}
|
|
24
|
-
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
25
|
-
return oas.parse(api, oasClass);
|
|
26
|
-
}
|
|
27
|
-
if (new utils.URLPath(config.input.path).isURL) {
|
|
28
|
-
return oas.parse(config.input.path, oasClass);
|
|
29
|
-
}
|
|
30
|
-
return oas.parse(path.resolve(config.root, config.input.path), oasClass);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports.parseFromConfig = parseFromConfig;
|
|
34
|
-
//# sourceMappingURL=chunk-QXUSUL7H.cjs.map
|
|
35
|
-
//# sourceMappingURL=chunk-QXUSUL7H.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/parseFromConfig.ts"],"names":["Oas","api","parse","yaml","URLPath","resolve"],"mappings":";;;;;;;;;;;;AAUO,SAAS,eAAA,CAAgB,MAAgB,EAAA,QAAA,GAAuBA,OAAmB,EAAA;AACxF,EAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,IAAA,IAAI,OAAO,MAAA,CAAO,KAAM,CAAA,IAAA,KAAS,QAAU,EAAA;AACzC,MAAMC,MAAAA,IAAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAO,OAAAC,SAAA,CAAMD,MAAK,QAAQ,CAAA;AAAA;AAG5B,IAAI,IAAA;AACF,MAAA,MAAMA,IAAc,GAAAE,qBAAA,CAAK,KAAM,CAAA,MAAA,CAAO,MAAM,IAAc,CAAA;AAE1D,MAAO,OAAAD,SAAA,CAAMD,MAAK,QAAQ,CAAA;AAAA,aACnB,CAAG,EAAA;AAAA;AAIZ,IAAM,MAAA,GAAA,GAA4B,KAAK,KAAM,CAAA,IAAA,CAAK,UAAU,MAAO,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAO,OAAAC,SAAA,CAAM,KAAK,QAAQ,CAAA;AAAA;AAG5B,EAAA,IAAI,IAAIE,aAAQ,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAAE,KAAO,EAAA;AACxC,IAAA,OAAOF,SAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA,EAAM,QAAQ,CAAA;AAAA;AAG1C,EAAO,OAAAA,SAAA,CAAMG,aAAQ,MAAO,CAAA,IAAA,EAAM,OAAO,KAAM,CAAA,IAAI,GAAG,QAAQ,CAAA;AAChE","file":"chunk-QXUSUL7H.cjs","sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { 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 (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), oasClass)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":[],"mappings":";;;;;AA2CO,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA;AACT;AASO,SAAS,qBAA4D,YAAoE,EAAA;AAC9I,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,MAAM,UAAW,CAAA,EAAE,UAAU,OAAS,EAAA,UAAA,EAAY,oBAAsB,EAAA;AACtE,MAAI,IAAA,CAAC,aAAa,UAAY,EAAA;AAC5B,QAAA,OAAO,EAAC;AAAA;AAGV,MAAA,MAAM,EAAE,aAAe,EAAA,GAAA,EAAK,MAAQ,EAAA,IAAA,KAAS,QAAS,CAAA,OAAA;AACtD,MAAA,MAAM,OAAO,UAAW,CAAA;AAAA,QACtB,QAAQ,aAAc,CAAA;AAAA,OACvB,CAAA;AAED,MAAA,MAAM,SAAY,GAAA,YAAA,CAAa,UAAW,CAAA,IAAA,CAAK,IAAI,CAAA;AAEnD,MAAK,IAAA,CAAA,MAAA;AAAA,4BACF,GAAI,EAAA,EAAA,aAAA,EAA8B,QAAgB,IACjD,EAAA,QAAA,kBAAA,GAAA,CAAC,OAAI,GAAU,EAAA,UAAA,EAAwB,SAAW,EAAA,QAAA,EAChD,8BAAC,SAAU,EAAA,EAAA,UAAA,EAAwB,UAAoB,kBAAwC,EAAA,OAAA,EAAkB,GACnH,CACF,EAAA;AAAA,OACF;AAEA,MAAA,OAAO,IAAK,CAAA,KAAA;AAAA,KACd;AAAA,IACA,MAAM,SAAU,CAAA,EAAE,QAAU,EAAA,SAAA,EAAW,SAAW,EAAA;AAChD,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O,CAAA,OAAA,CAAQ,MAAQ,EAAA,MAAA;AAAA,QAC/B,MAAA,EAAQ,MAAO,CAAA,OAAA,CAAQ,MAAQ,EAAA;AAAA;AACjC,KACF;AAAA;AAEJ,CAAC","file":"chunk-WBHFV7C2.js","sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\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\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\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\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} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\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\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\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 const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\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'\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: plugin.options.output?.banner,\n format: plugin.options.output?.footer,\n },\n ]\n },\n})\n"]}
|