@kubb/plugin-oas 3.0.0-alpha.9 → 3.0.0-beta.2
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/README.md +14 -5
- package/dist/OperationGenerator-BgQeGRzk.d.cts +550 -0
- package/dist/OperationGenerator-BgQeGRzk.d.ts +550 -0
- package/dist/{Schema-B1vcPGiK.d.ts → Schema-1iM2I0dK.d.ts} +1 -12
- package/dist/{Schema-DoSFh7Qd.d.cts → Schema-5o-c5UOy.d.cts} +1 -12
- package/dist/chunk-ABOQ73FL.cjs +36 -0
- package/dist/chunk-ABOQ73FL.cjs.map +1 -0
- package/dist/chunk-BG77DP54.js +30 -0
- package/dist/chunk-BG77DP54.js.map +1 -0
- package/dist/chunk-GF26SDHQ.js +28 -0
- package/dist/chunk-GF26SDHQ.js.map +1 -0
- package/dist/chunk-PADR76WZ.cjs +4 -0
- package/dist/chunk-PADR76WZ.cjs.map +1 -0
- package/dist/chunk-QAFBZLJA.cjs +48 -0
- package/dist/chunk-QAFBZLJA.cjs.map +1 -0
- package/dist/chunk-QT6ZFRNJ.cjs +752 -0
- package/dist/chunk-QT6ZFRNJ.cjs.map +1 -0
- package/dist/chunk-QWO5NQGQ.js +88 -0
- package/dist/chunk-QWO5NQGQ.js.map +1 -0
- package/dist/chunk-R47XMJ32.js +3 -0
- package/dist/chunk-R47XMJ32.js.map +1 -0
- package/dist/chunk-SR63CBLH.cjs +92 -0
- package/dist/chunk-SR63CBLH.cjs.map +1 -0
- package/dist/chunk-V2JO6RHI.js +744 -0
- package/dist/chunk-V2JO6RHI.js.map +1 -0
- package/dist/chunk-XNCEFOE6.js +45 -0
- package/dist/chunk-XNCEFOE6.js.map +1 -0
- package/dist/chunk-ZWHQ54JM.cjs +32 -0
- package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
- package/dist/components.cjs +20 -12
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +3 -6
- package/dist/components.d.ts +3 -6
- package/dist/components.js +3 -12
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +14 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +9 -0
- package/dist/generators.d.ts +9 -0
- package/dist/generators.js +5 -0
- package/dist/generators.js.map +1 -0
- package/dist/hooks.cjs +102 -57
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +41 -10
- package/dist/hooks.d.ts +41 -10
- package/dist/hooks.js +91 -53
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +134 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +68 -146
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +32 -45
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +4 -13
- package/dist/utils.d.ts +4 -13
- package/dist/utils.js +8 -44
- package/dist/utils.js.map +1 -1
- package/package.json +20 -14
- package/src/OperationGenerator.ts +11 -23
- package/src/SchemaGenerator.ts +68 -9
- package/src/SchemaMapper.ts +6 -4
- package/src/components/Schema.tsx +1 -99
- package/src/generator.tsx +22 -18
- package/src/generators/index.ts +1 -0
- package/src/generators/jsonGenerator.ts +32 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useOperationManager.ts +77 -30
- package/src/hooks/useSchemaManager.ts +77 -0
- package/src/plugin.ts +69 -56
- package/src/types.ts +24 -18
- package/src/utils/getParams.ts +1 -1
- package/src/utils/getSchemaFactory.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/parseFromConfig.ts +7 -7
- package/dist/OperationGenerator-By5WOmWB.d.ts +0 -165
- package/dist/OperationGenerator-Gd1X7wUz.d.cts +0 -165
- package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
- package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
- package/dist/chunk-75BIOXB7.cjs +0 -7
- package/dist/chunk-75BIOXB7.cjs.map +0 -1
- package/dist/chunk-IAUV3UKH.cjs +0 -3965
- package/dist/chunk-IAUV3UKH.cjs.map +0 -1
- package/dist/chunk-M347763D.js +0 -3965
- package/dist/chunk-M347763D.js.map +0 -1
- package/dist/chunk-N7EEVJA6.js +0 -35
- package/dist/chunk-N7EEVJA6.js.map +0 -1
- package/dist/chunk-NU4F7G47.cjs +0 -89
- package/dist/chunk-NU4F7G47.cjs.map +0 -1
- package/dist/chunk-O76YQFZB.cjs +0 -35
- package/dist/chunk-O76YQFZB.cjs.map +0 -1
- package/dist/chunk-SQ64ESS4.js +0 -7
- package/dist/chunk-SQ64ESS4.js.map +0 -1
- package/dist/chunk-SZDO532A.js +0 -89
- package/dist/chunk-SZDO532A.js.map +0 -1
- package/dist/types-CZTUCaE5.d.cts +0 -145
- package/dist/types-CZTUCaE5.d.ts +0 -145
- package/src/utils/refSorter.ts +0 -13
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkABOQ73FL_cjs = require('./chunk-ABOQ73FL.cjs');
|
|
4
|
+
var chunkSR63CBLH_cjs = require('./chunk-SR63CBLH.cjs');
|
|
5
|
+
require('./chunk-PADR76WZ.cjs');
|
|
6
|
+
var chunkQT6ZFRNJ_cjs = require('./chunk-QT6ZFRNJ.cjs');
|
|
7
|
+
var chunkQAFBZLJA_cjs = require('./chunk-QAFBZLJA.cjs');
|
|
8
|
+
require('./chunk-ZWHQ54JM.cjs');
|
|
9
|
+
var core = require('@kubb/core');
|
|
10
|
+
var transformers = require('@kubb/core/transformers');
|
|
11
|
+
var path = require('path');
|
|
5
12
|
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
14
|
|
|
15
|
+
var transformers__default = /*#__PURE__*/_interopDefault(transformers);
|
|
16
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
7
17
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _chunkIAUV3UKHcjs = require('./chunk-IAUV3UKH.cjs');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
|
|
17
|
-
|
|
18
|
-
// src/index.ts
|
|
19
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
20
|
-
|
|
21
|
-
// src/OperationGenerator.ts
|
|
22
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
23
|
-
var _core = require('@kubb/core');
|
|
24
|
-
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
25
|
-
var OperationGenerator = class extends _core.BaseGenerator {
|
|
18
|
+
var OperationGenerator = class extends core.BaseGenerator {
|
|
26
19
|
#operationsByMethod = {};
|
|
27
20
|
get operationsByMethod() {
|
|
28
21
|
return this.#operationsByMethod;
|
|
@@ -32,9 +25,9 @@ var OperationGenerator = class extends _core.BaseGenerator {
|
|
|
32
25
|
}
|
|
33
26
|
#getOptions(operation, method) {
|
|
34
27
|
const { override = [] } = this.context;
|
|
35
|
-
return
|
|
28
|
+
return override.find(({ pattern, type }) => {
|
|
36
29
|
if (type === "tag") {
|
|
37
|
-
return !!
|
|
30
|
+
return !!operation.getTags()[0]?.name.match(pattern);
|
|
38
31
|
}
|
|
39
32
|
if (type === "operationId") {
|
|
40
33
|
return !!operation.getOperationId().match(pattern);
|
|
@@ -46,18 +39,14 @@ var OperationGenerator = class extends _core.BaseGenerator {
|
|
|
46
39
|
return !!method.match(pattern);
|
|
47
40
|
}
|
|
48
41
|
return false;
|
|
49
|
-
})
|
|
42
|
+
})?.options || {};
|
|
50
43
|
}
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
* @deprecated
|
|
54
|
-
*/
|
|
55
44
|
#isExcluded(operation, method) {
|
|
56
45
|
const { exclude = [] } = this.context;
|
|
57
46
|
let matched = false;
|
|
58
47
|
exclude.forEach(({ pattern, type }) => {
|
|
59
48
|
if (type === "tag" && !matched) {
|
|
60
|
-
matched = !!
|
|
49
|
+
matched = !!operation.getTags()[0]?.name.match(pattern);
|
|
61
50
|
}
|
|
62
51
|
if (type === "operationId" && !matched) {
|
|
63
52
|
matched = !!operation.getOperationId().match(pattern);
|
|
@@ -71,16 +60,12 @@ var OperationGenerator = class extends _core.BaseGenerator {
|
|
|
71
60
|
});
|
|
72
61
|
return matched;
|
|
73
62
|
}
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* @deprecated
|
|
77
|
-
*/
|
|
78
63
|
#isIncluded(operation, method) {
|
|
79
64
|
const { include = [] } = this.context;
|
|
80
65
|
let matched = false;
|
|
81
66
|
include.forEach(({ pattern, type }) => {
|
|
82
67
|
if (type === "tag" && !matched) {
|
|
83
|
-
matched = !!
|
|
68
|
+
matched = !!operation.getTags()[0]?.name.match(pattern);
|
|
84
69
|
}
|
|
85
70
|
if (type === "operationId" && !matched) {
|
|
86
71
|
matched = !!operation.getOperationId().match(pattern);
|
|
@@ -95,14 +80,13 @@ var OperationGenerator = class extends _core.BaseGenerator {
|
|
|
95
80
|
return matched;
|
|
96
81
|
}
|
|
97
82
|
getSchemas(operation, {
|
|
98
|
-
forStatusCode,
|
|
99
83
|
resolveName = (name) => name
|
|
100
84
|
} = {}) {
|
|
101
85
|
const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
|
|
102
86
|
const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
|
|
103
87
|
const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
|
|
104
88
|
const requestSchema = this.context.oas.getRequestSchema(operation);
|
|
105
|
-
const responseStatusCode =
|
|
89
|
+
const responseStatusCode = operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
|
|
106
90
|
const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode);
|
|
107
91
|
const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
|
|
108
92
|
let name = statusCode;
|
|
@@ -111,63 +95,63 @@ var OperationGenerator = class extends _core.BaseGenerator {
|
|
|
111
95
|
}
|
|
112
96
|
const schema = this.context.oas.getResponseSchema(operation, statusCode);
|
|
113
97
|
return {
|
|
114
|
-
name: resolveName(
|
|
115
|
-
description:
|
|
98
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${name}`)),
|
|
99
|
+
description: operation.getResponseByStatusCode(statusCode)?.description,
|
|
116
100
|
schema,
|
|
117
101
|
operation,
|
|
118
|
-
operationName:
|
|
102
|
+
operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
|
|
119
103
|
statusCode: name === "error" ? void 0 : Number(statusCode),
|
|
120
|
-
keys:
|
|
104
|
+
keys: schema?.properties ? Object.keys(schema.properties) : void 0
|
|
121
105
|
};
|
|
122
106
|
});
|
|
123
107
|
return {
|
|
124
108
|
pathParams: pathParamsSchema ? {
|
|
125
|
-
name: resolveName(
|
|
109
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} PathParams`)),
|
|
126
110
|
operation,
|
|
127
|
-
operationName:
|
|
111
|
+
operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
|
|
128
112
|
schema: pathParamsSchema,
|
|
129
113
|
keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
|
|
130
114
|
} : void 0,
|
|
131
115
|
queryParams: queryParamsSchema ? {
|
|
132
|
-
name: resolveName(
|
|
116
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
|
|
133
117
|
operation,
|
|
134
|
-
operationName:
|
|
118
|
+
operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
|
|
135
119
|
schema: queryParamsSchema,
|
|
136
120
|
keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
|
|
137
121
|
} : void 0,
|
|
138
122
|
headerParams: headerParamsSchema ? {
|
|
139
|
-
name: resolveName(
|
|
123
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
|
|
140
124
|
operation,
|
|
141
|
-
operationName:
|
|
125
|
+
operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
|
|
142
126
|
schema: headerParamsSchema,
|
|
143
127
|
keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
|
|
144
128
|
} : void 0,
|
|
145
129
|
request: requestSchema ? {
|
|
146
|
-
name: resolveName(
|
|
147
|
-
description:
|
|
130
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
|
|
131
|
+
description: operation.schema.requestBody?.description,
|
|
148
132
|
operation,
|
|
149
|
-
operationName:
|
|
133
|
+
operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
|
|
150
134
|
schema: requestSchema,
|
|
151
135
|
keys: requestSchema.properties ? Object.keys(requestSchema.properties) : void 0,
|
|
152
136
|
keysToOmit: requestSchema.properties ? Object.keys(requestSchema.properties).filter((key) => {
|
|
153
|
-
const item =
|
|
154
|
-
return
|
|
137
|
+
const item = requestSchema.properties?.[key];
|
|
138
|
+
return item?.readOnly;
|
|
155
139
|
}) : void 0
|
|
156
140
|
} : void 0,
|
|
157
141
|
response: {
|
|
158
|
-
name: resolveName(
|
|
159
|
-
description:
|
|
142
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
|
|
143
|
+
description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,
|
|
160
144
|
operation,
|
|
161
|
-
operationName:
|
|
145
|
+
operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
|
|
162
146
|
schema: responseSchema,
|
|
163
147
|
statusCode: Number(responseStatusCode),
|
|
164
|
-
keys:
|
|
165
|
-
keysToOmit:
|
|
166
|
-
const item =
|
|
167
|
-
return
|
|
148
|
+
keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : void 0,
|
|
149
|
+
keysToOmit: responseSchema?.properties ? Object.keys(responseSchema.properties).filter((key) => {
|
|
150
|
+
const item = responseSchema.properties?.[key];
|
|
151
|
+
return item?.writeOnly;
|
|
168
152
|
}) : void 0
|
|
169
153
|
},
|
|
170
|
-
errors: statusCodes.filter((item) =>
|
|
154
|
+
errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5")),
|
|
171
155
|
statusCodes
|
|
172
156
|
};
|
|
173
157
|
}
|
|
@@ -201,14 +185,14 @@ var OperationGenerator = class extends _core.BaseGenerator {
|
|
|
201
185
|
const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
|
|
202
186
|
const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
|
|
203
187
|
methods.forEach((method) => {
|
|
204
|
-
const { operation } =
|
|
188
|
+
const { operation } = this.operationsByMethod[path2]?.[method];
|
|
205
189
|
const options = this.#getOptions(operation, method);
|
|
206
190
|
const methodToCall = this[method];
|
|
207
191
|
if (typeof methodToCall === "function") {
|
|
208
|
-
const promiseMethod =
|
|
192
|
+
const promiseMethod = methodToCall?.call(this, operation, {
|
|
209
193
|
...this.options,
|
|
210
194
|
...options
|
|
211
|
-
})
|
|
195
|
+
});
|
|
212
196
|
if (promiseMethod) {
|
|
213
197
|
acc.push(promiseMethod);
|
|
214
198
|
}
|
|
@@ -220,35 +204,35 @@ var OperationGenerator = class extends _core.BaseGenerator {
|
|
|
220
204
|
if (promiseOperation) {
|
|
221
205
|
acc.push(promiseOperation);
|
|
222
206
|
}
|
|
223
|
-
|
|
224
|
-
const promise =
|
|
207
|
+
generators?.forEach((generator) => {
|
|
208
|
+
const promise = generator.operation?.({
|
|
225
209
|
instance: this,
|
|
226
210
|
operation,
|
|
227
211
|
options: {
|
|
228
212
|
...this.options,
|
|
229
213
|
...options
|
|
230
214
|
}
|
|
231
|
-
})
|
|
215
|
+
});
|
|
232
216
|
if (promise) {
|
|
233
217
|
acc.push(promise);
|
|
234
218
|
}
|
|
235
|
-
})
|
|
219
|
+
});
|
|
236
220
|
});
|
|
237
221
|
return acc;
|
|
238
222
|
}, []);
|
|
239
223
|
const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
|
|
240
224
|
promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
|
|
241
|
-
|
|
242
|
-
const promise =
|
|
225
|
+
generators?.forEach((generator) => {
|
|
226
|
+
const promise = generator.operations?.({
|
|
243
227
|
instance: this,
|
|
244
228
|
operations: operations.flat().filter(Boolean),
|
|
245
229
|
operationsByMethod: this.operationsByMethod,
|
|
246
230
|
options: this.options
|
|
247
|
-
})
|
|
231
|
+
});
|
|
248
232
|
if (promise) {
|
|
249
233
|
promises.push(promise);
|
|
250
234
|
}
|
|
251
|
-
})
|
|
235
|
+
});
|
|
252
236
|
const files = await Promise.all(promises);
|
|
253
237
|
return files.flat().filter(Boolean);
|
|
254
238
|
}
|
|
@@ -295,164 +279,129 @@ var OperationGenerator = class extends _core.BaseGenerator {
|
|
|
295
279
|
return [];
|
|
296
280
|
}
|
|
297
281
|
};
|
|
298
|
-
|
|
299
|
-
// src/plugin.ts
|
|
300
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
301
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
302
|
-
|
|
303
|
-
|
|
304
282
|
var pluginOasName = "plugin-oas";
|
|
305
|
-
var pluginOas =
|
|
283
|
+
var pluginOas = core.createPlugin((options) => {
|
|
306
284
|
const {
|
|
307
|
-
output = {
|
|
308
|
-
|
|
309
|
-
|
|
285
|
+
output = {
|
|
286
|
+
path: "schemas"
|
|
287
|
+
},
|
|
310
288
|
validate = true,
|
|
289
|
+
generators = [chunkSR63CBLH_cjs.jsonGenerator],
|
|
311
290
|
serverIndex = 0,
|
|
312
291
|
contentType,
|
|
313
292
|
oasClass
|
|
314
293
|
} = options;
|
|
315
|
-
const getOas = async ({ config, logger
|
|
294
|
+
const getOas = async ({ config, logger }) => {
|
|
316
295
|
try {
|
|
317
|
-
const oas = await
|
|
296
|
+
const oas = await chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
|
|
318
297
|
if (validate) {
|
|
319
298
|
await oas.valdiate();
|
|
320
299
|
}
|
|
321
300
|
return oas;
|
|
322
301
|
} catch (e) {
|
|
323
302
|
const error = e;
|
|
324
|
-
logger.emit("warning",
|
|
325
|
-
return
|
|
303
|
+
logger.emit("warning", error?.message);
|
|
304
|
+
return chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
|
|
326
305
|
}
|
|
327
306
|
};
|
|
328
307
|
return {
|
|
329
308
|
name: pluginOasName,
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
} : {
|
|
334
|
-
exportType: "barrelNamed",
|
|
335
|
-
...output
|
|
309
|
+
options: {
|
|
310
|
+
output,
|
|
311
|
+
...options
|
|
336
312
|
},
|
|
337
|
-
options,
|
|
338
313
|
context() {
|
|
339
314
|
const { config, logger } = this;
|
|
340
315
|
return {
|
|
341
|
-
getOas(
|
|
342
|
-
return getOas({ config, logger
|
|
316
|
+
getOas() {
|
|
317
|
+
return getOas({ config, logger });
|
|
343
318
|
},
|
|
344
319
|
async getSchemas({ includes } = {}) {
|
|
345
320
|
const oas = await this.getOas();
|
|
346
|
-
return
|
|
321
|
+
return chunkQAFBZLJA_cjs.getSchemas({ oas, contentType, includes });
|
|
347
322
|
},
|
|
348
323
|
async getBaseURL() {
|
|
349
324
|
const oasInstance = await this.getOas();
|
|
350
|
-
|
|
351
|
-
return baseURL;
|
|
325
|
+
return oasInstance.api.servers?.at(serverIndex)?.url;
|
|
352
326
|
},
|
|
353
327
|
contentType
|
|
354
328
|
};
|
|
355
329
|
},
|
|
330
|
+
resolvePath(baseName, pathMode, options2) {
|
|
331
|
+
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
332
|
+
const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
333
|
+
if (mode === "single") {
|
|
334
|
+
return path__default.default.resolve(root, output.path);
|
|
335
|
+
}
|
|
336
|
+
return path__default.default.resolve(root, output.path, baseName);
|
|
337
|
+
},
|
|
356
338
|
async buildStart() {
|
|
357
339
|
if (!output) {
|
|
358
340
|
return;
|
|
359
341
|
}
|
|
360
342
|
const oas = await getOas({
|
|
361
343
|
config: this.config,
|
|
362
|
-
logger: this.logger
|
|
363
|
-
formatOptions: {
|
|
364
|
-
filterSet: filter,
|
|
365
|
-
sortSet: sort
|
|
366
|
-
}
|
|
344
|
+
logger: this.logger
|
|
367
345
|
});
|
|
368
346
|
await oas.dereference();
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
]
|
|
388
|
-
});
|
|
389
|
-
};
|
|
390
|
-
const promises = Object.entries(schemas).map(mapSchema);
|
|
391
|
-
await Promise.all(promises);
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
// src/generator.tsx
|
|
397
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
398
|
-
var import_jsx_runtime = _chunkNU4F7G47cjs.__toESM.call(void 0, _chunkIAUV3UKHcjs.require_jsx_runtime.call(void 0, ), 1);
|
|
399
|
-
var _react = require('@kubb/react');
|
|
400
|
-
function createGenerator(parseOptions) {
|
|
401
|
-
return parseOptions;
|
|
402
|
-
}
|
|
403
|
-
function createReactGenerator(parseOptions) {
|
|
404
|
-
return {
|
|
405
|
-
...parseOptions,
|
|
406
|
-
async operations({ instance, options, operations, operationsByMethod }) {
|
|
407
|
-
if (!parseOptions.Operations) {
|
|
408
|
-
return [];
|
|
409
|
-
}
|
|
410
|
-
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
411
|
-
const root = _react.createRoot.call(void 0, {
|
|
412
|
-
logger: pluginManager.logger
|
|
413
|
-
});
|
|
414
|
-
root.render(
|
|
415
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
|
|
416
|
-
);
|
|
417
|
-
return root.files;
|
|
418
|
-
},
|
|
419
|
-
async operation({ instance, operation, options }) {
|
|
420
|
-
if (!parseOptions.Operation) {
|
|
421
|
-
return [];
|
|
422
|
-
}
|
|
423
|
-
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
424
|
-
const root = _react.createRoot.call(void 0, {
|
|
425
|
-
logger: pluginManager.logger
|
|
426
|
-
});
|
|
427
|
-
root.render(
|
|
428
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
|
|
347
|
+
const schemaGenerator = new chunkQT6ZFRNJ_cjs.SchemaGenerator(
|
|
348
|
+
{
|
|
349
|
+
unknownType: "unknown",
|
|
350
|
+
dateType: "date",
|
|
351
|
+
transformers: {},
|
|
352
|
+
...this.plugin.options
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
oas,
|
|
356
|
+
pluginManager: this.pluginManager,
|
|
357
|
+
plugin: this.plugin,
|
|
358
|
+
contentType,
|
|
359
|
+
include: void 0,
|
|
360
|
+
override: void 0,
|
|
361
|
+
mode: "split",
|
|
362
|
+
output: output.path
|
|
363
|
+
}
|
|
429
364
|
);
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
365
|
+
const schemaFiles = await schemaGenerator.build(...generators);
|
|
366
|
+
await this.addFile(...schemaFiles);
|
|
367
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
368
|
+
oas,
|
|
369
|
+
pluginManager: this.pluginManager,
|
|
370
|
+
plugin: this.plugin,
|
|
371
|
+
contentType,
|
|
372
|
+
exclude: void 0,
|
|
373
|
+
include: void 0,
|
|
374
|
+
override: void 0,
|
|
375
|
+
mode: "split"
|
|
439
376
|
});
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
|
|
443
|
-
);
|
|
444
|
-
return root.files;
|
|
377
|
+
const operationFiles = await operationGenerator.build(...generators);
|
|
378
|
+
await this.addFile(...operationFiles);
|
|
445
379
|
}
|
|
446
380
|
};
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
381
|
+
});
|
|
456
382
|
|
|
457
|
-
|
|
383
|
+
Object.defineProperty(exports, "createGenerator", {
|
|
384
|
+
enumerable: true,
|
|
385
|
+
get: function () { return chunkSR63CBLH_cjs.createGenerator; }
|
|
386
|
+
});
|
|
387
|
+
Object.defineProperty(exports, "createReactGenerator", {
|
|
388
|
+
enumerable: true,
|
|
389
|
+
get: function () { return chunkSR63CBLH_cjs.createReactGenerator; }
|
|
390
|
+
});
|
|
391
|
+
Object.defineProperty(exports, "SchemaGenerator", {
|
|
392
|
+
enumerable: true,
|
|
393
|
+
get: function () { return chunkQT6ZFRNJ_cjs.SchemaGenerator; }
|
|
394
|
+
});
|
|
395
|
+
Object.defineProperty(exports, "isKeyword", {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: function () { return chunkQT6ZFRNJ_cjs.isKeyword; }
|
|
398
|
+
});
|
|
399
|
+
Object.defineProperty(exports, "schemaKeywords", {
|
|
400
|
+
enumerable: true,
|
|
401
|
+
get: function () { return chunkQT6ZFRNJ_cjs.schemaKeywords; }
|
|
402
|
+
});
|
|
403
|
+
exports.OperationGenerator = OperationGenerator;
|
|
404
|
+
exports.pluginOas = pluginOas;
|
|
405
|
+
exports.pluginOasName = pluginOasName;
|
|
406
|
+
//# sourceMappingURL=index.cjs.map
|
|
458
407
|
//# sourceMappingURL=index.cjs.map
|