@kubb/plugin-oas 3.0.0-alpha.8 → 3.0.0-beta.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/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 +137 -187
- 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 +76 -153
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +32 -41
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +5 -13
- package/dist/utils.d.ts +5 -13
- package/dist/utils.js +8 -40
- package/dist/utils.js.map +1 -1
- package/package.json +20 -14
- package/src/OperationGenerator.ts +23 -30
- package/src/SchemaGenerator.ts +79 -22
- package/src/SchemaMapper.ts +6 -4
- package/src/components/Schema.tsx +1 -99
- package/src/{parser.tsx → generator.tsx} +30 -22
- 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/index.ts +3 -3
- 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 +2 -1
- package/src/utils/parseFromConfig.ts +7 -7
- package/dist/OperationGenerator-DeXrfGDC.d.ts +0 -158
- package/dist/OperationGenerator-DhJ0MBKc.d.cts +0 -158
- 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-MUI5DWM3.js +0 -3966
- package/dist/chunk-MUI5DWM3.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/chunk-VSVVTCQB.cjs +0 -3966
- package/dist/chunk-VSVVTCQB.cjs.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 _chunkVSVVTCQBcjs = require('./chunk-VSVVTCQB.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.Generator {
|
|
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.Generator {
|
|
|
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.Generator {
|
|
|
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.Generator {
|
|
|
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.Generator {
|
|
|
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,74 +95,75 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
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
|
}
|
|
174
|
-
|
|
158
|
+
#methods = ["get", "post", "patch", "put", "delete"];
|
|
159
|
+
async build(...generators) {
|
|
175
160
|
const { oas } = this.context;
|
|
176
161
|
const paths = oas.getPaths();
|
|
177
162
|
this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
|
|
178
163
|
const methods = Object.keys(method);
|
|
179
164
|
methods.forEach((method2) => {
|
|
180
165
|
const operation = oas.operation(path2, method2);
|
|
181
|
-
if (operation) {
|
|
166
|
+
if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
|
|
182
167
|
const isExcluded = this.#isExcluded(operation, method2);
|
|
183
168
|
const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
|
|
184
169
|
if (isIncluded && !isExcluded) {
|
|
@@ -200,14 +185,14 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
200
185
|
const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
|
|
201
186
|
const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
|
|
202
187
|
methods.forEach((method) => {
|
|
203
|
-
const { operation } =
|
|
188
|
+
const { operation } = this.operationsByMethod[path2]?.[method];
|
|
204
189
|
const options = this.#getOptions(operation, method);
|
|
205
190
|
const methodToCall = this[method];
|
|
206
191
|
if (typeof methodToCall === "function") {
|
|
207
|
-
const promiseMethod =
|
|
192
|
+
const promiseMethod = methodToCall?.call(this, operation, {
|
|
208
193
|
...this.options,
|
|
209
194
|
...options
|
|
210
|
-
})
|
|
195
|
+
});
|
|
211
196
|
if (promiseMethod) {
|
|
212
197
|
acc.push(promiseMethod);
|
|
213
198
|
}
|
|
@@ -219,35 +204,35 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
219
204
|
if (promiseOperation) {
|
|
220
205
|
acc.push(promiseOperation);
|
|
221
206
|
}
|
|
222
|
-
|
|
223
|
-
const promise =
|
|
207
|
+
generators?.forEach((generator) => {
|
|
208
|
+
const promise = generator.operation?.({
|
|
224
209
|
instance: this,
|
|
225
210
|
operation,
|
|
226
211
|
options: {
|
|
227
212
|
...this.options,
|
|
228
213
|
...options
|
|
229
214
|
}
|
|
230
|
-
})
|
|
215
|
+
});
|
|
231
216
|
if (promise) {
|
|
232
217
|
acc.push(promise);
|
|
233
218
|
}
|
|
234
|
-
})
|
|
219
|
+
});
|
|
235
220
|
});
|
|
236
221
|
return acc;
|
|
237
222
|
}, []);
|
|
238
223
|
const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
|
|
239
224
|
promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
|
|
240
|
-
|
|
241
|
-
const promise =
|
|
225
|
+
generators?.forEach((generator) => {
|
|
226
|
+
const promise = generator.operations?.({
|
|
242
227
|
instance: this,
|
|
243
228
|
operations: operations.flat().filter(Boolean),
|
|
244
229
|
operationsByMethod: this.operationsByMethod,
|
|
245
230
|
options: this.options
|
|
246
|
-
})
|
|
231
|
+
});
|
|
247
232
|
if (promise) {
|
|
248
233
|
promises.push(promise);
|
|
249
234
|
}
|
|
250
|
-
})
|
|
235
|
+
});
|
|
251
236
|
const files = await Promise.all(promises);
|
|
252
237
|
return files.flat().filter(Boolean);
|
|
253
238
|
}
|
|
@@ -294,164 +279,129 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
294
279
|
return [];
|
|
295
280
|
}
|
|
296
281
|
};
|
|
297
|
-
|
|
298
|
-
// src/plugin.ts
|
|
299
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
300
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
301
|
-
|
|
302
|
-
|
|
303
282
|
var pluginOasName = "plugin-oas";
|
|
304
|
-
var pluginOas =
|
|
283
|
+
var pluginOas = core.createPlugin((options) => {
|
|
305
284
|
const {
|
|
306
|
-
output = {
|
|
307
|
-
|
|
308
|
-
|
|
285
|
+
output = {
|
|
286
|
+
path: "schemas"
|
|
287
|
+
},
|
|
309
288
|
validate = true,
|
|
289
|
+
generators = [chunkSR63CBLH_cjs.jsonGenerator],
|
|
310
290
|
serverIndex = 0,
|
|
311
291
|
contentType,
|
|
312
292
|
oasClass
|
|
313
293
|
} = options;
|
|
314
|
-
const getOas = async ({ config, logger
|
|
294
|
+
const getOas = async ({ config, logger }) => {
|
|
315
295
|
try {
|
|
316
|
-
const oas = await
|
|
296
|
+
const oas = await chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
|
|
317
297
|
if (validate) {
|
|
318
298
|
await oas.valdiate();
|
|
319
299
|
}
|
|
320
300
|
return oas;
|
|
321
301
|
} catch (e) {
|
|
322
302
|
const error = e;
|
|
323
|
-
logger.emit("warning",
|
|
324
|
-
return
|
|
303
|
+
logger.emit("warning", error?.message);
|
|
304
|
+
return chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
|
|
325
305
|
}
|
|
326
306
|
};
|
|
327
307
|
return {
|
|
328
308
|
name: pluginOasName,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
} : {
|
|
333
|
-
exportType: "barrelNamed",
|
|
334
|
-
...output
|
|
309
|
+
options: {
|
|
310
|
+
output,
|
|
311
|
+
...options
|
|
335
312
|
},
|
|
336
|
-
options,
|
|
337
313
|
context() {
|
|
338
314
|
const { config, logger } = this;
|
|
339
315
|
return {
|
|
340
|
-
getOas(
|
|
341
|
-
return getOas({ config, logger
|
|
316
|
+
getOas() {
|
|
317
|
+
return getOas({ config, logger });
|
|
342
318
|
},
|
|
343
319
|
async getSchemas({ includes } = {}) {
|
|
344
320
|
const oas = await this.getOas();
|
|
345
|
-
return
|
|
321
|
+
return chunkQAFBZLJA_cjs.getSchemas({ oas, contentType, includes });
|
|
346
322
|
},
|
|
347
323
|
async getBaseURL() {
|
|
348
324
|
const oasInstance = await this.getOas();
|
|
349
|
-
|
|
350
|
-
return baseURL;
|
|
325
|
+
return oasInstance.api.servers?.at(serverIndex)?.url;
|
|
351
326
|
},
|
|
352
327
|
contentType
|
|
353
328
|
};
|
|
354
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
|
+
},
|
|
355
338
|
async buildStart() {
|
|
356
339
|
if (!output) {
|
|
357
340
|
return;
|
|
358
341
|
}
|
|
359
342
|
const oas = await getOas({
|
|
360
343
|
config: this.config,
|
|
361
|
-
logger: this.logger
|
|
362
|
-
formatOptions: {
|
|
363
|
-
filterSet: filter,
|
|
364
|
-
sortSet: sort
|
|
365
|
-
}
|
|
344
|
+
logger: this.logger
|
|
366
345
|
});
|
|
367
346
|
await oas.dereference();
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
]
|
|
387
|
-
});
|
|
388
|
-
};
|
|
389
|
-
const promises = Object.entries(schemas).map(mapSchema);
|
|
390
|
-
await Promise.all(promises);
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// src/parser.tsx
|
|
396
|
-
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
397
|
-
var _react = require('@kubb/react');
|
|
398
|
-
var import_jsx_runtime = _chunkNU4F7G47cjs.__toESM.call(void 0, _chunkVSVVTCQBcjs.require_jsx_runtime.call(void 0, ), 1);
|
|
399
|
-
function createParser(parseOptions) {
|
|
400
|
-
return parseOptions;
|
|
401
|
-
}
|
|
402
|
-
function createReactParser(parseOptions) {
|
|
403
|
-
return {
|
|
404
|
-
...parseOptions,
|
|
405
|
-
async operations({ instance, options, operations, operationsByMethod }) {
|
|
406
|
-
if (!parseOptions.Operations) {
|
|
407
|
-
return [];
|
|
408
|
-
}
|
|
409
|
-
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
410
|
-
const root = _react.createRoot.call(void 0, {
|
|
411
|
-
logger: pluginManager.logger
|
|
412
|
-
});
|
|
413
|
-
root.render(
|
|
414
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
|
|
415
|
-
);
|
|
416
|
-
return root.files;
|
|
417
|
-
},
|
|
418
|
-
async operation({ instance, operation, options }) {
|
|
419
|
-
if (!parseOptions.Operation) {
|
|
420
|
-
return [];
|
|
421
|
-
}
|
|
422
|
-
const { pluginManager, oas, plugin, mode } = instance.context;
|
|
423
|
-
const root = _react.createRoot.call(void 0, {
|
|
424
|
-
logger: pluginManager.logger
|
|
425
|
-
});
|
|
426
|
-
root.render(
|
|
427
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.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
|
+
}
|
|
428
364
|
);
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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"
|
|
438
376
|
});
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
|
|
442
|
-
);
|
|
443
|
-
return root.files;
|
|
377
|
+
const operationFiles = await operationGenerator.build(...generators);
|
|
378
|
+
await this.addFile(...operationFiles);
|
|
444
379
|
}
|
|
445
380
|
};
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
381
|
+
});
|
|
455
382
|
|
|
456
|
-
|
|
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
|
|
457
407
|
//# sourceMappingURL=index.cjs.map
|