@kubb/plugin-oas 2.18.4 → 2.18.6
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-X6CTMfhG.d.cts → OperationGenerator-B6_KXF47.d.cts} +12 -11
- package/dist/{OperationGenerator-DvnXUUp4.d.ts → OperationGenerator-BL3W1CH2.d.ts} +12 -11
- package/dist/{Schema-DFZBfjF2.d.ts → Schema-ByMOp8RL.d.ts} +6 -12
- package/dist/{Schema-BWPWyiQO.d.cts → Schema-C9Wxng-Q.d.cts} +6 -12
- package/dist/{SchemaGenerator-hK5SHxTI.d.ts → SchemaMapper-DRlWYDvv.d.cts} +2 -74
- package/dist/{SchemaGenerator-z_7YrAAB.d.cts → SchemaMapper-DRlWYDvv.d.ts} +2 -74
- package/dist/{chunk-UMYKVV7G.js → chunk-37DRAF2Z.js} +49 -2
- package/dist/chunk-37DRAF2Z.js.map +1 -0
- package/dist/chunk-CTFUZW3D.cjs +682 -0
- package/dist/chunk-CTFUZW3D.cjs.map +1 -0
- package/dist/{chunk-XML4KQ5H.js → chunk-FL37EDQ2.js} +12 -30
- package/dist/{chunk-XML4KQ5H.js.map → chunk-FL37EDQ2.js.map} +1 -1
- package/dist/chunk-JWIFGIVZ.js +34 -0
- package/dist/chunk-JWIFGIVZ.js.map +1 -0
- package/dist/{chunk-YI3FIAD4.cjs → chunk-OUN5NRHC.cjs} +30 -48
- package/dist/chunk-OUN5NRHC.cjs.map +1 -0
- package/dist/chunk-QLNCBDLM.js +682 -0
- package/dist/chunk-QLNCBDLM.js.map +1 -0
- package/dist/chunk-R4EI2NRQ.cjs +34 -0
- package/dist/chunk-R4EI2NRQ.cjs.map +1 -0
- package/dist/{chunk-BDNSPC5Z.cjs → chunk-SSSTH6CP.cjs} +50 -3
- package/dist/chunk-SSSTH6CP.cjs.map +1 -0
- package/dist/components.cjs +5 -5
- package/dist/components.d.cts +5 -4
- package/dist/components.d.ts +5 -4
- package/dist/components.js +3 -3
- package/dist/hooks.cjs +13 -13
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +7 -8
- package/dist/hooks.d.ts +7 -8
- package/dist/hooks.js +3 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +69 -642
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -6
- package/dist/index.d.ts +72 -6
- package/dist/index.js +50 -623
- package/dist/index.js.map +1 -1
- package/dist/{types-n5zV4Q3s.d.cts → types-BMBTfHxe.d.cts} +3 -2
- package/dist/{types-n5zV4Q3s.d.ts → types-BMBTfHxe.d.ts} +3 -2
- package/dist/utils.cjs +9 -9
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +5 -4
- package/dist/utils.d.ts +5 -4
- package/dist/utils.js +5 -5
- package/dist/utils.js.map +1 -1
- package/package.json +10 -9
- package/src/OperationGenerator.ts +27 -11
- package/src/SchemaGenerator.ts +30 -35
- package/src/SchemaMapper.ts +1 -1
- package/src/components/Schema.tsx +12 -42
- package/src/hooks/useOperationManager.ts +3 -2
- package/src/hooks/useSchema.ts +1 -8
- package/src/index.ts +1 -0
- package/src/plugin.ts +3 -3
- package/src/types.ts +3 -1
- package/src/utils/getGroupedByTagFiles.ts +4 -3
- package/dist/chunk-4OLWDMEK.cjs +0 -61
- package/dist/chunk-4OLWDMEK.cjs.map +0 -1
- package/dist/chunk-BDNSPC5Z.cjs.map +0 -1
- package/dist/chunk-BIJSTJCQ.js +0 -61
- package/dist/chunk-BIJSTJCQ.js.map +0 -1
- package/dist/chunk-I2JOGJIB.cjs +0 -81
- package/dist/chunk-I2JOGJIB.cjs.map +0 -1
- package/dist/chunk-UMYKVV7G.js.map +0 -1
- package/dist/chunk-XRPYJNPR.js +0 -81
- package/dist/chunk-XRPYJNPR.js.map +0 -1
- package/dist/chunk-YI3FIAD4.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
+
var _chunkR4EI2NRQcjs = require('./chunk-R4EI2NRQ.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
|
-
var _chunkI2JOGJIBcjs = require('./chunk-I2JOGJIB.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
var _chunkCTFUZW3Dcjs = require('./chunk-CTFUZW3D.cjs');
|
|
8
9
|
|
|
9
|
-
var _chunk4OLWDMEKcjs = require('./chunk-4OLWDMEK.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkSSSTH6CPcjs = require('./chunk-SSSTH6CP.cjs');
|
|
17
17
|
|
|
18
18
|
// src/index.ts
|
|
19
|
-
|
|
19
|
+
_chunkSSSTH6CPcjs.init_cjs_shims.call(void 0, );
|
|
20
20
|
|
|
21
21
|
// src/plugin.ts
|
|
22
|
-
|
|
22
|
+
_chunkSSSTH6CPcjs.init_cjs_shims.call(void 0, );
|
|
23
23
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
24
24
|
var _core = require('@kubb/core');
|
|
25
25
|
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
@@ -35,7 +35,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
35
35
|
} = options;
|
|
36
36
|
const getOas = async ({ config, logger, formatOptions }) => {
|
|
37
37
|
try {
|
|
38
|
-
const oas = await
|
|
38
|
+
const oas = await _chunkR4EI2NRQcjs.parseFromConfig.call(void 0, config, formatOptions);
|
|
39
39
|
if (validate) {
|
|
40
40
|
await oas.valdiate();
|
|
41
41
|
}
|
|
@@ -43,7 +43,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
43
43
|
} catch (e) {
|
|
44
44
|
const error = e;
|
|
45
45
|
logger.emit("warning", _optionalChain([error, 'optionalAccess', _ => _.message]));
|
|
46
|
-
return
|
|
46
|
+
return _chunkR4EI2NRQcjs.parseFromConfig.call(void 0, config);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
return {
|
|
@@ -57,7 +57,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
57
57
|
},
|
|
58
58
|
async getSchemas({ includes } = {}) {
|
|
59
59
|
const oas = await this.getOas();
|
|
60
|
-
return
|
|
60
|
+
return _chunkSSSTH6CPcjs.getSchemas.call(void 0, { oas, contentType, includes });
|
|
61
61
|
},
|
|
62
62
|
async getBaseURL() {
|
|
63
63
|
const oasInstance = await this.getOas();
|
|
@@ -77,11 +77,11 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
77
77
|
resolveName(name, type) {
|
|
78
78
|
return _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
|
|
79
79
|
},
|
|
80
|
-
async writeFile(
|
|
81
|
-
if (!
|
|
80
|
+
async writeFile(path2, source) {
|
|
81
|
+
if (!path2.endsWith(".json") || !source) {
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
return this.fileManager.write(
|
|
84
|
+
return this.fileManager.write(path2, source, { sanity: false });
|
|
85
85
|
},
|
|
86
86
|
async buildStart() {
|
|
87
87
|
if (!output) {
|
|
@@ -96,7 +96,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
await oas.dereference();
|
|
99
|
-
const schemas =
|
|
99
|
+
const schemas = _chunkSSSTH6CPcjs.getSchemas.call(void 0, { oas, contentType });
|
|
100
100
|
const mapSchema = async ([name, schema]) => {
|
|
101
101
|
const resolvedPath = this.resolvePath({
|
|
102
102
|
baseName: `${name}.json`,
|
|
@@ -126,32 +126,32 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
// src/OperationGenerator.ts
|
|
129
|
-
|
|
129
|
+
_chunkSSSTH6CPcjs.init_cjs_shims.call(void 0, );
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
var _operationsByMethod, _getOptions, getOptions_fn, _isExcluded, isExcluded_fn, _isIncluded, isIncluded_fn, _methods, methods_get;
|
|
133
133
|
var OperationGenerator = class extends _core.Generator {
|
|
134
134
|
constructor() {
|
|
135
135
|
super(...arguments);
|
|
136
|
-
|
|
136
|
+
_chunkSSSTH6CPcjs.__privateAdd.call(void 0, this, _getOptions);
|
|
137
137
|
/**
|
|
138
138
|
*
|
|
139
139
|
* @deprecated
|
|
140
140
|
*/
|
|
141
|
-
|
|
141
|
+
_chunkSSSTH6CPcjs.__privateAdd.call(void 0, this, _isExcluded);
|
|
142
142
|
/**
|
|
143
143
|
*
|
|
144
144
|
* @deprecated
|
|
145
145
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
_chunkSSSTH6CPcjs.__privateAdd.call(void 0, this, _isIncluded);
|
|
147
|
+
_chunkSSSTH6CPcjs.__privateAdd.call(void 0, this, _methods);
|
|
148
|
+
_chunkSSSTH6CPcjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
|
|
149
149
|
}
|
|
150
150
|
get operationsByMethod() {
|
|
151
|
-
return
|
|
151
|
+
return _chunkSSSTH6CPcjs.__privateGet.call(void 0, this, _operationsByMethod);
|
|
152
152
|
}
|
|
153
153
|
set operationsByMethod(paths) {
|
|
154
|
-
|
|
154
|
+
_chunkSSSTH6CPcjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
|
|
155
155
|
}
|
|
156
156
|
getSchemas(operation, forStatusCode) {
|
|
157
157
|
const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
|
|
@@ -234,9 +234,9 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
234
234
|
const methods = Object.keys(method);
|
|
235
235
|
methods.forEach((method2) => {
|
|
236
236
|
const operation = oas.operation(path2, method2);
|
|
237
|
-
if (operation &&
|
|
238
|
-
const isExcluded =
|
|
239
|
-
const isIncluded = this.context.include ?
|
|
237
|
+
if (operation && _chunkSSSTH6CPcjs.__privateGet.call(void 0, this, _methods, methods_get)[method2]) {
|
|
238
|
+
const isExcluded = _chunkSSSTH6CPcjs.__privateMethod.call(void 0, this, _isExcluded, isExcluded_fn).call(this, operation, method2);
|
|
239
|
+
const isIncluded = this.context.include ? _chunkSSSTH6CPcjs.__privateMethod.call(void 0, this, _isIncluded, isIncluded_fn).call(this, operation, method2) : true;
|
|
240
240
|
if (isIncluded && !isExcluded) {
|
|
241
241
|
if (!acc[path2]) {
|
|
242
242
|
acc[path2] = {};
|
|
@@ -257,8 +257,8 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
257
257
|
const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
|
|
258
258
|
methods.forEach((method) => {
|
|
259
259
|
const { operation } = _optionalChain([this, 'access', _37 => _37.operationsByMethod, 'access', _38 => _38[path2], 'optionalAccess', _39 => _39[method]]);
|
|
260
|
-
const options =
|
|
261
|
-
const promiseMethod = _optionalChain([
|
|
260
|
+
const options = _chunkSSSTH6CPcjs.__privateMethod.call(void 0, this, _getOptions, getOptions_fn).call(this, operation, method);
|
|
261
|
+
const promiseMethod = _optionalChain([_chunkSSSTH6CPcjs.__privateGet.call(void 0, this, _methods, methods_get), 'access', _40 => _40[method], 'optionalAccess', _41 => _41.call, 'call', _42 => _42(this, operation, {
|
|
262
262
|
...this.options,
|
|
263
263
|
...options
|
|
264
264
|
})]);
|
|
@@ -280,6 +280,48 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
280
280
|
const files = await Promise.all(promises);
|
|
281
281
|
return files.flat().filter(Boolean);
|
|
282
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Operation
|
|
285
|
+
*/
|
|
286
|
+
async operation(operation, options) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* GET
|
|
291
|
+
*/
|
|
292
|
+
async get(operation, options) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* POST
|
|
297
|
+
*/
|
|
298
|
+
async post(operation, options) {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* PATCH
|
|
303
|
+
*/
|
|
304
|
+
async patch(operation, options) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* PUT
|
|
309
|
+
*/
|
|
310
|
+
async put(operation, options) {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* DELETE
|
|
315
|
+
*/
|
|
316
|
+
async delete(operation, options) {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
321
|
+
*/
|
|
322
|
+
async all(operations, paths) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
283
325
|
};
|
|
284
326
|
_operationsByMethod = new WeakMap();
|
|
285
327
|
_getOptions = new WeakSet();
|
|
@@ -355,621 +397,6 @@ methods_get = function() {
|
|
|
355
397
|
};
|
|
356
398
|
};
|
|
357
399
|
|
|
358
|
-
// src/SchemaGenerator.ts
|
|
359
|
-
_chunkBDNSPC5Zcjs.init_cjs_shims.call(void 0, );
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
var _utils = require('@kubb/core/utils');
|
|
363
|
-
var _oas = require('@kubb/oas');
|
|
364
|
-
var _remeda = require('remeda');
|
|
365
|
-
var _usedAliasNames, _getUsedEnumNames, getUsedEnumNames_fn, _getOptions2, getOptions_fn2, _getUnknownReturn, getUnknownReturn_fn, _parseProperties, parseProperties_fn, _getRefAlias, getRefAlias_fn, _getParsedSchemaObject, getParsedSchemaObject_fn, _parseSchemaObject, parseSchemaObject_fn;
|
|
366
|
-
var _SchemaGenerator = class _SchemaGenerator extends _core.Generator {
|
|
367
|
-
constructor() {
|
|
368
|
-
super(...arguments);
|
|
369
|
-
_chunkBDNSPC5Zcjs.__privateAdd.call(void 0, this, _getUsedEnumNames);
|
|
370
|
-
_chunkBDNSPC5Zcjs.__privateAdd.call(void 0, this, _getOptions2);
|
|
371
|
-
_chunkBDNSPC5Zcjs.__privateAdd.call(void 0, this, _getUnknownReturn);
|
|
372
|
-
/**
|
|
373
|
-
* Recursively creates a type literal with the given props.
|
|
374
|
-
*/
|
|
375
|
-
_chunkBDNSPC5Zcjs.__privateAdd.call(void 0, this, _parseProperties);
|
|
376
|
-
/**
|
|
377
|
-
* Create a type alias for the schema referenced by the given ReferenceObject
|
|
378
|
-
*/
|
|
379
|
-
_chunkBDNSPC5Zcjs.__privateAdd.call(void 0, this, _getRefAlias);
|
|
380
|
-
_chunkBDNSPC5Zcjs.__privateAdd.call(void 0, this, _getParsedSchemaObject);
|
|
381
|
-
/**
|
|
382
|
-
* This is the very core of the OpenAPI to TS conversion - it takes a
|
|
383
|
-
* schema and returns the appropriate type.
|
|
384
|
-
*/
|
|
385
|
-
_chunkBDNSPC5Zcjs.__privateAdd.call(void 0, this, _parseSchemaObject);
|
|
386
|
-
// Collect the types of all referenced schemas, so we can export them later
|
|
387
|
-
this.refs = {};
|
|
388
|
-
// Keep track of already used type aliases
|
|
389
|
-
_chunkBDNSPC5Zcjs.__privateAdd.call(void 0, this, _usedAliasNames, {});
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Creates a type node from a given schema.
|
|
393
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
394
|
-
* optionally adds a union with null.
|
|
395
|
-
*/
|
|
396
|
-
buildSchemas(props) {
|
|
397
|
-
const options = _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getOptions2, getOptions_fn2).call(this, props);
|
|
398
|
-
const defaultSchemas = _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _parseSchemaObject, parseSchemaObject_fn).call(this, props);
|
|
399
|
-
const schemas = _optionalChain([options, 'access', _64 => _64.transformers, 'optionalAccess', _65 => _65.schema, 'optionalCall', _66 => _66(props, defaultSchemas)]) || defaultSchemas || [];
|
|
400
|
-
return _remeda.uniqueWith.call(void 0, schemas, _remeda.isDeepEqual);
|
|
401
|
-
}
|
|
402
|
-
deepSearch(schemas, keyword) {
|
|
403
|
-
return _SchemaGenerator.deepSearch(schemas, keyword);
|
|
404
|
-
}
|
|
405
|
-
find(schemas, keyword) {
|
|
406
|
-
return _SchemaGenerator.find(schemas, keyword);
|
|
407
|
-
}
|
|
408
|
-
static deepSearch(schemas, keyword) {
|
|
409
|
-
const foundItems = [];
|
|
410
|
-
_optionalChain([schemas, 'optionalAccess', _67 => _67.forEach, 'call', _68 => _68((schema) => {
|
|
411
|
-
if (schema.keyword === keyword) {
|
|
412
|
-
foundItems.push(schema);
|
|
413
|
-
}
|
|
414
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.object) {
|
|
415
|
-
const subItem = schema;
|
|
416
|
-
Object.values(_optionalChain([subItem, 'access', _69 => _69.args, 'optionalAccess', _70 => _70.properties]) || {}).forEach((entrySchema) => {
|
|
417
|
-
foundItems.push(..._SchemaGenerator.deepSearch(entrySchema, keyword));
|
|
418
|
-
});
|
|
419
|
-
Object.values(_optionalChain([subItem, 'access', _71 => _71.args, 'optionalAccess', _72 => _72.additionalProperties]) || {}).forEach((entrySchema) => {
|
|
420
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.array) {
|
|
424
|
-
const subItem = schema;
|
|
425
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
426
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.and) {
|
|
430
|
-
const subItem = schema;
|
|
431
|
-
subItem.args.forEach((entrySchema) => {
|
|
432
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.tuple) {
|
|
436
|
-
const subItem = schema;
|
|
437
|
-
subItem.args.forEach((entrySchema) => {
|
|
438
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.union) {
|
|
442
|
-
const subItem = schema;
|
|
443
|
-
subItem.args.forEach((entrySchema) => {
|
|
444
|
-
foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
})]);
|
|
448
|
-
return foundItems;
|
|
449
|
-
}
|
|
450
|
-
static findInObject(schemas, keyword) {
|
|
451
|
-
let foundItem = void 0;
|
|
452
|
-
_optionalChain([schemas, 'optionalAccess', _73 => _73.forEach, 'call', _74 => _74((schema) => {
|
|
453
|
-
if (!foundItem && schema.keyword === keyword) {
|
|
454
|
-
foundItem = schema;
|
|
455
|
-
}
|
|
456
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.object) {
|
|
457
|
-
const subItem = schema;
|
|
458
|
-
Object.values(_optionalChain([subItem, 'access', _75 => _75.args, 'optionalAccess', _76 => _76.properties]) || {}).forEach((entrySchema) => {
|
|
459
|
-
if (!foundItem) {
|
|
460
|
-
foundItem = _SchemaGenerator.find(entrySchema, keyword);
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
Object.values(_optionalChain([subItem, 'access', _77 => _77.args, 'optionalAccess', _78 => _78.additionalProperties]) || {}).forEach((entrySchema) => {
|
|
464
|
-
if (!foundItem) {
|
|
465
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
})]);
|
|
470
|
-
return foundItem;
|
|
471
|
-
}
|
|
472
|
-
static find(schemas, keyword) {
|
|
473
|
-
let foundItem = void 0;
|
|
474
|
-
_optionalChain([schemas, 'optionalAccess', _79 => _79.forEach, 'call', _80 => _80((schema) => {
|
|
475
|
-
if (!foundItem && schema.keyword === keyword) {
|
|
476
|
-
foundItem = schema;
|
|
477
|
-
}
|
|
478
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.array) {
|
|
479
|
-
const subItem = schema;
|
|
480
|
-
subItem.args.items.forEach((entrySchema) => {
|
|
481
|
-
if (!foundItem) {
|
|
482
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.and) {
|
|
487
|
-
const subItem = schema;
|
|
488
|
-
subItem.args.forEach((entrySchema) => {
|
|
489
|
-
if (!foundItem) {
|
|
490
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.tuple) {
|
|
495
|
-
const subItem = schema;
|
|
496
|
-
subItem.args.forEach((entrySchema) => {
|
|
497
|
-
if (!foundItem) {
|
|
498
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
if (schema.keyword === _chunk4OLWDMEKcjs.schemaKeywords.union) {
|
|
503
|
-
const subItem = schema;
|
|
504
|
-
subItem.args.forEach((entrySchema) => {
|
|
505
|
-
if (!foundItem) {
|
|
506
|
-
foundItem = _SchemaGenerator.find([entrySchema], keyword);
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
})]);
|
|
511
|
-
return foundItem;
|
|
512
|
-
}
|
|
513
|
-
async build() {
|
|
514
|
-
const { oas, contentType, include } = this.context;
|
|
515
|
-
const schemas = _chunkI2JOGJIBcjs.getSchemas.call(void 0, { oas, contentType, includes: include });
|
|
516
|
-
const promises = Object.entries(schemas).reduce((acc, [name, schema]) => {
|
|
517
|
-
const promiseOperation = this.schema.call(this, name, schema);
|
|
518
|
-
if (promiseOperation) {
|
|
519
|
-
acc.push(promiseOperation);
|
|
520
|
-
}
|
|
521
|
-
return acc;
|
|
522
|
-
}, []);
|
|
523
|
-
const files = await Promise.all(promises);
|
|
524
|
-
return files.flat().filter(Boolean);
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
|
-
_usedAliasNames = new WeakMap();
|
|
528
|
-
_getUsedEnumNames = new WeakSet();
|
|
529
|
-
getUsedEnumNames_fn = function(props) {
|
|
530
|
-
const options = _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getOptions2, getOptions_fn2).call(this, props);
|
|
531
|
-
return options.usedEnumNames || {};
|
|
532
|
-
};
|
|
533
|
-
_getOptions2 = new WeakSet();
|
|
534
|
-
getOptions_fn2 = function({ name }) {
|
|
535
|
-
const { override = [] } = this.context;
|
|
536
|
-
return {
|
|
537
|
-
...this.options,
|
|
538
|
-
..._optionalChain([override, 'access', _81 => _81.find, 'call', _82 => _82(({ pattern, type }) => {
|
|
539
|
-
if (name && type === "schemaName") {
|
|
540
|
-
return !!name.match(pattern);
|
|
541
|
-
}
|
|
542
|
-
return false;
|
|
543
|
-
}), 'optionalAccess', _83 => _83.options]) || {}
|
|
544
|
-
};
|
|
545
|
-
};
|
|
546
|
-
_getUnknownReturn = new WeakSet();
|
|
547
|
-
getUnknownReturn_fn = function(props) {
|
|
548
|
-
const options = _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getOptions2, getOptions_fn2).call(this, props);
|
|
549
|
-
if (options.unknownType === "any") {
|
|
550
|
-
return _chunk4OLWDMEKcjs.schemaKeywords.any;
|
|
551
|
-
}
|
|
552
|
-
return _chunk4OLWDMEKcjs.schemaKeywords.unknown;
|
|
553
|
-
};
|
|
554
|
-
_parseProperties = new WeakSet();
|
|
555
|
-
parseProperties_fn = function({ schema, name }) {
|
|
556
|
-
const properties = _optionalChain([schema, 'optionalAccess', _84 => _84.properties]) || {};
|
|
557
|
-
const additionalProperties = _optionalChain([schema, 'optionalAccess', _85 => _85.additionalProperties]);
|
|
558
|
-
const required = _optionalChain([schema, 'optionalAccess', _86 => _86.required]);
|
|
559
|
-
const propertiesSchemas = Object.keys(properties).map((propertyName) => {
|
|
560
|
-
const validationFunctions = [];
|
|
561
|
-
const propertySchema = properties[propertyName];
|
|
562
|
-
const isRequired = Array.isArray(required) ? _optionalChain([required, 'optionalAccess', _87 => _87.includes, 'call', _88 => _88(propertyName)]) : !!required;
|
|
563
|
-
const nullable = _nullishCoalesce(_nullishCoalesce(propertySchema.nullable, () => ( propertySchema["x-nullable"])), () => ( false));
|
|
564
|
-
validationFunctions.push(...this.buildSchemas({ schema: propertySchema, name: propertyName, parentName: name }));
|
|
565
|
-
validationFunctions.push({
|
|
566
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.name,
|
|
567
|
-
args: propertyName
|
|
568
|
-
});
|
|
569
|
-
if (!isRequired && nullable) {
|
|
570
|
-
validationFunctions.push({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.nullish });
|
|
571
|
-
} else if (!isRequired) {
|
|
572
|
-
validationFunctions.push({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.optional });
|
|
573
|
-
}
|
|
574
|
-
return {
|
|
575
|
-
[propertyName]: validationFunctions
|
|
576
|
-
};
|
|
577
|
-
}).reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
578
|
-
let additionalPropertiesSchemas = [];
|
|
579
|
-
if (additionalProperties) {
|
|
580
|
-
additionalPropertiesSchemas = additionalProperties === true ? [{ keyword: _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getUnknownReturn, getUnknownReturn_fn).call(this, { schema, name }) }] : this.buildSchemas({ schema: additionalProperties, parentName: name });
|
|
581
|
-
}
|
|
582
|
-
return [
|
|
583
|
-
{
|
|
584
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.object,
|
|
585
|
-
args: {
|
|
586
|
-
properties: propertiesSchemas,
|
|
587
|
-
additionalProperties: additionalPropertiesSchemas
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
];
|
|
591
|
-
};
|
|
592
|
-
_getRefAlias = new WeakSet();
|
|
593
|
-
getRefAlias_fn = function(obj) {
|
|
594
|
-
const { $ref } = obj;
|
|
595
|
-
let ref = this.refs[$ref];
|
|
596
|
-
const originalName = _utils.getUniqueName.call(void 0, $ref.replace(/.+\//, ""), _chunkBDNSPC5Zcjs.__privateGet.call(void 0, this, _usedAliasNames));
|
|
597
|
-
const propertyName = this.context.pluginManager.resolveName({
|
|
598
|
-
name: originalName,
|
|
599
|
-
pluginKey: this.context.plugin.key,
|
|
600
|
-
type: "function"
|
|
601
|
-
});
|
|
602
|
-
if (ref) {
|
|
603
|
-
return [
|
|
604
|
-
{
|
|
605
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.ref,
|
|
606
|
-
args: { name: ref.propertyName, path: ref.path }
|
|
607
|
-
}
|
|
608
|
-
];
|
|
609
|
-
}
|
|
610
|
-
const fileName = this.context.pluginManager.resolveName({
|
|
611
|
-
name: originalName,
|
|
612
|
-
pluginKey: this.context.plugin.key,
|
|
613
|
-
type: "file"
|
|
614
|
-
});
|
|
615
|
-
const file = this.context.pluginManager.getFile({
|
|
616
|
-
name: fileName,
|
|
617
|
-
pluginKey: this.context.plugin.key,
|
|
618
|
-
extName: ".ts"
|
|
619
|
-
});
|
|
620
|
-
ref = this.refs[$ref] = {
|
|
621
|
-
propertyName,
|
|
622
|
-
originalName,
|
|
623
|
-
path: file.path
|
|
624
|
-
};
|
|
625
|
-
return [
|
|
626
|
-
{
|
|
627
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.ref,
|
|
628
|
-
args: { name: ref.propertyName, path: _optionalChain([ref, 'optionalAccess', _89 => _89.path]), isTypeOnly: false }
|
|
629
|
-
}
|
|
630
|
-
];
|
|
631
|
-
};
|
|
632
|
-
_getParsedSchemaObject = new WeakSet();
|
|
633
|
-
getParsedSchemaObject_fn = function(schema) {
|
|
634
|
-
const parsedSchema = _chunkI2JOGJIBcjs.getSchemaFactory.call(void 0, this.context.oas)(schema);
|
|
635
|
-
return parsedSchema;
|
|
636
|
-
};
|
|
637
|
-
_parseSchemaObject = new WeakSet();
|
|
638
|
-
parseSchemaObject_fn = function({ schema: _schema, name, parentName }) {
|
|
639
|
-
const options = _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getOptions2, getOptions_fn2).call(this, { schema: _schema, name });
|
|
640
|
-
const unknownReturn = _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getUnknownReturn, getUnknownReturn_fn).call(this, { schema: _schema, name });
|
|
641
|
-
const { schema, version } = _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getParsedSchemaObject, getParsedSchemaObject_fn).call(this, _schema);
|
|
642
|
-
const resolvedName = this.context.pluginManager.resolveName({
|
|
643
|
-
name: `${parentName || ""} ${name}`,
|
|
644
|
-
pluginKey: this.context.plugin.key,
|
|
645
|
-
type: "type"
|
|
646
|
-
});
|
|
647
|
-
if (!schema) {
|
|
648
|
-
return [{ keyword: unknownReturn }];
|
|
649
|
-
}
|
|
650
|
-
const baseItems = [
|
|
651
|
-
{
|
|
652
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.schema,
|
|
653
|
-
args: {
|
|
654
|
-
type: schema.type,
|
|
655
|
-
format: schema.format
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
];
|
|
659
|
-
const min = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.minimum, () => ( schema.minLength)), () => ( schema.minItems)), () => ( void 0));
|
|
660
|
-
const max = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.maximum, () => ( schema.maxLength)), () => ( schema.maxItems)), () => ( void 0));
|
|
661
|
-
const nullable = _nullishCoalesce(_nullishCoalesce(schema.nullable, () => ( schema["x-nullable"])), () => ( false));
|
|
662
|
-
if (schema.default !== void 0 && !Array.isArray(schema.default)) {
|
|
663
|
-
if (typeof schema.default === "string") {
|
|
664
|
-
baseItems.push({
|
|
665
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.default,
|
|
666
|
-
args: _transformers2.default.stringify(schema.default)
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
if (typeof schema.default === "boolean") {
|
|
670
|
-
baseItems.push({
|
|
671
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.default,
|
|
672
|
-
args: _nullishCoalesce(schema.default, () => ( false))
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
if (schema.description) {
|
|
677
|
-
baseItems.push({
|
|
678
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.describe,
|
|
679
|
-
args: schema.description
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
if (schema.pattern) {
|
|
683
|
-
baseItems.unshift({
|
|
684
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.matches,
|
|
685
|
-
args: schema.pattern
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
if (max !== void 0) {
|
|
689
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.max, args: max });
|
|
690
|
-
}
|
|
691
|
-
if (min !== void 0) {
|
|
692
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.min, args: min });
|
|
693
|
-
}
|
|
694
|
-
if (nullable) {
|
|
695
|
-
baseItems.push({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.nullable });
|
|
696
|
-
}
|
|
697
|
-
if (schema.type && Array.isArray(schema.type)) {
|
|
698
|
-
const [_schema2, nullable2] = schema.type;
|
|
699
|
-
if (nullable2 === "null") {
|
|
700
|
-
baseItems.push({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.nullable });
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
if (schema.readOnly) {
|
|
704
|
-
baseItems.push({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.readOnly });
|
|
705
|
-
}
|
|
706
|
-
if (_oas.isReference.call(void 0, schema)) {
|
|
707
|
-
return [..._chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getRefAlias, getRefAlias_fn).call(this, schema), ...baseItems];
|
|
708
|
-
}
|
|
709
|
-
if (schema.oneOf) {
|
|
710
|
-
const schemaWithoutOneOf = { ...schema, oneOf: void 0 };
|
|
711
|
-
const union = {
|
|
712
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.union,
|
|
713
|
-
args: schema.oneOf.map((item) => {
|
|
714
|
-
return item && this.buildSchemas({ schema: item, name, parentName })[0];
|
|
715
|
-
}).filter(Boolean).filter((item) => {
|
|
716
|
-
return item && item.keyword !== unknownReturn;
|
|
717
|
-
})
|
|
718
|
-
};
|
|
719
|
-
if (schemaWithoutOneOf.properties) {
|
|
720
|
-
return [...this.buildSchemas({ schema: schemaWithoutOneOf, name, parentName }), union, ...baseItems];
|
|
721
|
-
}
|
|
722
|
-
return [union, ...baseItems];
|
|
723
|
-
}
|
|
724
|
-
if (schema.anyOf) {
|
|
725
|
-
const schemaWithoutAnyOf = { ...schema, anyOf: void 0 };
|
|
726
|
-
const union = {
|
|
727
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.union,
|
|
728
|
-
args: schema.anyOf.map((item) => {
|
|
729
|
-
return item && this.buildSchemas({ schema: item, name, parentName })[0];
|
|
730
|
-
}).filter(Boolean).filter((item) => {
|
|
731
|
-
return item && item.keyword !== unknownReturn;
|
|
732
|
-
}).map((item) => {
|
|
733
|
-
if (_chunk4OLWDMEKcjs.isKeyword.call(void 0, item, _chunk4OLWDMEKcjs.schemaKeywords.object)) {
|
|
734
|
-
return {
|
|
735
|
-
...item,
|
|
736
|
-
args: {
|
|
737
|
-
...item.args,
|
|
738
|
-
strict: true
|
|
739
|
-
}
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
return item;
|
|
743
|
-
})
|
|
744
|
-
};
|
|
745
|
-
if (schemaWithoutAnyOf.properties) {
|
|
746
|
-
return [...this.buildSchemas({ schema: schemaWithoutAnyOf, name, parentName }), union, ...baseItems];
|
|
747
|
-
}
|
|
748
|
-
return [union, ...baseItems];
|
|
749
|
-
}
|
|
750
|
-
if (schema.allOf) {
|
|
751
|
-
const schemaWithoutAllOf = { ...schema, allOf: void 0 };
|
|
752
|
-
const and = {
|
|
753
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.and,
|
|
754
|
-
args: schema.allOf.map((item) => {
|
|
755
|
-
return item && this.buildSchemas({ schema: item, name, parentName })[0];
|
|
756
|
-
}).filter(Boolean).filter((item) => {
|
|
757
|
-
return item && item.keyword !== unknownReturn;
|
|
758
|
-
})
|
|
759
|
-
};
|
|
760
|
-
if (schemaWithoutAllOf.properties) {
|
|
761
|
-
return [
|
|
762
|
-
{
|
|
763
|
-
...and,
|
|
764
|
-
args: [...and.args || [], ...this.buildSchemas({ schema: schemaWithoutAllOf, name, parentName })]
|
|
765
|
-
},
|
|
766
|
-
...baseItems
|
|
767
|
-
];
|
|
768
|
-
}
|
|
769
|
-
return [and, ...baseItems];
|
|
770
|
-
}
|
|
771
|
-
if (schema.enum) {
|
|
772
|
-
const enumName = _utils.getUniqueName.call(void 0, _transformers.pascalCase.call(void 0, [parentName, name, options.enumSuffix].join(" ")), _chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _getUsedEnumNames, getUsedEnumNames_fn).call(this, { schema, name }));
|
|
773
|
-
const typeName = this.context.pluginManager.resolveName({
|
|
774
|
-
name: enumName,
|
|
775
|
-
pluginKey: this.context.plugin.key,
|
|
776
|
-
type: "type"
|
|
777
|
-
});
|
|
778
|
-
const extensionEnums = ["x-enumNames", "x-enum-varnames"].filter((extensionKey) => extensionKey in schema).map((extensionKey) => {
|
|
779
|
-
return [
|
|
780
|
-
{
|
|
781
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.enum,
|
|
782
|
-
args: {
|
|
783
|
-
name,
|
|
784
|
-
typeName,
|
|
785
|
-
asConst: false,
|
|
786
|
-
items: [...new Set(schema[extensionKey])].map((name2, index) => ({
|
|
787
|
-
name: _transformers2.default.stringify(name2),
|
|
788
|
-
value: _optionalChain([schema, 'access', _90 => _90.enum, 'optionalAccess', _91 => _91[index]]),
|
|
789
|
-
format: _remeda.isNumber.call(void 0, _optionalChain([schema, 'access', _92 => _92.enum, 'optionalAccess', _93 => _93[index]])) ? "number" : "string"
|
|
790
|
-
}))
|
|
791
|
-
}
|
|
792
|
-
},
|
|
793
|
-
...baseItems.filter(
|
|
794
|
-
(item) => item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.min && item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.max && item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.matches
|
|
795
|
-
)
|
|
796
|
-
];
|
|
797
|
-
});
|
|
798
|
-
if (schema.type === "number" || schema.type === "integer") {
|
|
799
|
-
const enumNames = _optionalChain([extensionEnums, 'access', _94 => _94[0], 'optionalAccess', _95 => _95.find, 'call', _96 => _96((item) => _chunk4OLWDMEKcjs.isKeyword.call(void 0, item, _chunk4OLWDMEKcjs.schemaKeywords.enum))]);
|
|
800
|
-
return [
|
|
801
|
-
{
|
|
802
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.enum,
|
|
803
|
-
args: {
|
|
804
|
-
name: enumName,
|
|
805
|
-
typeName,
|
|
806
|
-
asConst: true,
|
|
807
|
-
items: _optionalChain([enumNames, 'optionalAccess', _97 => _97.args, 'optionalAccess', _98 => _98.items]) ? [...new Set(enumNames.args.items)].map(({ name: name2, value }) => ({
|
|
808
|
-
name: name2,
|
|
809
|
-
value,
|
|
810
|
-
format: "number"
|
|
811
|
-
})) : [...new Set(schema.enum)].map((value) => {
|
|
812
|
-
return {
|
|
813
|
-
name: value,
|
|
814
|
-
value,
|
|
815
|
-
format: "number"
|
|
816
|
-
};
|
|
817
|
-
})
|
|
818
|
-
}
|
|
819
|
-
},
|
|
820
|
-
...baseItems.filter((item) => item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.min && item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.max && item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.matches)
|
|
821
|
-
];
|
|
822
|
-
}
|
|
823
|
-
if (extensionEnums.length > 0 && extensionEnums[0]) {
|
|
824
|
-
return extensionEnums[0];
|
|
825
|
-
}
|
|
826
|
-
return [
|
|
827
|
-
{
|
|
828
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.enum,
|
|
829
|
-
args: {
|
|
830
|
-
name: enumName,
|
|
831
|
-
typeName,
|
|
832
|
-
asConst: false,
|
|
833
|
-
items: [...new Set(schema.enum)].map((value) => ({
|
|
834
|
-
name: _transformers2.default.stringify(value),
|
|
835
|
-
value,
|
|
836
|
-
format: _remeda.isNumber.call(void 0, value) ? "number" : "string"
|
|
837
|
-
}))
|
|
838
|
-
}
|
|
839
|
-
},
|
|
840
|
-
...baseItems.filter((item) => item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.min && item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.max && item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.matches)
|
|
841
|
-
];
|
|
842
|
-
}
|
|
843
|
-
if ("prefixItems" in schema) {
|
|
844
|
-
const prefixItems = schema.prefixItems;
|
|
845
|
-
return [
|
|
846
|
-
{
|
|
847
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.tuple,
|
|
848
|
-
args: prefixItems.map((item) => {
|
|
849
|
-
return this.buildSchemas({ schema: item, name, parentName })[0];
|
|
850
|
-
}).filter(Boolean)
|
|
851
|
-
},
|
|
852
|
-
...baseItems
|
|
853
|
-
];
|
|
854
|
-
}
|
|
855
|
-
if (version === "3.1" && "const" in schema) {
|
|
856
|
-
if (schema["const"]) {
|
|
857
|
-
return [
|
|
858
|
-
{
|
|
859
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.const,
|
|
860
|
-
args: {
|
|
861
|
-
name: schema["const"],
|
|
862
|
-
format: typeof schema["const"] === "number" ? "number" : "string",
|
|
863
|
-
value: schema["const"]
|
|
864
|
-
}
|
|
865
|
-
},
|
|
866
|
-
...baseItems
|
|
867
|
-
];
|
|
868
|
-
}
|
|
869
|
-
return [{ keyword: _chunk4OLWDMEKcjs.schemaKeywords.null }];
|
|
870
|
-
}
|
|
871
|
-
if (schema.format) {
|
|
872
|
-
switch (schema.format) {
|
|
873
|
-
case "binary":
|
|
874
|
-
baseItems.push({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.blob });
|
|
875
|
-
return baseItems;
|
|
876
|
-
case "date-time":
|
|
877
|
-
if (options.dateType) {
|
|
878
|
-
if (options.dateType === "date") {
|
|
879
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.date, args: { type: "date" } });
|
|
880
|
-
return baseItems;
|
|
881
|
-
}
|
|
882
|
-
if (options.dateType === "stringOffset") {
|
|
883
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.datetime, args: { offset: true } });
|
|
884
|
-
return baseItems;
|
|
885
|
-
}
|
|
886
|
-
if (options.dateType === "stringLocal") {
|
|
887
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.datetime, args: { local: true } });
|
|
888
|
-
return baseItems;
|
|
889
|
-
}
|
|
890
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.datetime, args: { offset: false } });
|
|
891
|
-
return baseItems;
|
|
892
|
-
}
|
|
893
|
-
break;
|
|
894
|
-
case "date":
|
|
895
|
-
if (options.dateType) {
|
|
896
|
-
if (options.dateType === "date") {
|
|
897
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.date, args: { type: "date" } });
|
|
898
|
-
return baseItems;
|
|
899
|
-
}
|
|
900
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.date, args: { type: "string" } });
|
|
901
|
-
return baseItems;
|
|
902
|
-
}
|
|
903
|
-
break;
|
|
904
|
-
case "time":
|
|
905
|
-
if (options.dateType) {
|
|
906
|
-
if (options.dateType === "date") {
|
|
907
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.time, args: { type: "date" } });
|
|
908
|
-
return baseItems;
|
|
909
|
-
}
|
|
910
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.time, args: { type: "string" } });
|
|
911
|
-
return baseItems;
|
|
912
|
-
}
|
|
913
|
-
break;
|
|
914
|
-
case "uuid":
|
|
915
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.uuid });
|
|
916
|
-
break;
|
|
917
|
-
case "email":
|
|
918
|
-
case "idn-email":
|
|
919
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.email });
|
|
920
|
-
break;
|
|
921
|
-
case "uri":
|
|
922
|
-
case "ipv4":
|
|
923
|
-
case "ipv6":
|
|
924
|
-
case "uri-reference":
|
|
925
|
-
case "hostname":
|
|
926
|
-
case "idn-hostname":
|
|
927
|
-
baseItems.unshift({ keyword: _chunk4OLWDMEKcjs.schemaKeywords.url });
|
|
928
|
-
break;
|
|
929
|
-
default:
|
|
930
|
-
break;
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
if ("items" in schema || schema.type === "array") {
|
|
934
|
-
const min2 = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.minimum, () => ( schema.minLength)), () => ( schema.minItems)), () => ( void 0));
|
|
935
|
-
const max2 = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.maximum, () => ( schema.maxLength)), () => ( schema.maxItems)), () => ( void 0));
|
|
936
|
-
const items = this.buildSchemas({ schema: "items" in schema ? schema.items : [], name, parentName });
|
|
937
|
-
return [
|
|
938
|
-
{
|
|
939
|
-
keyword: _chunk4OLWDMEKcjs.schemaKeywords.array,
|
|
940
|
-
args: {
|
|
941
|
-
items,
|
|
942
|
-
min: min2,
|
|
943
|
-
max: max2
|
|
944
|
-
}
|
|
945
|
-
},
|
|
946
|
-
...baseItems.filter((item) => item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.min && item.keyword !== _chunk4OLWDMEKcjs.schemaKeywords.max)
|
|
947
|
-
];
|
|
948
|
-
}
|
|
949
|
-
if (schema.properties || schema.additionalProperties) {
|
|
950
|
-
return [..._chunkBDNSPC5Zcjs.__privateMethod.call(void 0, this, _parseProperties, parseProperties_fn).call(this, { schema, name }), ...baseItems];
|
|
951
|
-
}
|
|
952
|
-
if (schema.type) {
|
|
953
|
-
if (Array.isArray(schema.type)) {
|
|
954
|
-
const [type] = schema.type;
|
|
955
|
-
return [
|
|
956
|
-
...this.buildSchemas({
|
|
957
|
-
schema: {
|
|
958
|
-
...schema,
|
|
959
|
-
type
|
|
960
|
-
},
|
|
961
|
-
name,
|
|
962
|
-
parentName
|
|
963
|
-
}),
|
|
964
|
-
...baseItems
|
|
965
|
-
].filter(Boolean);
|
|
966
|
-
}
|
|
967
|
-
return [{ keyword: schema.type }, ...baseItems];
|
|
968
|
-
}
|
|
969
|
-
return [{ keyword: unknownReturn }];
|
|
970
|
-
};
|
|
971
|
-
var SchemaGenerator = _SchemaGenerator;
|
|
972
|
-
|
|
973
400
|
// src/index.ts
|
|
974
401
|
var definePluginDefault = pluginOas;
|
|
975
402
|
var src_default = definePluginDefault;
|
|
@@ -981,5 +408,5 @@ var src_default = definePluginDefault;
|
|
|
981
408
|
|
|
982
409
|
|
|
983
410
|
|
|
984
|
-
exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = SchemaGenerator; exports.default = src_default; exports.isKeyword =
|
|
411
|
+
exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkCTFUZW3Dcjs.SchemaGenerator; exports.default = src_default; exports.isKeyword = _chunkCTFUZW3Dcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkCTFUZW3Dcjs.schemaKeywords;
|
|
985
412
|
//# sourceMappingURL=index.cjs.map
|