@kubb/plugin-oas 3.8.0 → 3.9.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-DkfVl11s.d.cts → OperationGenerator-DiF6WJNP.d.cts} +10 -6
- package/dist/{OperationGenerator-DkfVl11s.d.ts → OperationGenerator-DiF6WJNP.d.ts} +10 -6
- package/dist/{Schema-BJcs_y8u.d.ts → Schema-BbIxCfn7.d.ts} +1 -1
- package/dist/{Schema-B2XBcTNh.d.cts → Schema-Ds5f4y7m.d.cts} +1 -1
- package/dist/{chunk-TKFFW62C.cjs → chunk-DEDONPUL.cjs} +14 -7
- package/dist/chunk-DEDONPUL.cjs.map +1 -0
- package/dist/{chunk-EMSV6TX2.js → chunk-DN373TFU.js} +8 -4
- package/dist/chunk-DN373TFU.js.map +1 -0
- package/dist/{chunk-FNXIO7AH.cjs → chunk-DUZZHEQI.cjs} +9 -5
- package/dist/chunk-DUZZHEQI.cjs.map +1 -0
- package/dist/{chunk-HSTP26AO.cjs → chunk-I2LBG5AS.cjs} +27 -37
- package/dist/chunk-I2LBG5AS.cjs.map +1 -0
- package/dist/{chunk-3DX5ALTN.js → chunk-QPFZUPQA.js} +16 -8
- package/dist/chunk-QPFZUPQA.js.map +1 -0
- package/dist/{chunk-Z2353AWG.js → chunk-VJ6RX6RF.js} +28 -38
- package/dist/chunk-VJ6RX6RF.js.map +1 -0
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/generators.cjs +3 -3
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/hooks.cjs +2 -2
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/utils.cjs +7 -11
- package/dist/utils.d.cts +4 -12
- package/dist/utils.d.ts +4 -12
- package/dist/utils.js +1 -1
- package/package.json +9 -9
- package/src/SchemaGenerator.ts +26 -46
- package/src/SchemaMapper.ts +6 -2
- package/src/generators/jsonGenerator.ts +5 -1
- package/src/utils/getBanner.ts +13 -5
- package/src/utils/index.ts +1 -1
- package/dist/chunk-3DX5ALTN.js.map +0 -1
- package/dist/chunk-EMSV6TX2.js.map +0 -1
- package/dist/chunk-FNXIO7AH.cjs.map +0 -1
- package/dist/chunk-HSTP26AO.cjs.map +0 -1
- package/dist/chunk-TKFFW62C.cjs.map +0 -1
- package/dist/chunk-Z2353AWG.js.map +0 -1
package/dist/utils.cjs
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDEDONPUL_cjs = require('./chunk-DEDONPUL.cjs');
|
|
4
4
|
var chunkB7KP5ZFA_cjs = require('./chunk-B7KP5ZFA.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
Object.defineProperty(exports, "getASTParams", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () { return chunkTKFFW62C_cjs.getASTParams; }
|
|
11
|
-
});
|
|
12
8
|
Object.defineProperty(exports, "getBanner", {
|
|
13
9
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkDEDONPUL_cjs.getBanner; }
|
|
15
11
|
});
|
|
16
12
|
Object.defineProperty(exports, "getComments", {
|
|
17
13
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkDEDONPUL_cjs.getComments; }
|
|
19
15
|
});
|
|
20
16
|
Object.defineProperty(exports, "getFooter", {
|
|
21
17
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkDEDONPUL_cjs.getFooter; }
|
|
23
19
|
});
|
|
24
20
|
Object.defineProperty(exports, "getPathParams", {
|
|
25
21
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkDEDONPUL_cjs.getPathParams; }
|
|
27
23
|
});
|
|
28
24
|
Object.defineProperty(exports, "isOptional", {
|
|
29
25
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkDEDONPUL_cjs.isOptional; }
|
|
31
27
|
});
|
|
32
28
|
Object.defineProperty(exports, "parseFromConfig", {
|
|
33
29
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkDEDONPUL_cjs.parseFromConfig; }
|
|
35
31
|
});
|
|
36
32
|
Object.defineProperty(exports, "getSchemaFactory", {
|
|
37
33
|
enumerable: true,
|
package/dist/utils.d.cts
CHANGED
|
@@ -2,21 +2,12 @@ import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1, contentType, OasT
|
|
|
2
2
|
export { isOptional } from '@kubb/oas';
|
|
3
3
|
import { FunctionParamsAST } from '@kubb/core/utils';
|
|
4
4
|
import { Params } from '@kubb/react/types';
|
|
5
|
-
import { v as OperationSchema } from './OperationGenerator-
|
|
5
|
+
import { v as OperationSchema } from './OperationGenerator-DiF6WJNP.cjs';
|
|
6
6
|
import { Config, Output } from '@kubb/core';
|
|
7
7
|
import '@kubb/fs/types';
|
|
8
8
|
|
|
9
9
|
declare function getComments(operation: Operation): string[];
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @deprecated
|
|
14
|
-
* TODO move to operationManager hook
|
|
15
|
-
*/
|
|
16
|
-
declare function getASTParams(operationSchema: OperationSchema | undefined, { typed, override, }?: {
|
|
17
|
-
typed?: boolean;
|
|
18
|
-
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
19
|
-
}): FunctionParamsAST[];
|
|
20
11
|
declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
|
|
21
12
|
typed?: boolean;
|
|
22
13
|
casing?: 'camelcase';
|
|
@@ -54,8 +45,9 @@ declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise
|
|
|
54
45
|
type Props$1 = {
|
|
55
46
|
oas: Oas;
|
|
56
47
|
output: Output<Oas>;
|
|
48
|
+
config?: Config;
|
|
57
49
|
};
|
|
58
|
-
declare function getBanner({ output, oas }: Props$1): string
|
|
50
|
+
declare function getBanner({ output, oas, config }: Props$1): string;
|
|
59
51
|
|
|
60
52
|
type Props = {
|
|
61
53
|
oas: Oas;
|
|
@@ -63,4 +55,4 @@ type Props = {
|
|
|
63
55
|
};
|
|
64
56
|
declare function getFooter({ output, oas }: Props): string | undefined;
|
|
65
57
|
|
|
66
|
-
export {
|
|
58
|
+
export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, parseFromConfig };
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,21 +2,12 @@ import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1, contentType, OasT
|
|
|
2
2
|
export { isOptional } from '@kubb/oas';
|
|
3
3
|
import { FunctionParamsAST } from '@kubb/core/utils';
|
|
4
4
|
import { Params } from '@kubb/react/types';
|
|
5
|
-
import { v as OperationSchema } from './OperationGenerator-
|
|
5
|
+
import { v as OperationSchema } from './OperationGenerator-DiF6WJNP.js';
|
|
6
6
|
import { Config, Output } from '@kubb/core';
|
|
7
7
|
import '@kubb/fs/types';
|
|
8
8
|
|
|
9
9
|
declare function getComments(operation: Operation): string[];
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @deprecated
|
|
14
|
-
* TODO move to operationManager hook
|
|
15
|
-
*/
|
|
16
|
-
declare function getASTParams(operationSchema: OperationSchema | undefined, { typed, override, }?: {
|
|
17
|
-
typed?: boolean;
|
|
18
|
-
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
19
|
-
}): FunctionParamsAST[];
|
|
20
11
|
declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
|
|
21
12
|
typed?: boolean;
|
|
22
13
|
casing?: 'camelcase';
|
|
@@ -54,8 +45,9 @@ declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise
|
|
|
54
45
|
type Props$1 = {
|
|
55
46
|
oas: Oas;
|
|
56
47
|
output: Output<Oas>;
|
|
48
|
+
config?: Config;
|
|
57
49
|
};
|
|
58
|
-
declare function getBanner({ output, oas }: Props$1): string
|
|
50
|
+
declare function getBanner({ output, oas, config }: Props$1): string;
|
|
59
51
|
|
|
60
52
|
type Props = {
|
|
61
53
|
oas: Oas;
|
|
@@ -63,4 +55,4 @@ type Props = {
|
|
|
63
55
|
};
|
|
64
56
|
declare function getFooter({ output, oas }: Props): string | undefined;
|
|
65
57
|
|
|
66
|
-
export {
|
|
58
|
+
export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, parseFromConfig };
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getBanner, getComments, getFooter, getPathParams, isOptional, parseFromConfig } from './chunk-QPFZUPQA.js';
|
|
2
2
|
export { getSchemaFactory, getSchemas } from './chunk-3Y4QGY6D.js';
|
|
3
3
|
//# sourceMappingURL=utils.js.map
|
|
4
4
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Generator swagger",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
],
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "
|
|
15
|
+
"url": "https://github.com/kubb-labs/kubb.git",
|
|
16
16
|
"directory": "packages/plugin-oas"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"author": "
|
|
19
|
+
"author": "stijnvanhulle",
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
@@ -76,18 +76,18 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@stoplight/yaml": "^4.3.0",
|
|
78
78
|
"remeda": "^2.21.2",
|
|
79
|
-
"@kubb/core": "3.
|
|
80
|
-
"@kubb/fs": "3.
|
|
81
|
-
"@kubb/oas": "3.
|
|
82
|
-
"@kubb/react": "3.
|
|
79
|
+
"@kubb/core": "3.9.1",
|
|
80
|
+
"@kubb/fs": "3.9.1",
|
|
81
|
+
"@kubb/oas": "3.9.1",
|
|
82
|
+
"@kubb/react": "3.9.1"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/react": "^18.3.20",
|
|
86
86
|
"react": "^18.3.1",
|
|
87
87
|
"tsup": "^8.4.0",
|
|
88
88
|
"typescript": "^5.8.3",
|
|
89
|
-
"@kubb/config-ts": "3.
|
|
90
|
-
"@kubb/config-tsup": "3.
|
|
89
|
+
"@kubb/config-ts": "3.9.1",
|
|
90
|
+
"@kubb/config-tsup": "3.9.1"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@kubb/react": "^3.0.0"
|
package/src/SchemaGenerator.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BaseGenerator, type FileMetaBase } from '@kubb/core'
|
|
|
2
2
|
import transformers, { pascalCase } from '@kubb/core/transformers'
|
|
3
3
|
import { getUniqueName } from '@kubb/core/utils'
|
|
4
4
|
|
|
5
|
-
import { isReference } from '@kubb/oas'
|
|
5
|
+
import { isNullable, isReference } from '@kubb/oas'
|
|
6
6
|
import { isDeepEqual, isNumber, uniqueWith } from 'remeda'
|
|
7
7
|
import { isKeyword, schemaKeywords } from './SchemaMapper.ts'
|
|
8
8
|
import { getSchemaFactory } from './utils/getSchemaFactory.ts'
|
|
@@ -89,7 +89,7 @@ export class SchemaGenerator<
|
|
|
89
89
|
return uniqueWith(schemas, isDeepEqual)
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T]
|
|
92
|
+
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]> {
|
|
93
93
|
return SchemaGenerator.deepSearch<T>(tree, keyword)
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -97,7 +97,7 @@ export class SchemaGenerator<
|
|
|
97
97
|
return SchemaGenerator.find<T>(tree, keyword)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T]
|
|
100
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]> {
|
|
101
101
|
const foundItems: SchemaKeywordMapper[T][] = []
|
|
102
102
|
|
|
103
103
|
tree?.forEach((schema) => {
|
|
@@ -105,46 +105,36 @@ export class SchemaGenerator<
|
|
|
105
105
|
foundItems.push(schema as SchemaKeywordMapper[T])
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
if (schema
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Object.values(subItem.args?.properties || {}).forEach((entrySchema) => {
|
|
108
|
+
if (isKeyword(schema, schemaKeywords.object)) {
|
|
109
|
+
Object.values(schema.args?.properties || {}).forEach((entrySchema) => {
|
|
112
110
|
foundItems.push(...SchemaGenerator.deepSearch<T>(entrySchema, keyword))
|
|
113
111
|
})
|
|
114
112
|
|
|
115
|
-
Object.values(
|
|
113
|
+
Object.values(schema.args?.additionalProperties || {}).forEach((entrySchema) => {
|
|
116
114
|
foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))
|
|
117
115
|
})
|
|
118
116
|
}
|
|
119
117
|
|
|
120
|
-
if (schema
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
118
|
+
if (isKeyword(schema, schemaKeywords.array)) {
|
|
119
|
+
schema.args.items.forEach((entrySchema) => {
|
|
124
120
|
foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))
|
|
125
121
|
})
|
|
126
122
|
}
|
|
127
123
|
|
|
128
|
-
if (schema
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
subItem.args.forEach((entrySchema) => {
|
|
124
|
+
if (isKeyword(schema, schemaKeywords.and)) {
|
|
125
|
+
schema.args.forEach((entrySchema) => {
|
|
132
126
|
foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))
|
|
133
127
|
})
|
|
134
128
|
}
|
|
135
129
|
|
|
136
|
-
if (schema
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
130
|
+
if (isKeyword(schema, schemaKeywords.tuple)) {
|
|
131
|
+
schema.args.items.forEach((entrySchema) => {
|
|
140
132
|
foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))
|
|
141
133
|
})
|
|
142
134
|
}
|
|
143
135
|
|
|
144
|
-
if (schema
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
subItem.args.forEach((entrySchema) => {
|
|
136
|
+
if (isKeyword(schema, schemaKeywords.union)) {
|
|
137
|
+
schema.args.forEach((entrySchema) => {
|
|
148
138
|
foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))
|
|
149
139
|
})
|
|
150
140
|
}
|
|
@@ -161,16 +151,14 @@ export class SchemaGenerator<
|
|
|
161
151
|
foundItem = schema as SchemaKeywordMapper[T]
|
|
162
152
|
}
|
|
163
153
|
|
|
164
|
-
if (schema
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
Object.values(subItem.args?.properties || {}).forEach((entrySchema) => {
|
|
154
|
+
if (isKeyword(schema, schemaKeywords.object)) {
|
|
155
|
+
Object.values(schema.args?.properties || {}).forEach((entrySchema) => {
|
|
168
156
|
if (!foundItem) {
|
|
169
157
|
foundItem = SchemaGenerator.find<T>(entrySchema, keyword)
|
|
170
158
|
}
|
|
171
159
|
})
|
|
172
160
|
|
|
173
|
-
Object.values(
|
|
161
|
+
Object.values(schema.args?.additionalProperties || {}).forEach((entrySchema) => {
|
|
174
162
|
if (!foundItem) {
|
|
175
163
|
foundItem = SchemaGenerator.find<T>([entrySchema], keyword)
|
|
176
164
|
}
|
|
@@ -189,40 +177,32 @@ export class SchemaGenerator<
|
|
|
189
177
|
foundItem = schema as SchemaKeywordMapper[T]
|
|
190
178
|
}
|
|
191
179
|
|
|
192
|
-
if (schema
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
180
|
+
if (isKeyword(schema, schemaKeywords.array)) {
|
|
181
|
+
schema.args.items.forEach((entrySchema) => {
|
|
196
182
|
if (!foundItem) {
|
|
197
183
|
foundItem = SchemaGenerator.find<T>([entrySchema], keyword)
|
|
198
184
|
}
|
|
199
185
|
})
|
|
200
186
|
}
|
|
201
187
|
|
|
202
|
-
if (schema
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
subItem.args.forEach((entrySchema) => {
|
|
188
|
+
if (isKeyword(schema, schemaKeywords.and)) {
|
|
189
|
+
schema.args.forEach((entrySchema) => {
|
|
206
190
|
if (!foundItem) {
|
|
207
191
|
foundItem = SchemaGenerator.find<T>([entrySchema], keyword)
|
|
208
192
|
}
|
|
209
193
|
})
|
|
210
194
|
}
|
|
211
195
|
|
|
212
|
-
if (schema
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
196
|
+
if (isKeyword(schema, schemaKeywords.tuple)) {
|
|
197
|
+
schema.args.items.forEach((entrySchema) => {
|
|
216
198
|
if (!foundItem) {
|
|
217
199
|
foundItem = SchemaGenerator.find<T>([entrySchema], keyword)
|
|
218
200
|
}
|
|
219
201
|
})
|
|
220
202
|
}
|
|
221
203
|
|
|
222
|
-
if (schema
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
subItem.args.forEach((entrySchema) => {
|
|
204
|
+
if (isKeyword(schema, schemaKeywords.union)) {
|
|
205
|
+
schema.args.forEach((entrySchema) => {
|
|
226
206
|
if (!foundItem) {
|
|
227
207
|
foundItem = SchemaGenerator.find<T>([entrySchema], keyword)
|
|
228
208
|
}
|
|
@@ -397,7 +377,7 @@ export class SchemaGenerator<
|
|
|
397
377
|
]
|
|
398
378
|
const min = schema.minimum ?? schema.minLength ?? schema.minItems ?? undefined
|
|
399
379
|
const max = schema.maximum ?? schema.maxLength ?? schema.maxItems ?? undefined
|
|
400
|
-
const nullable = schema
|
|
380
|
+
const nullable = isNullable(schema)
|
|
401
381
|
const defaultNullAndNullable = schema.default === null && nullable
|
|
402
382
|
|
|
403
383
|
if (schema.default !== undefined && !defaultNullAndNullable && !Array.isArray(schema.default)) {
|
package/src/SchemaMapper.ts
CHANGED
|
@@ -9,7 +9,6 @@ export type SchemaKeywordMapper = {
|
|
|
9
9
|
strict?: boolean
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
strict: { keyword: 'strict' }
|
|
13
12
|
url: { keyword: 'url' }
|
|
14
13
|
readOnly: { keyword: 'readOnly' }
|
|
15
14
|
writeOnly: { keyword: 'writeOnly' }
|
|
@@ -88,11 +87,11 @@ export type SchemaKeywordMapper = {
|
|
|
88
87
|
schema: { keyword: 'schema'; args: { type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object'; format?: string } }
|
|
89
88
|
name: { keyword: 'name'; args: string }
|
|
90
89
|
catchall: { keyword: 'catchall' }
|
|
90
|
+
interface: { keyword: 'interface' }
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export const schemaKeywords = {
|
|
94
94
|
any: 'any',
|
|
95
|
-
strict: 'strict',
|
|
96
95
|
unknown: 'unknown',
|
|
97
96
|
number: 'number',
|
|
98
97
|
integer: 'integer',
|
|
@@ -138,6 +137,7 @@ export const schemaKeywords = {
|
|
|
138
137
|
catchall: 'catchall',
|
|
139
138
|
time: 'time',
|
|
140
139
|
name: 'name',
|
|
140
|
+
interface: 'interface',
|
|
141
141
|
} satisfies {
|
|
142
142
|
[K in keyof SchemaKeywordMapper]: SchemaKeywordMapper[K]['keyword']
|
|
143
143
|
}
|
|
@@ -159,6 +159,10 @@ export type SchemaTree = {
|
|
|
159
159
|
parent: Schema | undefined
|
|
160
160
|
current: Schema
|
|
161
161
|
siblings: Schema[]
|
|
162
|
+
/**
|
|
163
|
+
* this will be equal to the key of a property(object)
|
|
164
|
+
*/
|
|
165
|
+
name?: string
|
|
162
166
|
}
|
|
163
167
|
|
|
164
168
|
export function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]> {
|
|
@@ -25,7 +25,11 @@ export const jsonGenerator = createGenerator<PluginOas>({
|
|
|
25
25
|
value: JSON.stringify(schema.value),
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
|
-
banner: getBanner({
|
|
28
|
+
banner: getBanner({
|
|
29
|
+
oas: instance.context.oas,
|
|
30
|
+
output: plugin.options.output,
|
|
31
|
+
config: pluginManager.config,
|
|
32
|
+
}),
|
|
29
33
|
format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),
|
|
30
34
|
},
|
|
31
35
|
]
|
package/src/utils/getBanner.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { getDefaultBanner, type Config, type Output } from '@kubb/core'
|
|
2
2
|
import type { Oas } from '@kubb/oas'
|
|
3
3
|
import { isFunction } from 'remeda'
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
oas: Oas
|
|
7
7
|
output: Output<Oas>
|
|
8
|
+
config?: Config
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export function getBanner({ output, oas }: Props) {
|
|
11
|
+
export function getBanner({ output, oas, config }: Props) {
|
|
12
|
+
let banner = ''
|
|
13
|
+
if (config?.output?.defaultBanner !== false && config) {
|
|
14
|
+
const { title, description, version } = oas.api?.info || {}
|
|
15
|
+
|
|
16
|
+
banner = getDefaultBanner({ title, description, version, config })
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
if (!output.banner) {
|
|
12
|
-
return
|
|
20
|
+
return banner
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
if (isFunction(output.banner)) {
|
|
16
|
-
return output.banner(oas)
|
|
24
|
+
return `${output.banner(oas)}\n${banner}`
|
|
17
25
|
}
|
|
18
26
|
|
|
19
|
-
return output.banner
|
|
27
|
+
return `${output.banner}\n${banner}`
|
|
20
28
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getComments } from './getComments.ts'
|
|
2
|
-
export {
|
|
2
|
+
export { getPathParams } from './getParams.ts'
|
|
3
3
|
export { getSchemaFactory } from './getSchemaFactory.ts'
|
|
4
4
|
export { getSchemas } from './getSchemas.ts'
|
|
5
5
|
export { parseFromConfig } from './parseFromConfig.ts'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/getComments.ts","../src/utils/getParams.ts","../src/utils/parseFromConfig.ts","../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"names":["api","URLPath","isFunction"],"mappings":";;;;;;;;;AAKO,SAAS,YAAY,SAAgC,EAAA;AAC1D,EAAO,OAAA;AAAA,IACL,UAAU,cAAe,EAAA,IAAK,CAAgB,aAAA,EAAA,SAAA,CAAU,gBAAgB,CAAA,CAAA;AAAA,IACxE,UAAU,UAAW,EAAA,IAAK,CAAY,SAAA,EAAA,SAAA,CAAU,YAAY,CAAA,CAAA;AAAA,IAC5D,SAAA,CAAU,QAAQ,CAAU,OAAA,EAAA,IAAI,QAAQ,SAAU,CAAA,IAAI,EAAE,GAAG,CAAA,CAAA,CAAA;AAAA,IAC3D,SAAA,CAAU,cAAkB,IAAA;AAAA,GAC9B,CACG,MAAO,CAAA,OAAO,CACd,CAAA,GAAA,C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KAAM,CAAA,IAAI,GAAG,QAAQ,CAAA;AAChE;AC1BO,SAAS,SAAU,CAAA,EAAE,MAAQ,EAAA,GAAA,EAAc,EAAA;AAChD,EAAI,IAAA,CAAC,OAAO,MAAQ,EAAA;AAClB,IAAO,OAAA,MAAA;AAAA;AAGT,EAAI,IAAA,UAAA,CAAW,MAAO,CAAA,MAAM,CAAG,EAAA;AAC7B,IAAO,OAAA,MAAA,CAAO,OAAO,GAAG,CAAA;AAAA;AAG1B,EAAA,OAAO,MAAO,CAAA,MAAA;AAChB;ACVO,SAAS,SAAU,CAAA,EAAE,MAAQ,EAAA,GAAA,EAAc,EAAA;AAChD,EAAI,IAAA,CAAC,OAAO,MAAQ,EAAA;AAClB,IAAO,OAAA,MAAA;AAAA;AAGT,EAAIC,IAAAA,UAAAA,CAAW,MAAO,CAAA,MAAM,CAAG,EAAA;AAC7B,IAAO,OAAA,MAAA,CAAO,OAAO,GAAG,CAAA;AAAA;AAG1B,EAAA,OAAO,MAAO,CAAA,MAAA;AAChB","file":"chunk-3DX5ALTN.js","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport { camelCase, isValidVarName } from '@kubb/core/transformers'\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = isValidVarName(curr.name) ? curr.name : camelCase(curr.name)\n\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","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","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props = {\n oas: Oas\n output: Output<Oas>\n}\n\nexport function getBanner({ output, oas }: Props) {\n if (!output.banner) {\n return undefined\n }\n\n if (isFunction(output.banner)) {\n return output.banner(oas)\n }\n\n return output.banner\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props = {\n oas: Oas\n output: Output<Oas>\n}\n\nexport function getFooter({ output, oas }: Props) {\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"]}
|
|
@@ -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,S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AAA,EAAM,SAAU,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,SAAU,CAAA,EAAE,GAAK,EAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,EAAK,MAAQ,EAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,EAAQ,CAAA;AAAA,QAC9E,MAAA,EAAQ,SAAU,CAAA,EAAE,GAAK,EAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,EAAK,MAAQ,EAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,EAAQ;AAAA;AAChF,KACF;AAAA;AAEJ,CAAC","file":"chunk-EMSV6TX2.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 { getBanner, getFooter } from '@kubb/plugin-oas/utils'\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: getBanner({ oas: instance.context.oas, output: plugin.options.output }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":["createRoot","App","jsx","Oas","camelCase","getBanner","getFooter"],"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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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 { getBanner, getFooter } from '@kubb/plugin-oas/utils'\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: getBanner({ oas: instance.context.oas, output: plugin.options.output }),\n format: getFooter({ oas: instance.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"]}
|