oas 32.1.9 → 32.1.11
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/analyzer/index.cjs +6 -6
- package/dist/analyzer/index.js +4 -4
- package/dist/{chunk-WRZUJO3I.js → chunk-2J4VKLIT.js} +4 -4
- package/dist/{chunk-YPR7YTHM.cjs → chunk-3MTU2ESP.cjs} +1 -1
- package/dist/{chunk-YPR7YTHM.cjs.map → chunk-3MTU2ESP.cjs.map} +1 -1
- package/dist/{chunk-NG4A45EE.cjs → chunk-DNLCD3K6.cjs} +153 -141
- package/dist/chunk-DNLCD3K6.cjs.map +1 -0
- package/dist/{chunk-Q6ABRA4U.cjs → chunk-FGPV2UXT.cjs} +28 -28
- package/dist/{chunk-Q6ABRA4U.cjs.map → chunk-FGPV2UXT.cjs.map} +1 -1
- package/dist/{chunk-55H65L6J.js → chunk-JCBISKOK.js} +37 -25
- package/dist/chunk-JCBISKOK.js.map +1 -0
- package/dist/{chunk-MNOEMVCF.js → chunk-PSNTODZL.js} +1 -1
- package/dist/{chunk-MNOEMVCF.js.map → chunk-PSNTODZL.js.map} +1 -1
- package/dist/{chunk-7BR3G6FM.js → chunk-QINBUHP2.js} +179 -48
- package/dist/chunk-QINBUHP2.js.map +1 -0
- package/dist/{chunk-KZCEPS4J.cjs → chunk-X7KOY66H.cjs} +206 -75
- package/dist/chunk-X7KOY66H.cjs.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +4 -4
- package/dist/operation/index.cjs +4 -4
- package/dist/operation/index.js +3 -3
- package/dist/reducer/index.cjs +49 -28
- package/dist/reducer/index.cjs.map +1 -1
- package/dist/reducer/index.js +23 -2
- package/dist/reducer/index.js.map +1 -1
- package/dist/types.cjs +2 -2
- package/dist/types.d.cts +3 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +1 -1
- package/dist/utils.cjs +3 -3
- package/dist/utils.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-55H65L6J.js.map +0 -1
- package/dist/chunk-7BR3G6FM.js.map +0 -1
- package/dist/chunk-KZCEPS4J.cjs.map +0 -1
- package/dist/chunk-NG4A45EE.cjs.map +0 -1
- /package/dist/{chunk-WRZUJO3I.js.map → chunk-2J4VKLIT.js.map} +0 -0
|
@@ -6,7 +6,7 @@ var _chunkAYA3UT4Lcjs = require('./chunk-AYA3UT4L.cjs');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk3MTU2ESPcjs = require('./chunk-3MTU2ESP.cjs');
|
|
10
10
|
|
|
11
11
|
// src/lib/matches-mimetype.ts
|
|
12
12
|
function matchesMediaType(types2, mediaType) {
|
|
@@ -118,7 +118,7 @@ function dereferenceRef(value, definition, seenRefs = /* @__PURE__ */ new Set())
|
|
|
118
118
|
if (value === void 0) {
|
|
119
119
|
return void 0;
|
|
120
120
|
}
|
|
121
|
-
if (
|
|
121
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, value)) {
|
|
122
122
|
if (!definition) {
|
|
123
123
|
return value;
|
|
124
124
|
}
|
|
@@ -129,7 +129,7 @@ function dereferenceRef(value, definition, seenRefs = /* @__PURE__ */ new Set())
|
|
|
129
129
|
seenRefs.add(ref);
|
|
130
130
|
try {
|
|
131
131
|
const dereferenced = findRef(ref, definition);
|
|
132
|
-
if (
|
|
132
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, dereferenced)) {
|
|
133
133
|
return dereferenceRef(dereferenced, definition, seenRefs);
|
|
134
134
|
}
|
|
135
135
|
return {
|
|
@@ -141,6 +141,24 @@ function dereferenceRef(value, definition, seenRefs = /* @__PURE__ */ new Set())
|
|
|
141
141
|
}
|
|
142
142
|
return value;
|
|
143
143
|
}
|
|
144
|
+
function dereferenceRefDeep(value, definition, seenRefs = /* @__PURE__ */ new Set()) {
|
|
145
|
+
if (value === null || value === void 0) return value;
|
|
146
|
+
if (typeof value !== "object") return value;
|
|
147
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, value)) {
|
|
148
|
+
if (!definition) return value;
|
|
149
|
+
const resolved = dereferenceRef(value, definition, seenRefs);
|
|
150
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, resolved)) return resolved;
|
|
151
|
+
return dereferenceRefDeep(resolved, definition, seenRefs);
|
|
152
|
+
}
|
|
153
|
+
if (Array.isArray(value)) {
|
|
154
|
+
return value.map((entry) => dereferenceRefDeep(entry, definition, seenRefs));
|
|
155
|
+
}
|
|
156
|
+
const out = {};
|
|
157
|
+
for (const key of Object.keys(value)) {
|
|
158
|
+
out[key] = dereferenceRefDeep(value[key], definition, seenRefs);
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
144
162
|
function getDereferencingOptions(circularRefs) {
|
|
145
163
|
return {
|
|
146
164
|
resolve: {
|
|
@@ -162,7 +180,7 @@ function collectRefsInSchema(schema) {
|
|
|
162
180
|
const refs = /* @__PURE__ */ new Set();
|
|
163
181
|
if (!schema || typeof schema !== "object") return refs;
|
|
164
182
|
const obj = schema;
|
|
165
|
-
if (
|
|
183
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, obj)) {
|
|
166
184
|
refs.add(obj.$ref);
|
|
167
185
|
}
|
|
168
186
|
for (const value of Object.values(obj)) {
|
|
@@ -209,6 +227,15 @@ function getRefPathSegments(ref) {
|
|
|
209
227
|
}
|
|
210
228
|
return path;
|
|
211
229
|
}
|
|
230
|
+
function isArrayIndexSegment(seg) {
|
|
231
|
+
return /^\d+$/.test(seg);
|
|
232
|
+
}
|
|
233
|
+
function childShouldBeSchemaArray(parentKey, childSeg) {
|
|
234
|
+
if (!childSeg || !isArrayIndexSegment(childSeg)) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
return parentKey === "allOf" || parentKey === "anyOf" || parentKey === "oneOf";
|
|
238
|
+
}
|
|
212
239
|
function mergeReferencedSchemasIntoRoot(root, refToSchema) {
|
|
213
240
|
for (const [ref, schema] of refToSchema) {
|
|
214
241
|
const segments = getRefPathSegments(ref);
|
|
@@ -216,16 +243,57 @@ function mergeReferencedSchemasIntoRoot(root, refToSchema) {
|
|
|
216
243
|
continue;
|
|
217
244
|
}
|
|
218
245
|
let current = root;
|
|
246
|
+
let pathInvalid = false;
|
|
219
247
|
for (let i = 0; i < segments.length - 1; i++) {
|
|
220
248
|
const seg = segments[i];
|
|
221
|
-
|
|
222
|
-
if (
|
|
249
|
+
const nextSeg = segments[i + 1];
|
|
250
|
+
if (Array.isArray(current)) {
|
|
251
|
+
const idx = Number(seg);
|
|
252
|
+
if (!Number.isInteger(idx) || idx < 0) {
|
|
253
|
+
pathInvalid = true;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
const slot = current[idx];
|
|
257
|
+
if (slot === void 0 || slot === null || typeof slot !== "object" || Array.isArray(slot)) {
|
|
258
|
+
const nextObj = {};
|
|
259
|
+
current[idx] = nextObj;
|
|
260
|
+
current = nextObj;
|
|
261
|
+
} else {
|
|
262
|
+
current = slot;
|
|
263
|
+
}
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
const cur = current;
|
|
267
|
+
const existing = cur[seg];
|
|
268
|
+
if (childShouldBeSchemaArray(seg, nextSeg)) {
|
|
269
|
+
if (!Array.isArray(existing)) {
|
|
270
|
+
cur[seg] = [];
|
|
271
|
+
}
|
|
272
|
+
current = cur[seg];
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
let next;
|
|
276
|
+
if (existing !== void 0 && existing !== null && typeof existing === "object" && !Array.isArray(existing)) {
|
|
277
|
+
next = existing;
|
|
278
|
+
} else {
|
|
223
279
|
next = {};
|
|
224
|
-
|
|
280
|
+
cur[seg] = next;
|
|
225
281
|
}
|
|
226
282
|
current = next;
|
|
227
283
|
}
|
|
228
|
-
|
|
284
|
+
if (pathInvalid) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const lastSeg = segments[segments.length - 1];
|
|
288
|
+
if (Array.isArray(current)) {
|
|
289
|
+
const idx = Number(lastSeg);
|
|
290
|
+
if (!Number.isInteger(idx) || idx < 0) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
current[idx] = schema;
|
|
294
|
+
} else {
|
|
295
|
+
current[lastSeg] = schema;
|
|
296
|
+
}
|
|
229
297
|
}
|
|
230
298
|
}
|
|
231
299
|
|
|
@@ -248,7 +316,7 @@ function allOfReferencesSchema(schema, targetSchemaName) {
|
|
|
248
316
|
if (!schema || typeof schema !== "object") return false;
|
|
249
317
|
if (!("allOf" in schema) || !Array.isArray(schema.allOf)) return false;
|
|
250
318
|
return schema.allOf.some((item) => {
|
|
251
|
-
if (
|
|
319
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, item)) {
|
|
252
320
|
const refParts = item.$ref.split("/");
|
|
253
321
|
const refSchemaName = refParts[refParts.length - 1];
|
|
254
322
|
return refSchemaName === targetSchemaName;
|
|
@@ -350,12 +418,41 @@ var UNSUPPORTED_SCHEMA_PROPS = [
|
|
|
350
418
|
"externalDocs",
|
|
351
419
|
"xml"
|
|
352
420
|
];
|
|
421
|
+
var mergeAllOfSchemasOptions = {
|
|
422
|
+
ignoreAdditionalProperties: true,
|
|
423
|
+
resolvers: {
|
|
424
|
+
// `merge-json-schema-allof` by default takes the first `description` when you're merging an
|
|
425
|
+
// `allOf` but because generally when you're merging two schemas together with an `allOf` you
|
|
426
|
+
// want data in the subsequent schemas to be applied to the first and `description` should be a
|
|
427
|
+
// part of that.
|
|
428
|
+
description: (obj) => {
|
|
429
|
+
return obj.slice(-1)[0];
|
|
430
|
+
},
|
|
431
|
+
// `merge-json-schema-allof` doesn't support merging enum arrays but since that's a safe and
|
|
432
|
+
// simple operation as enums always contain primitives we can handle it ourselves with a custom
|
|
433
|
+
// resolver. We intersect the arrays so that child schemas can narrow a parent's broad enum
|
|
434
|
+
// (e.g. [1,2,20,50] ∩ [1] = [1]).
|
|
435
|
+
//
|
|
436
|
+
// We unfortunately need to cast our return value as `any[]` because the internal types of
|
|
437
|
+
// `merge-json-schema-allof`'s `enum` resolver are not portable.
|
|
438
|
+
enum: (obj) => {
|
|
439
|
+
const arrays = obj;
|
|
440
|
+
const intersection = arrays.reduce((acc, e) => acc.filter((v) => e.includes(v)));
|
|
441
|
+
return intersection.length > 0 ? intersection : arrays.reduce((acc, e) => acc.concat(e), []);
|
|
442
|
+
},
|
|
443
|
+
// For any unknown keywords (e.g., `example`, `format`, `x-readme-ref-name`), we fallback to
|
|
444
|
+
// using the `title` resolver (which uses the first value found).
|
|
445
|
+
// https://github.com/mokkabonna/json-schema-merge-allof/blob/ea2e48ee34415022de5a50c236eb4793a943ad11/src/index.js#L292
|
|
446
|
+
// https://github.com/mokkabonna/json-schema-merge-allof/blob/ea2e48ee34415022de5a50c236eb4793a943ad11/README.md?plain=1#L147
|
|
447
|
+
defaultResolver: _jsonschemamergeallof2.default.options.resolvers.title
|
|
448
|
+
}
|
|
449
|
+
};
|
|
353
450
|
var PENDING_SCHEMA = { __pending: true };
|
|
354
451
|
function isPendingSchema(s) {
|
|
355
452
|
return isObject(s) && "__pending" in s && s.__pending === true;
|
|
356
453
|
}
|
|
357
454
|
function getSchemaVersionString(schema, api) {
|
|
358
|
-
if (
|
|
455
|
+
if (_chunk3MTU2ESPcjs.isOpenAPI30.call(void 0, api)) {
|
|
359
456
|
return "http://json-schema.org/draft-04/schema#";
|
|
360
457
|
}
|
|
361
458
|
if (schema.$schema) {
|
|
@@ -369,6 +466,14 @@ function getSchemaVersionString(schema, api) {
|
|
|
369
466
|
function isPolymorphicSchema(schema) {
|
|
370
467
|
return "allOf" in schema || "anyOf" in schema || "oneOf" in schema;
|
|
371
468
|
}
|
|
469
|
+
function shouldFoldParentItemsIntoPolymorphBranch(item) {
|
|
470
|
+
if (!isObject(item)) return false;
|
|
471
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, item)) return true;
|
|
472
|
+
const branch = item;
|
|
473
|
+
if (!("type" in branch) || branch.type === void 0) return true;
|
|
474
|
+
if (!hasSchemaType(branch, "array")) return false;
|
|
475
|
+
return !("items" in branch) || branch.items === void 0;
|
|
476
|
+
}
|
|
372
477
|
function isEmptyPolymorphicSchema(list) {
|
|
373
478
|
if (!Array.isArray(list)) return false;
|
|
374
479
|
if (!list.length) return true;
|
|
@@ -378,14 +483,18 @@ function isEmptyPolymorphicSchema(list) {
|
|
|
378
483
|
return Array.isArray(branch) ? !branch.length : !Object.keys(branch).length;
|
|
379
484
|
});
|
|
380
485
|
}
|
|
381
|
-
function inlinePropertyRefsForMerge(schema, usedSchemas) {
|
|
486
|
+
function inlinePropertyRefsForMerge(schema, usedSchemas, refLogger) {
|
|
382
487
|
const out = structuredClone(schema);
|
|
383
488
|
if (!("properties" in out) || typeof out.properties !== "object" || out.properties === null) {
|
|
384
489
|
return out;
|
|
385
490
|
}
|
|
386
491
|
for (const key of Object.keys(out.properties)) {
|
|
387
492
|
const val = out.properties[key];
|
|
388
|
-
if (
|
|
493
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, val)) {
|
|
494
|
+
if (val.$ref.startsWith("#/paths/")) {
|
|
495
|
+
refLogger(val.$ref, "ref");
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
389
498
|
const resolved = usedSchemas.get(val.$ref);
|
|
390
499
|
if (resolved !== void 0 && !isPendingSchema(resolved)) {
|
|
391
500
|
out.properties[key] = {
|
|
@@ -415,7 +524,7 @@ function resolveAndCacheRefSchema({
|
|
|
415
524
|
if (_optionalChain([refsEmittedAsStub, 'optionalAccess', _18 => _18.has, 'call', _19 => _19(ref)])) {
|
|
416
525
|
return { $ref: ref };
|
|
417
526
|
}
|
|
418
|
-
if (!
|
|
527
|
+
if (!_chunk3MTU2ESPcjs.isRef.call(void 0, existing)) {
|
|
419
528
|
return structuredClone(existing);
|
|
420
529
|
}
|
|
421
530
|
return { $ref: ref };
|
|
@@ -429,7 +538,7 @@ function resolveAndCacheRefSchema({
|
|
|
429
538
|
let resolved;
|
|
430
539
|
try {
|
|
431
540
|
const dereferenced = dereferenceRef(schema, definition, seenRefs);
|
|
432
|
-
if (
|
|
541
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, dereferenced)) {
|
|
433
542
|
refLogger(dereferenced.$ref, "ref");
|
|
434
543
|
let converted2;
|
|
435
544
|
try {
|
|
@@ -463,7 +572,7 @@ function resolveAndCacheRefSchema({
|
|
|
463
572
|
}
|
|
464
573
|
try {
|
|
465
574
|
const dereferenced = dereferenceRef(schema, definition, seenRefs);
|
|
466
|
-
if (
|
|
575
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, dereferenced)) {
|
|
467
576
|
let converted2;
|
|
468
577
|
try {
|
|
469
578
|
const pointer = ref.startsWith("#") ? decodeURIComponent(ref.substring(1)) : ref;
|
|
@@ -534,7 +643,7 @@ function searchForValueByPropAndPointer(property, pointer, schemas = []) {
|
|
|
534
643
|
}
|
|
535
644
|
function toJSONSchema(data, opts) {
|
|
536
645
|
let schema = data === true ? {} : { ...data };
|
|
537
|
-
const schemaAdditionalProperties =
|
|
646
|
+
const schemaAdditionalProperties = _chunk3MTU2ESPcjs.isSchema.call(void 0, schema) ? schema.additionalProperties : null;
|
|
538
647
|
const {
|
|
539
648
|
addEnumsToDescriptions,
|
|
540
649
|
currentLocation,
|
|
@@ -579,7 +688,7 @@ function toJSONSchema(data, opts) {
|
|
|
579
688
|
usedSchemas,
|
|
580
689
|
refsEmittedAsStub
|
|
581
690
|
};
|
|
582
|
-
if (
|
|
691
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, schema)) {
|
|
583
692
|
if (definition && usedSchemas) {
|
|
584
693
|
const resolved = resolveAndCacheRefSchema({
|
|
585
694
|
schema,
|
|
@@ -590,7 +699,7 @@ function toJSONSchema(data, opts) {
|
|
|
590
699
|
returnMode: "ref",
|
|
591
700
|
refLogger
|
|
592
701
|
});
|
|
593
|
-
const { $ref: _$ref, ...siblings } = schema;
|
|
702
|
+
const { $ref: _$ref, properties: _propertiesWithRef, ...siblings } = schema;
|
|
594
703
|
if (Object.keys(siblings).length > 0) {
|
|
595
704
|
return { ...resolved, ...siblings };
|
|
596
705
|
}
|
|
@@ -599,16 +708,45 @@ function toJSONSchema(data, opts) {
|
|
|
599
708
|
refLogger(schema.$ref, "ref");
|
|
600
709
|
return schema;
|
|
601
710
|
}
|
|
602
|
-
if (
|
|
711
|
+
if (_chunk3MTU2ESPcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild)) {
|
|
603
712
|
if ("allOf" in schema && Array.isArray(schema.allOf)) {
|
|
713
|
+
if ("properties" in schema && schema.properties !== void 0 && typeof schema.properties === "object" && schema.properties !== null && !Array.isArray(schema.properties)) {
|
|
714
|
+
const preprocessed = {};
|
|
715
|
+
for (const prop of Object.keys(schema.properties)) {
|
|
716
|
+
const val = schema.properties[prop];
|
|
717
|
+
if (Array.isArray(val) || typeof val === "object" && val !== null) {
|
|
718
|
+
preprocessed[prop] = toJSONSchema(val, {
|
|
719
|
+
...polyOptions,
|
|
720
|
+
currentLocation: `${currentLocation}/${encodePointer(prop)}`,
|
|
721
|
+
prevDefaultSchemas,
|
|
722
|
+
prevExampleSchemas
|
|
723
|
+
});
|
|
724
|
+
} else {
|
|
725
|
+
preprocessed[prop] = val;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
schema = { ...schema, properties: preprocessed };
|
|
729
|
+
}
|
|
604
730
|
let allOfSchemas = schema.allOf;
|
|
605
731
|
if (definition && usedSchemas) {
|
|
606
|
-
const allOfOptions =
|
|
732
|
+
const allOfOptions = allOfSchemas.length > 1 ? { ...polyOptions, refLogger: () => {
|
|
607
733
|
} } : polyOptions;
|
|
608
|
-
allOfSchemas =
|
|
609
|
-
if (
|
|
610
|
-
|
|
611
|
-
|
|
734
|
+
allOfSchemas = allOfSchemas.map((item) => {
|
|
735
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, item)) {
|
|
736
|
+
if (Object.keys(item).length === 1) {
|
|
737
|
+
return resolveAndCacheRefSchema({
|
|
738
|
+
schema: item,
|
|
739
|
+
definition,
|
|
740
|
+
usedSchemas,
|
|
741
|
+
seenRefs,
|
|
742
|
+
conversionOptions: allOfOptions,
|
|
743
|
+
returnMode: "converted",
|
|
744
|
+
refLogger
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
const { $ref, ...siblings } = item;
|
|
748
|
+
const resolved = resolveAndCacheRefSchema({
|
|
749
|
+
schema: { $ref },
|
|
612
750
|
definition,
|
|
613
751
|
usedSchemas,
|
|
614
752
|
seenRefs,
|
|
@@ -616,45 +754,29 @@ function toJSONSchema(data, opts) {
|
|
|
616
754
|
returnMode: "converted",
|
|
617
755
|
refLogger
|
|
618
756
|
});
|
|
757
|
+
if (!Object.keys(siblings).length) {
|
|
758
|
+
return resolved;
|
|
759
|
+
}
|
|
760
|
+
const siblingSchema = toJSONSchema(siblings, allOfOptions);
|
|
761
|
+
try {
|
|
762
|
+
return _jsonschemamergeallof2.default.call(void 0,
|
|
763
|
+
{ allOf: [resolved, siblingSchema] },
|
|
764
|
+
mergeAllOfSchemasOptions
|
|
765
|
+
);
|
|
766
|
+
} catch (e8) {
|
|
767
|
+
return resolved;
|
|
768
|
+
}
|
|
619
769
|
}
|
|
620
770
|
return toJSONSchema(item, allOfOptions);
|
|
621
771
|
});
|
|
622
772
|
schema = {
|
|
623
773
|
...schema,
|
|
624
|
-
allOf: allOfSchemas.map((s) => inlinePropertyRefsForMerge(s, usedSchemas))
|
|
774
|
+
allOf: allOfSchemas.map((s) => inlinePropertyRefsForMerge(s, usedSchemas, refLogger))
|
|
625
775
|
};
|
|
626
776
|
}
|
|
627
777
|
try {
|
|
628
|
-
schema = _jsonschemamergeallof2.default.call(void 0, schema,
|
|
629
|
-
|
|
630
|
-
resolvers: {
|
|
631
|
-
// `merge-json-schema-allof` by default takes the first `description` when you're
|
|
632
|
-
// merging an `allOf` but because generally when you're merging two schemas together
|
|
633
|
-
// with an `allOf` you want data in the subsequent schemas to be applied to the first
|
|
634
|
-
// and `description` should be a part of that.
|
|
635
|
-
description: (obj) => {
|
|
636
|
-
return obj.slice(-1)[0];
|
|
637
|
-
},
|
|
638
|
-
// `merge-json-schema-allof` doesn't support merging enum arrays but since that's a
|
|
639
|
-
// safe and simple operation as enums always contain primitives we can handle it
|
|
640
|
-
// ourselves with a custom resolver. We intersect the arrays so that child schemas
|
|
641
|
-
// can narrow a parent's broad enum (e.g. [1,2,20,50] ∩ [1] = [1]).
|
|
642
|
-
//
|
|
643
|
-
// We unfortunately need to cast our return value as `any[]` because the internal types
|
|
644
|
-
// of `merge-json-schema-allof`'s `enum` resolver are not portable.
|
|
645
|
-
enum: (obj) => {
|
|
646
|
-
const arrays = obj;
|
|
647
|
-
const intersection = arrays.reduce((acc, e) => acc.filter((v) => e.includes(v)));
|
|
648
|
-
return intersection.length > 0 ? intersection : arrays.reduce((acc, e) => acc.concat(e), []);
|
|
649
|
-
},
|
|
650
|
-
// for any unknown keywords (e.g., `example`, `format`, `x-readme-ref-name`),
|
|
651
|
-
// we fallback to using the title resolver (which uses the first value found).
|
|
652
|
-
// https://github.com/mokkabonna/json-schema-merge-allof/blob/ea2e48ee34415022de5a50c236eb4793a943ad11/src/index.js#L292
|
|
653
|
-
// https://github.com/mokkabonna/json-schema-merge-allof/blob/ea2e48ee34415022de5a50c236eb4793a943ad11/README.md?plain=1#L147
|
|
654
|
-
defaultResolver: _jsonschemamergeallof2.default.options.resolvers.title
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
} catch (e8) {
|
|
778
|
+
schema = _jsonschemamergeallof2.default.call(void 0, schema, mergeAllOfSchemasOptions);
|
|
779
|
+
} catch (e9) {
|
|
658
780
|
const { ...schemaWithoutAllOf } = schema;
|
|
659
781
|
schema = schemaWithoutAllOf;
|
|
660
782
|
delete schema.allOf;
|
|
@@ -662,7 +784,7 @@ function toJSONSchema(data, opts) {
|
|
|
662
784
|
collectRefsInSchema(schema).forEach((ref) => {
|
|
663
785
|
refLogger(ref, "ref");
|
|
664
786
|
});
|
|
665
|
-
if (
|
|
787
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, schema)) {
|
|
666
788
|
refLogger(schema.$ref, "ref");
|
|
667
789
|
return schema;
|
|
668
790
|
}
|
|
@@ -687,12 +809,16 @@ function toJSONSchema(data, opts) {
|
|
|
687
809
|
itemOptions
|
|
688
810
|
);
|
|
689
811
|
} else if ("items" in schema) {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
812
|
+
if (shouldFoldParentItemsIntoPolymorphBranch(item)) {
|
|
813
|
+
schema[polyType][idx] = toJSONSchema(
|
|
814
|
+
{
|
|
815
|
+
allOf: [item, { items: schema.items }]
|
|
816
|
+
},
|
|
817
|
+
itemOptions
|
|
818
|
+
);
|
|
819
|
+
} else {
|
|
820
|
+
schema[polyType][idx] = toJSONSchema(item, itemOptions);
|
|
821
|
+
}
|
|
696
822
|
} else {
|
|
697
823
|
schema[polyType][idx] = toJSONSchema(item, itemOptions);
|
|
698
824
|
}
|
|
@@ -716,7 +842,7 @@ function toJSONSchema(data, opts) {
|
|
|
716
842
|
delete childSchema.anyOf;
|
|
717
843
|
}
|
|
718
844
|
}
|
|
719
|
-
if (definition && usedSchemas &&
|
|
845
|
+
if (definition && usedSchemas && _chunk3MTU2ESPcjs.isRef.call(void 0, childSchema)) {
|
|
720
846
|
const resolved = usedSchemas.get(childSchema.$ref);
|
|
721
847
|
if (resolved && typeof resolved === "object" && !isPendingSchema(resolved)) {
|
|
722
848
|
if ("discriminator" in resolved) {
|
|
@@ -837,7 +963,7 @@ function toJSONSchema(data, opts) {
|
|
|
837
963
|
}
|
|
838
964
|
}
|
|
839
965
|
}
|
|
840
|
-
if (
|
|
966
|
+
if (_chunk3MTU2ESPcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild)) {
|
|
841
967
|
if ("default" in schema && isObject(schema.default)) {
|
|
842
968
|
prevDefaultSchemas.push({ default: schema.default });
|
|
843
969
|
}
|
|
@@ -861,7 +987,7 @@ function toJSONSchema(data, opts) {
|
|
|
861
987
|
let currentExample = example;
|
|
862
988
|
if (name === "$ref") {
|
|
863
989
|
currentExample = dereferenceRef({ $ref: currentExample }, definition, seenRefs);
|
|
864
|
-
if (!currentExample ||
|
|
990
|
+
if (!currentExample || _chunk3MTU2ESPcjs.isRef.call(void 0, currentExample)) {
|
|
865
991
|
refLogger(currentExample.$ref, "ref");
|
|
866
992
|
return;
|
|
867
993
|
}
|
|
@@ -901,7 +1027,7 @@ function toJSONSchema(data, opts) {
|
|
|
901
1027
|
}
|
|
902
1028
|
if (hasSchemaType(schema, "array")) {
|
|
903
1029
|
if ("items" in schema && schema.items !== void 0) {
|
|
904
|
-
if (!(definition && usedSchemas) && !Array.isArray(schema.items) && Object.keys(schema.items).length === 1 &&
|
|
1030
|
+
if (!(definition && usedSchemas) && !Array.isArray(schema.items) && Object.keys(schema.items).length === 1 && _chunk3MTU2ESPcjs.isRef.call(void 0, schema.items)) {
|
|
905
1031
|
refLogger(schema.items.$ref, "ref");
|
|
906
1032
|
} else if (schema.items !== true) {
|
|
907
1033
|
schema.items = toJSONSchema(schema.items, {
|
|
@@ -977,13 +1103,13 @@ function toJSONSchema(data, opts) {
|
|
|
977
1103
|
}
|
|
978
1104
|
}
|
|
979
1105
|
}
|
|
980
|
-
if (
|
|
1106
|
+
if (_chunk3MTU2ESPcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild) && globalDefaults && Object.keys(globalDefaults).length > 0 && currentLocation) {
|
|
981
1107
|
try {
|
|
982
1108
|
const userJwtDefault = _jsonpointer2.default.get(globalDefaults, currentLocation);
|
|
983
1109
|
if (userJwtDefault) {
|
|
984
1110
|
schema.default = userJwtDefault;
|
|
985
1111
|
}
|
|
986
|
-
} catch (
|
|
1112
|
+
} catch (e10) {
|
|
987
1113
|
}
|
|
988
1114
|
}
|
|
989
1115
|
if ("default" in schema && typeof schema.default !== "undefined") {
|
|
@@ -999,7 +1125,7 @@ function toJSONSchema(data, opts) {
|
|
|
999
1125
|
schema.default = foundDefault;
|
|
1000
1126
|
}
|
|
1001
1127
|
}
|
|
1002
|
-
if (
|
|
1128
|
+
if (_chunk3MTU2ESPcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild) && "enum" in schema && Array.isArray(schema.enum)) {
|
|
1003
1129
|
schema.enum = Array.from(new Set(schema.enum));
|
|
1004
1130
|
if (addEnumsToDescriptions) {
|
|
1005
1131
|
const enums = schema.enum.filter((v) => v !== void 0 && (typeof v !== "string" || v.trim() !== "")).map((str) => `\`${str}\``).join(" ");
|
|
@@ -1037,6 +1163,9 @@ ${enums}`;
|
|
|
1037
1163
|
}
|
|
1038
1164
|
if ("items" in schema) {
|
|
1039
1165
|
delete schema.items;
|
|
1166
|
+
if ("type" in schema && schema.type === "array") {
|
|
1167
|
+
delete schema.type;
|
|
1168
|
+
}
|
|
1040
1169
|
}
|
|
1041
1170
|
}
|
|
1042
1171
|
}
|
|
@@ -1105,9 +1234,9 @@ function getParametersAsJSONSchema(operation, api, opts) {
|
|
|
1105
1234
|
examples: Object.values(mediaTypeObject.examples || {}).map((ex) => {
|
|
1106
1235
|
let example = ex;
|
|
1107
1236
|
if (!example) return void 0;
|
|
1108
|
-
if (
|
|
1237
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, example)) {
|
|
1109
1238
|
example = dereferenceRef(example, operation.api);
|
|
1110
|
-
if (!example ||
|
|
1239
|
+
if (!example || _chunk3MTU2ESPcjs.isRef.call(void 0, example)) return void 0;
|
|
1111
1240
|
}
|
|
1112
1241
|
return example.value;
|
|
1113
1242
|
}).filter((item) => item !== void 0)
|
|
@@ -1234,7 +1363,7 @@ function getParametersAsJSONSchema(operation, api, opts) {
|
|
|
1234
1363
|
}
|
|
1235
1364
|
try {
|
|
1236
1365
|
const resolved = dereferenceRef({ $ref: ref }, api, seenRefs);
|
|
1237
|
-
if (
|
|
1366
|
+
if (_chunk3MTU2ESPcjs.isRef.call(void 0, resolved)) return void 0;
|
|
1238
1367
|
const converted = toJSONSchema(structuredClone(resolved), {
|
|
1239
1368
|
...baseSchemaOptions,
|
|
1240
1369
|
usedSchemas,
|
|
@@ -1242,7 +1371,7 @@ function getParametersAsJSONSchema(operation, api, opts) {
|
|
|
1242
1371
|
});
|
|
1243
1372
|
usedSchemas.set(ref, converted);
|
|
1244
1373
|
return converted;
|
|
1245
|
-
} catch (
|
|
1374
|
+
} catch (e11) {
|
|
1246
1375
|
return void 0;
|
|
1247
1376
|
}
|
|
1248
1377
|
});
|
|
@@ -1281,5 +1410,7 @@ var SERVER_VARIABLE_REGEX = /{([-_a-zA-Z0-9:.[\]]+)}/g;
|
|
|
1281
1410
|
|
|
1282
1411
|
|
|
1283
1412
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
exports.isObject = isObject; exports.isPrimitive = isPrimitive; exports.decorateComponentSchemasWithRefName = decorateComponentSchemasWithRefName; exports.decodePointer = decodePointer; exports.dereferenceRef = dereferenceRef; exports.dereferenceRefDeep = dereferenceRefDeep; exports.getDereferencingOptions = getDereferencingOptions; exports.collectRefsInSchema = collectRefsInSchema; exports.filterRequiredRefsToReferenced = filterRequiredRefsToReferenced; exports.mergeReferencedSchemasIntoRoot = mergeReferencedSchemasIntoRoot; exports.matches_mimetype_default = matches_mimetype_default; exports.getParameterContentType = getParameterContentType; exports.cloneObject = cloneObject; exports.applyDiscriminatorOneOfToUsedSchemas = applyDiscriminatorOneOfToUsedSchemas; exports.getSchemaVersionString = getSchemaVersionString; exports.toJSONSchema = toJSONSchema; exports.types = types; exports.getParametersAsJSONSchema = getParametersAsJSONSchema; exports.supportedMethods = supportedMethods; exports.SERVER_VARIABLE_REGEX = SERVER_VARIABLE_REGEX;
|
|
1416
|
+
//# sourceMappingURL=chunk-X7KOY66H.cjs.map
|