@kubb/plugin-oas 4.1.4 → 4.2.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/{Oas-CuqAnIw-.js → Oas-DoN76W2_.js} +2 -2
- package/dist/{Oas-CuqAnIw-.js.map → Oas-DoN76W2_.js.map} +1 -1
- package/dist/{OperationGenerator-B3oFps4I.d.ts → OperationGenerator-BeVo1_b1.d.cts} +87 -157
- package/dist/{OperationGenerator-aKcfGbOt.d.cts → OperationGenerator-CUE372Ht.d.ts} +87 -157
- package/dist/{Schema-DxWT5L8_.d.ts → Schema-BPvUCUWJ.d.ts} +7 -8
- package/dist/{Schema-CEmdFRTN.d.cts → Schema-D-wz873C.d.cts} +7 -8
- package/dist/{SchemaGenerator-Dnllsi8M.cjs → SchemaGenerator-BQUPa5AD.cjs} +2 -3
- package/dist/{SchemaGenerator-Dnllsi8M.cjs.map → SchemaGenerator-BQUPa5AD.cjs.map} +1 -1
- package/dist/{SchemaGenerator-TL2a9FN6.js → SchemaGenerator-DYOXlswO.js} +5 -6
- package/dist/{SchemaGenerator-TL2a9FN6.js.map → SchemaGenerator-DYOXlswO.js.map} +1 -1
- package/dist/{SchemaMapper-BiagBQN4.d.cts → SchemaMapper-BWDIvdP9.d.ts} +2 -2
- package/dist/{SchemaMapper-C2J2d3o4.d.ts → SchemaMapper-BvE5JflR.d.cts} +2 -2
- package/dist/{SchemaMapper-BaZQKrQB.js → SchemaMapper-CqOUibvI.js} +2 -2
- package/dist/{SchemaMapper-BaZQKrQB.js.map → SchemaMapper-CqOUibvI.js.map} +1 -1
- package/dist/components.d.cts +7 -19
- package/dist/components.d.ts +7 -19
- package/dist/components.js +1 -1
- package/dist/{generators-L3av7_7B.cjs → generators-BIyNritE.cjs} +76 -61
- package/dist/generators-BIyNritE.cjs.map +1 -0
- package/dist/{generators-CW7v1RgJ.js → generators-CJBwMPUb.js} +79 -64
- package/dist/generators-CJBwMPUb.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +3 -3
- package/dist/getFooter-CvTKkK7-.js +58 -0
- package/dist/getFooter-CvTKkK7-.js.map +1 -0
- package/dist/getFooter-pQXwqM81.cjs +72 -0
- package/dist/getFooter-pQXwqM81.cjs.map +1 -0
- package/dist/{getSchemas-WoSBIxG8.js → getSchemas-CvUX0jWa.js} +2 -2
- package/dist/{getSchemas-WoSBIxG8.js.map → getSchemas-CvUX0jWa.js.map} +1 -1
- package/dist/hooks.cjs +7 -3
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +3 -3
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +10 -7
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +5 -5
- 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 +9 -9
- package/dist/index.js.map +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-yAiFK03V.js → parseFromConfig-DSI6Meg0.js} +5 -10
- package/dist/parseFromConfig-DSI6Meg0.js.map +1 -0
- package/dist/{parseFromConfig-CFzprC8B.cjs → parseFromConfig-o3tU1XJt.cjs} +4 -9
- package/dist/parseFromConfig-o3tU1XJt.cjs.map +1 -0
- package/dist/utils.cjs +2 -2
- package/dist/utils.d.cts +6 -9
- package/dist/utils.d.ts +6 -9
- package/dist/utils.js +3 -3
- package/package.json +5 -7
- package/src/generator.tsx +50 -43
- package/src/hooks/useOperationManager.ts +5 -6
- package/src/hooks/useSchemaManager.ts +3 -3
- package/src/plugin.ts +2 -3
- package/src/utils/getBanner.ts +47 -1
- package/dist/generators-CW7v1RgJ.js.map +0 -1
- package/dist/generators-L3av7_7B.cjs.map +0 -1
- package/dist/getFooter-B_nmsoeK.cjs +0 -45
- package/dist/getFooter-B_nmsoeK.cjs.map +0 -1
- package/dist/getFooter-DM8B8cnC.js +0 -31
- package/dist/getFooter-DM8B8cnC.js.map +0 -1
- package/dist/parseFromConfig-CFzprC8B.cjs.map +0 -1
- package/dist/parseFromConfig-yAiFK03V.js.map +0 -1
package/dist/utils.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./SchemaMapper-
|
|
1
|
+
import { D as Output, E as Config, F as OpenAPIV3$1, I as OpenAPIV3_1, L as Operation, M as Oas, P as OasTypes, R as SchemaObject$1, g as OperationSchema, j as types_d_exports, z as contentType } from "./OperationGenerator-BeVo1_b1.cjs";
|
|
2
|
+
import "./SchemaMapper-BvE5JflR.cjs";
|
|
3
3
|
import { OASDocument, SchemaObject } from "oas/types";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
5
|
|
|
@@ -7,6 +7,9 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
7
7
|
|
|
8
8
|
declare function isOptional(schema?: SchemaObject): boolean;
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/utils/getComments.d.ts
|
|
11
|
+
declare function getComments(operation: Operation): string[];
|
|
12
|
+
//#endregion
|
|
10
13
|
//#region ../core/src/utils/FunctionParams.d.ts
|
|
11
14
|
type FunctionParamsASTWithoutType = {
|
|
12
15
|
name?: string;
|
|
@@ -38,19 +41,13 @@ type FunctionParamsASTWithType = {
|
|
|
38
41
|
* @deprecated
|
|
39
42
|
*/
|
|
40
43
|
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated
|
|
43
|
-
*/
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/utils/getComments.d.ts
|
|
46
|
-
declare function getComments(operation: Operation): string[];
|
|
47
44
|
//#endregion
|
|
48
45
|
//#region src/utils/getParams.d.ts
|
|
49
46
|
declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
|
|
50
47
|
typed?: boolean;
|
|
51
48
|
casing?: 'camelcase';
|
|
52
49
|
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
53
|
-
}): Params;
|
|
50
|
+
}): types_d_exports.Params;
|
|
54
51
|
//#endregion
|
|
55
52
|
//#region src/utils/getSchemaFactory.d.ts
|
|
56
53
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./SchemaMapper-
|
|
1
|
+
import { D as Output, E as Config, F as OpenAPIV3$1, I as OpenAPIV3_1, L as Operation, M as Oas, P as OasTypes, R as SchemaObject$1, g as OperationSchema, j as types_d_exports, z as contentType } from "./OperationGenerator-CUE372Ht.js";
|
|
2
|
+
import "./SchemaMapper-BWDIvdP9.js";
|
|
3
3
|
import { OASDocument, SchemaObject } from "oas/types";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
5
|
|
|
@@ -7,6 +7,9 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
7
7
|
|
|
8
8
|
declare function isOptional(schema?: SchemaObject): boolean;
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/utils/getComments.d.ts
|
|
11
|
+
declare function getComments(operation: Operation): string[];
|
|
12
|
+
//#endregion
|
|
10
13
|
//#region ../core/src/utils/FunctionParams.d.ts
|
|
11
14
|
type FunctionParamsASTWithoutType = {
|
|
12
15
|
name?: string;
|
|
@@ -38,19 +41,13 @@ type FunctionParamsASTWithType = {
|
|
|
38
41
|
* @deprecated
|
|
39
42
|
*/
|
|
40
43
|
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated
|
|
43
|
-
*/
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/utils/getComments.d.ts
|
|
46
|
-
declare function getComments(operation: Operation): string[];
|
|
47
44
|
//#endregion
|
|
48
45
|
//#region src/utils/getParams.d.ts
|
|
49
46
|
declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
|
|
50
47
|
typed?: boolean;
|
|
51
48
|
casing?: 'camelcase';
|
|
52
49
|
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
53
|
-
}): Params;
|
|
50
|
+
}): types_d_exports.Params;
|
|
54
51
|
//#endregion
|
|
55
52
|
//#region src/utils/getSchemaFactory.d.ts
|
|
56
53
|
/**
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getBanner, getFooter } from "./getFooter-
|
|
2
|
-
import { getSchemaFactory, getSchemas } from "./getSchemas-
|
|
3
|
-
import { parseFromConfig } from "./parseFromConfig-
|
|
1
|
+
import { n as getBanner, t as getFooter } from "./getFooter-CvTKkK7-.js";
|
|
2
|
+
import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-CvUX0jWa.js";
|
|
3
|
+
import { t as parseFromConfig } from "./parseFromConfig-DSI6Meg0.js";
|
|
4
4
|
import transformers, { camelCase, isValidVarName } from "@kubb/core/transformers";
|
|
5
5
|
import { URLPath } from "@kubb/core/utils";
|
|
6
6
|
import { isOptional, isParameterObject } from "@kubb/oas";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "4.1
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -82,14 +82,12 @@
|
|
|
82
82
|
"@stoplight/yaml": "^4.3.0",
|
|
83
83
|
"p-limit": "^7.2.0",
|
|
84
84
|
"remeda": "^2.32.0",
|
|
85
|
-
"@kubb/core": "4.1
|
|
86
|
-
"@kubb/
|
|
87
|
-
"@kubb/
|
|
85
|
+
"@kubb/core": "4.2.1",
|
|
86
|
+
"@kubb/react": "4.2.1",
|
|
87
|
+
"@kubb/oas": "4.2.1"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"
|
|
91
|
-
"react": "^18.3.1",
|
|
92
|
-
"tsdown": "^0.14.2",
|
|
90
|
+
"tsdown": "^0.15.9",
|
|
93
91
|
"typescript": "^5.9.3"
|
|
94
92
|
},
|
|
95
93
|
"peerDependencies": {
|
package/src/generator.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginFactoryOptions } from '@kubb/core'
|
|
2
2
|
import type { KubbFile } from '@kubb/core/fs'
|
|
3
3
|
import type { Operation, SchemaObject } from '@kubb/oas'
|
|
4
|
-
import { App,
|
|
4
|
+
import { App, createApp } from '@kubb/react'
|
|
5
5
|
import type { KubbNode } from '@kubb/react/types'
|
|
6
6
|
import { Oas } from './components/Oas.tsx'
|
|
7
7
|
import type { OperationGenerator } from './OperationGenerator.ts'
|
|
@@ -66,19 +66,21 @@ export function createReactGenerator<TOptions extends PluginFactoryOptions>(pars
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const { pluginManager, oas, plugin, mode } = instance.context
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
69
|
+
const Operations = parseOptions.Operations
|
|
70
|
+
|
|
71
|
+
function Component() {
|
|
72
|
+
return (
|
|
73
|
+
<App meta={{ pluginManager, plugin, mode }}>
|
|
74
|
+
<Oas oas={oas} operations={operations} generator={instance}>
|
|
75
|
+
<Operations operations={operations} instance={instance} options={options} />
|
|
76
|
+
</Oas>
|
|
77
|
+
</App>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
const app = createApp(Component)
|
|
81
|
+
|
|
82
|
+
app.render()
|
|
83
|
+
return app.files
|
|
82
84
|
},
|
|
83
85
|
async operation({ instance, operation, options }) {
|
|
84
86
|
if (!parseOptions.Operation) {
|
|
@@ -86,21 +88,23 @@ export function createReactGenerator<TOptions extends PluginFactoryOptions>(pars
|
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
const { pluginManager, oas, plugin, mode } = instance.context
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)
|
|
103
|
-
|
|
91
|
+
const Operation = parseOptions.Operation
|
|
92
|
+
|
|
93
|
+
function Component() {
|
|
94
|
+
return (
|
|
95
|
+
<App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>
|
|
96
|
+
<Oas oas={oas} operations={[operation]} generator={instance}>
|
|
97
|
+
<Oas.Operation operation={operation}>
|
|
98
|
+
<Operation operation={operation} options={options} instance={instance} />
|
|
99
|
+
</Oas.Operation>
|
|
100
|
+
</Oas>
|
|
101
|
+
</App>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
const app = createApp(Component)
|
|
105
|
+
|
|
106
|
+
app.render()
|
|
107
|
+
return app.files
|
|
104
108
|
},
|
|
105
109
|
async schema({ instance, schema, options }) {
|
|
106
110
|
if (!parseOptions.Schema) {
|
|
@@ -109,20 +113,23 @@ export function createReactGenerator<TOptions extends PluginFactoryOptions>(pars
|
|
|
109
113
|
|
|
110
114
|
const { pluginManager, oas, plugin, mode } = instance.context
|
|
111
115
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
</Oas
|
|
122
|
-
</
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
const Schema = parseOptions.Schema
|
|
117
|
+
|
|
118
|
+
function Component() {
|
|
119
|
+
return (
|
|
120
|
+
<App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>
|
|
121
|
+
<Oas oas={oas}>
|
|
122
|
+
<Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>
|
|
123
|
+
<Schema schema={schema} options={options} instance={instance} />
|
|
124
|
+
</Oas.Schema>
|
|
125
|
+
</Oas>
|
|
126
|
+
</App>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
const app = createApp(Component)
|
|
130
|
+
|
|
131
|
+
app.render()
|
|
132
|
+
return app.files
|
|
126
133
|
},
|
|
127
134
|
}
|
|
128
135
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { useApp, useContext } from '@kubb/react'
|
|
2
|
-
|
|
3
|
-
import { Oas } from '../components/Oas.tsx'
|
|
4
|
-
|
|
5
1
|
import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'
|
|
6
|
-
|
|
7
2
|
import type { KubbFile } from '@kubb/core/fs'
|
|
3
|
+
import { usePlugin, usePluginManager } from '@kubb/core/hooks'
|
|
8
4
|
import type { Operation, Operation as OperationType } from '@kubb/oas'
|
|
5
|
+
import { useContext } from '@kubb/react'
|
|
6
|
+
import { Oas } from '../components/Oas.tsx'
|
|
9
7
|
import type { OperationSchemas } from '../types.ts'
|
|
10
8
|
|
|
11
9
|
type FileMeta = FileMetaBase & {
|
|
@@ -66,7 +64,8 @@ type UseOperationManagerResult = {
|
|
|
66
64
|
* `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
|
|
67
65
|
*/
|
|
68
66
|
export function useOperationManager(): UseOperationManagerResult {
|
|
69
|
-
const
|
|
67
|
+
const plugin = usePlugin()
|
|
68
|
+
const pluginManager = usePluginManager()
|
|
70
69
|
const { generator } = useContext(Oas.Context)
|
|
71
70
|
|
|
72
71
|
const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { useApp } from '@kubb/react'
|
|
2
|
-
|
|
3
1
|
import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'
|
|
4
2
|
import type { KubbFile } from '@kubb/core/fs'
|
|
3
|
+
import { usePlugin, usePluginManager } from '@kubb/core/hooks'
|
|
5
4
|
import { SchemaGenerator } from '../SchemaGenerator.ts'
|
|
6
5
|
import { type Schema, schemaKeywords } from '../SchemaMapper'
|
|
7
6
|
|
|
@@ -35,7 +34,8 @@ type UseSchemaManagerResult = {
|
|
|
35
34
|
* `useSchemaManager` will return some helper functions that can be used to get the schema file, get the schema name.
|
|
36
35
|
*/
|
|
37
36
|
export function useSchemaManager(): UseSchemaManagerResult {
|
|
38
|
-
const
|
|
37
|
+
const plugin = usePlugin()
|
|
38
|
+
const pluginManager = usePluginManager()
|
|
39
39
|
|
|
40
40
|
const getName: UseSchemaManagerResult['getName'] = (name, { pluginKey = plugin.key, type }) => {
|
|
41
41
|
return pluginManager.resolveName({
|
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import type
|
|
3
|
-
import { createPlugin, FileManager, type Group } from '@kubb/core'
|
|
2
|
+
import { type Config, createPlugin, type Group, getMode } from '@kubb/core'
|
|
4
3
|
import type { Logger } from '@kubb/core/logger'
|
|
5
4
|
import { camelCase } from '@kubb/core/transformers'
|
|
6
5
|
import type { Oas } from '@kubb/oas'
|
|
@@ -76,7 +75,7 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
76
75
|
},
|
|
77
76
|
resolvePath(baseName, pathMode, options) {
|
|
78
77
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
79
|
-
const mode = pathMode ??
|
|
78
|
+
const mode = pathMode ?? getMode(path.resolve(root, output.path))
|
|
80
79
|
|
|
81
80
|
if (mode === 'single') {
|
|
82
81
|
/**
|
package/src/utils/getBanner.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Config, Output } from '@kubb/core'
|
|
2
2
|
import type { Oas } from '@kubb/oas'
|
|
3
3
|
import { isFunction } from 'remeda'
|
|
4
|
+
import path from 'node:path'
|
|
4
5
|
|
|
5
6
|
type Props<TOas extends Oas> = {
|
|
6
7
|
oas: TOas
|
|
@@ -8,6 +9,51 @@ type Props<TOas extends Oas> = {
|
|
|
8
9
|
config?: Config
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Generate a default banner for files created by Kubb
|
|
14
|
+
* @returns A string with the default banner
|
|
15
|
+
*/
|
|
16
|
+
function getDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {
|
|
17
|
+
try {
|
|
18
|
+
let source = ''
|
|
19
|
+
if ('path' in config.input) {
|
|
20
|
+
source = path.basename(config.input.path)
|
|
21
|
+
} else if ('data' in config.input) {
|
|
22
|
+
source = 'text content'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let banner = '/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n'
|
|
26
|
+
|
|
27
|
+
if (config.output.defaultBanner === 'simple') {
|
|
28
|
+
banner += '*/\n'
|
|
29
|
+
return banner
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (source) {
|
|
33
|
+
banner += `* Source: ${source}\n`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (title) {
|
|
37
|
+
banner += `* Title: ${title}\n`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (description) {
|
|
41
|
+
const formattedDescription = description.replace(/\n/gm, '\n* ')
|
|
42
|
+
banner += `* Description: ${formattedDescription}\n`
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (version) {
|
|
46
|
+
banner += `* OpenAPI spec version: ${version}\n`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
banner += '*/\n'
|
|
50
|
+
return banner
|
|
51
|
+
} catch (_error) {
|
|
52
|
+
// If there's any error in parsing the Oas data, return a simpler banner
|
|
53
|
+
return '/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
11
57
|
export function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {
|
|
12
58
|
let banner = ''
|
|
13
59
|
if (config?.output?.defaultBanner !== false && config) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-CW7v1RgJ.js","names":[],"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,gBAAuD,cAA+D;AACpI,QAAO;;;;;;;;;AAiBT,SAAgB,qBAA4D,cAAoE;AAC9I,QAAO;EACL,GAAG;EACH,MAAM,WAAW,EAAE,UAAU,SAAS,cAAc;AAClD,OAAI,CAAC,aAAa,WAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,OAAO,WAAW,EACtB,QAAQ,cAAc,QACvB,CAAC;GACF,MAAM,YAAY,aAAa,WAAW,KAAK,KAAK;AAEpD,QAAK,OACH,oBAAC;IAAmB;IAAuB;IAAc;cACvD,oBAAC;KAAS;KAAiB;KAAY,WAAW;eAChD,oBAAC;MAAsB;MAAsB;MAAmB;OAAW;MACvE;KACF,CACP;AACD,UAAO,KAAK;;EAEd,MAAM,UAAU,EAAE,UAAU,WAAW,WAAW;AAChD,OAAI,CAAC,aAAa,UAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,OAAO,WAAW,EACtB,QAAQ,cAAc,QACvB,CAAC;GACF,MAAM,YAAY,aAAa,UAAU,KAAK,KAAK;AAEnD,QAAK,OACH,oBAAC;IAAmB;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAQ;cACvE,oBAAC;KAAS;KAAK,YAAY,CAAC,UAAU;KAAE,WAAW;eACjD,oBAAC,IAAI;MAAqB;gBACxB,oBAAC;OAAqB;OAAoB;OAAmB;QAAY;OAC3D;MACZ;KACF,CACP;AACD,UAAO,KAAK;;EAEd,MAAM,OAAO,EAAE,UAAU,QAAQ,WAAW;AAC1C,OAAI,CAAC,aAAa,OAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GAEtD,MAAM,YAAY,aAAa,OAAO,KAAK,KAAK;GAChD,MAAM,OAAO,WAAW,EACtB,QAAQ,cAAc,QACvB,CAAC;AACF,QAAK,OACH,oBAAC;IAAmB;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAQ;cACvE,oBAAC;KAAS;eACR,oBAAC,IAAI;MAAO,MAAM,OAAO;MAAM,cAAc,OAAO;MAAO,MAAM,OAAO;gBACtE,oBAAC;OAAkB;OAAiB;OAAmB;QAAY;OACxD;MACT;KACF,CACP;AACD,UAAO,KAAK;;EAEf;;;;;ACxHH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,YAAY;EACjC,MAAM,EAAE,eAAe,WAAW,SAAS;AAQ3C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAM,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-L3av7_7B.cjs","names":["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,gBAAuD,cAA+D;AACpI,QAAO;;;;;;;;;AAiBT,SAAgB,qBAA4D,cAAoE;AAC9I,QAAO;EACL,GAAG;EACH,MAAM,WAAW,EAAE,UAAU,SAAS,cAAc;AAClD,OAAI,CAAC,aAAa,WAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,oCAAkB,EACtB,QAAQ,cAAc,QACvB,CAAC;GACF,MAAM,YAAY,aAAa,WAAW,KAAK,KAAK;AAEpD,QAAK,OACH,kDAACA;IAAmB;IAAuB;IAAc;cACvD,kDAACC;KAAS;KAAiB;KAAY,WAAW;eAChD,kDAAC;MAAsB;MAAsB;MAAmB;OAAW;MACvE;KACF,CACP;AACD,UAAO,KAAK;;EAEd,MAAM,UAAU,EAAE,UAAU,WAAW,WAAW;AAChD,OAAI,CAAC,aAAa,UAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GACtD,MAAM,oCAAkB,EACtB,QAAQ,cAAc,QACvB,CAAC;GACF,MAAM,YAAY,aAAa,UAAU,KAAK,KAAK;AAEnD,QAAK,OACH,kDAACD;IAAmB;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAQ;cACvE,kDAACC;KAAS;KAAK,YAAY,CAAC,UAAU;KAAE,WAAW;eACjD,kDAACA,gBAAI;MAAqB;gBACxB,kDAAC;OAAqB;OAAoB;OAAmB;QAAY;OAC3D;MACZ;KACF,CACP;AACD,UAAO,KAAK;;EAEd,MAAM,OAAO,EAAE,UAAU,QAAQ,WAAW;AAC1C,OAAI,CAAC,aAAa,OAChB,QAAO,EAAE;GAGX,MAAM,EAAE,eAAe,KAAK,QAAQ,SAAS,SAAS;GAEtD,MAAM,YAAY,aAAa,OAAO,KAAK,KAAK;GAChD,MAAM,oCAAkB,EACtB,QAAQ,cAAc,QACvB,CAAC;AACF,QAAK,OACH,kDAACD;IAAmB;IAAe,QAAQ;KAAE,GAAG;KAAQ;KAAS;IAAQ;cACvE,kDAACC;KAAS;eACR,kDAACA,gBAAI;MAAO,MAAM,OAAO;MAAM,cAAc,OAAO;MAAO,MAAM,OAAO;gBACtE,kDAAC;OAAkB;OAAiB;OAAmB;QAAY;OACxD;MACT;KACF,CACP;AACD,UAAO,KAAK;;EAEf;;;;;ACxHH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,YAAY;EACjC,MAAM,EAAE,eAAe,WAAW,SAAS;AAQ3C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,8CAAgB,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,8CAAgB,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQC,4BAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,4BAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
let __kubb_core = require("@kubb/core");
|
|
3
|
-
__kubb_core = require_chunk.__toESM(__kubb_core);
|
|
4
|
-
let remeda = require("remeda");
|
|
5
|
-
remeda = require_chunk.__toESM(remeda);
|
|
6
|
-
|
|
7
|
-
//#region src/utils/getBanner.ts
|
|
8
|
-
function getBanner({ output, oas, config }) {
|
|
9
|
-
let banner = "";
|
|
10
|
-
if (config?.output?.defaultBanner !== false && config) {
|
|
11
|
-
const { title, description, version } = oas.api?.info || {};
|
|
12
|
-
banner = (0, __kubb_core.getDefaultBanner)({
|
|
13
|
-
title,
|
|
14
|
-
description,
|
|
15
|
-
version,
|
|
16
|
-
config
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
if (!output.banner) return banner;
|
|
20
|
-
if ((0, remeda.isFunction)(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
21
|
-
return `${output.banner}\n${banner}`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/utils/getFooter.ts
|
|
26
|
-
function getFooter({ output, oas }) {
|
|
27
|
-
if (!output.footer) return;
|
|
28
|
-
if ((0, remeda.isFunction)(output.footer)) return output.footer(oas);
|
|
29
|
-
return output.footer;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
Object.defineProperty(exports, 'getBanner', {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () {
|
|
36
|
-
return getBanner;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(exports, 'getFooter', {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () {
|
|
42
|
-
return getFooter;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=getFooter-B_nmsoeK.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFooter-B_nmsoeK.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,UAA+B;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,YAAY,IAAI,KAAK,QAAQ,EAAE;AAE3D,6CAA0B;GAAE;GAAO;GAAa;GAAS;GAAQ,CAAC;;AAGpE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,4BAAe,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;;;;;ACjB9B,SAAgB,UAA4B,EAAE,QAAQ,OAAoB;AACxE,KAAI,CAAC,OAAO,OACV;AAGF,4BAAe,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|
|
@@ -1,31 +0,0 @@
|
|
|
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;
|
|
25
|
-
if (isFunction(output.footer)) return output.footer(oas);
|
|
26
|
-
return output.footer;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { getBanner, getFooter };
|
|
31
|
-
//# sourceMappingURL=getFooter-DM8B8cnC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFooter-DM8B8cnC.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,UAA+B;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,YAAY,IAAI,KAAK,QAAQ,EAAE;AAE3D,WAAS,iBAAiB;GAAE;GAAO;GAAa;GAAS;GAAQ,CAAC;;AAGpE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;;;;;ACjB9B,SAAgB,UAA4B,EAAE,QAAQ,OAAoB;AACxE,KAAI,CAAC,OAAO,OACV;AAGF,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseFromConfig-CFzprC8B.cjs","names":["Oas","api: OasTypes.OASDocument","api","api: string","yaml","URLPath"],"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { merge, parse } from '@kubb/oas'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, { oasClass })\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, { oasClass })\n } catch (_e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, { oasClass })\n }\n\n if (Array.isArray(config.input)) {\n return merge(\n config.input.map((input) => input.path),\n { oasClass },\n )\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, { oasClass })\n }\n\n return parse(resolve(config.root, config.input.path), { oasClass })\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,gBAAgB,QAAgB,WAAuBA,gBAAmB;AACxF,KAAI,UAAU,OAAO,OAAO;AAC1B,MAAI,OAAO,OAAO,MAAM,SAAS,UAAU;GACzC,MAAMC,QAA4B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC;AAC/E,gCAAaC,OAAK,EAAE,UAAU,CAAC;;AAGjC,MAAI;GACF,MAAMC,QAAcC,yBAAK,MAAM,OAAO,MAAM,KAAe;AAE3D,gCAAaF,OAAK,EAAE,UAAU,CAAC;WACxB,IAAI;EAIb,MAAMD,MAA4B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC;AAE/E,+BAAa,KAAK,EAAE,UAAU,CAAC;;AAGjC,KAAI,MAAM,QAAQ,OAAO,MAAM,CAC7B,8BACE,OAAO,MAAM,KAAK,UAAU,MAAM,KAAK,EACvC,EAAE,UAAU,CACb;AAGH,KAAI,IAAII,0BAAQ,OAAO,MAAM,KAAK,CAAC,MACjC,8BAAa,OAAO,MAAM,MAAM,EAAE,UAAU,CAAC;AAG/C,qDAAqB,OAAO,MAAM,OAAO,MAAM,KAAK,EAAE,EAAE,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseFromConfig-yAiFK03V.js","names":["api: OasTypes.OASDocument","api","api: string"],"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { merge, parse } from '@kubb/oas'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, { oasClass })\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, { oasClass })\n } catch (_e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, { oasClass })\n }\n\n if (Array.isArray(config.input)) {\n return merge(\n config.input.map((input) => input.path),\n { oasClass },\n )\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, { oasClass })\n }\n\n return parse(resolve(config.root, config.input.path), { oasClass })\n}\n"],"mappings":";;;;;;AAUA,SAAgB,gBAAgB,QAAgB,WAAuB,KAAmB;AACxF,KAAI,UAAU,OAAO,OAAO;AAC1B,MAAI,OAAO,OAAO,MAAM,SAAS,UAAU;GACzC,MAAMA,QAA4B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC;AAC/E,UAAO,MAAMC,OAAK,EAAE,UAAU,CAAC;;AAGjC,MAAI;GACF,MAAMC,QAAc,KAAK,MAAM,OAAO,MAAM,KAAe;AAE3D,UAAO,MAAMD,OAAK,EAAE,UAAU,CAAC;WACxB,IAAI;EAIb,MAAMD,MAA4B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,KAAK,CAAC;AAE/E,SAAO,MAAM,KAAK,EAAE,UAAU,CAAC;;AAGjC,KAAI,MAAM,QAAQ,OAAO,MAAM,CAC7B,QAAO,MACL,OAAO,MAAM,KAAK,UAAU,MAAM,KAAK,EACvC,EAAE,UAAU,CACb;AAGH,KAAI,IAAI,QAAQ,OAAO,MAAM,KAAK,CAAC,MACjC,QAAO,MAAM,OAAO,MAAM,MAAM,EAAE,UAAU,CAAC;AAG/C,QAAO,MAAM,QAAQ,OAAO,MAAM,OAAO,MAAM,KAAK,EAAE,EAAE,UAAU,CAAC"}
|