@skmtc/core 0.46.0 → 0.47.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 +7 -1
- package/esm/context/ParseContext.d.ts +3 -0
- package/esm/context/ParseContext.js +17 -7
- package/esm/context/generateTypes.d.ts +2 -2
- package/esm/helpers/collateExamples.js +35 -17
- package/esm/mod.d.ts +1 -0
- package/esm/mod.js +1 -0
- package/esm/oas/intersection/Intersection.d.ts +122 -0
- package/esm/oas/intersection/Intersection.js +266 -0
- package/esm/oas/mediaType/jsonMediaType.d.ts +1 -1
- package/esm/oas/mediaType/jsonMediaType.js +3 -3
- package/esm/oas/requestBody/RequestBody.d.ts +1 -1
- package/esm/oas/requestBody/RequestBody.js +1 -1
- package/esm/oas/response/Response.d.ts +1 -1
- package/esm/oas/response/Response.js +1 -1
- package/esm/oas/schema/Schema.d.ts +4 -2
- package/esm/oas/schema/siblings.d.ts +10 -2
- package/esm/oas/schema/siblings.js +87 -22
- package/esm/oas/schemaPath/traverseSchema.d.ts +2 -0
- package/esm/oas/schemaPath/traverseSchema.js +40 -0
- package/esm/parse/allOfSystem.d.ts +3 -0
- package/esm/parse/allOfSystem.js +2 -1
- package/esm/parse/keptIntersection.d.ts +53 -0
- package/esm/parse/keptIntersection.js +155 -0
- package/esm/parse/keptRefs.d.ts +23 -0
- package/esm/parse/keptRefs.js +59 -0
- package/esm/parse/toCyclicRefs.d.ts +8 -0
- package/esm/parse/toCyclicRefs.js +126 -0
- package/esm/parse/toDeclaredTypes.d.ts +20 -0
- package/esm/parse/toDeclaredTypes.js +43 -0
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +8 -4
- package/esm/parse/v3-0/_merge-all-of/merge-union.js +7 -1
- package/esm/parse/v3-0/_merge-all-of/merge.js +13 -0
- package/esm/parse/v3-0/_merge-all-of/types.d.ts +3 -0
- package/esm/parse/v3-0/intersection/toIntersection.d.ts +12 -0
- package/esm/parse/v3-0/intersection/toIntersection.js +61 -0
- package/esm/parse/v3-0/schema/toSchemasV3.js +13 -1
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +8 -4
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +7 -1
- package/esm/parse/v3-1/_merge-all-of/merge.js +13 -0
- package/esm/parse/v3-1/_merge-all-of/types.d.ts +3 -0
- package/esm/parse/v3-1/intersection/toIntersection.d.ts +12 -0
- package/esm/parse/v3-1/intersection/toIntersection.js +61 -0
- package/esm/parse/v3-1/schema/toSchemasV3.js +15 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +8 -4
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +7 -1
- package/esm/parse/v3-2/_merge-all-of/merge.js +13 -0
- package/esm/parse/v3-2/_merge-all-of/types.d.ts +3 -0
- package/esm/parse/v3-2/intersection/toIntersection.d.ts +12 -0
- package/esm/parse/v3-2/intersection/toIntersection.js +61 -0
- package/esm/parse/v3-2/schema/toSchemasV3.js +15 -2
- package/esm/types/Settings.d.ts +9 -0
- package/esm/types/Settings.js +2 -1
- package/esm/types/TypeSystem.d.ts +17 -2
- package/package.json +1 -1
- package/script/context/ParseContext.d.ts +3 -0
- package/script/context/ParseContext.js +17 -7
- package/script/context/generateTypes.d.ts +2 -2
- package/script/helpers/collateExamples.js +35 -17
- package/script/mod.d.ts +1 -0
- package/script/mod.js +1 -0
- package/script/oas/intersection/Intersection.d.ts +122 -0
- package/script/oas/intersection/Intersection.js +270 -0
- package/script/oas/mediaType/jsonMediaType.d.ts +1 -1
- package/script/oas/mediaType/jsonMediaType.js +3 -3
- package/script/oas/requestBody/RequestBody.d.ts +1 -1
- package/script/oas/requestBody/RequestBody.js +1 -1
- package/script/oas/response/Response.d.ts +1 -1
- package/script/oas/response/Response.js +1 -1
- package/script/oas/schema/Schema.d.ts +4 -2
- package/script/oas/schema/siblings.d.ts +10 -2
- package/script/oas/schema/siblings.js +89 -23
- package/script/oas/schemaPath/traverseSchema.d.ts +2 -0
- package/script/oas/schemaPath/traverseSchema.js +40 -0
- package/script/parse/allOfSystem.d.ts +3 -0
- package/script/parse/allOfSystem.js +2 -1
- package/script/parse/keptIntersection.d.ts +53 -0
- package/script/parse/keptIntersection.js +164 -0
- package/script/parse/keptRefs.d.ts +23 -0
- package/script/parse/keptRefs.js +63 -0
- package/script/parse/toCyclicRefs.d.ts +8 -0
- package/script/parse/toCyclicRefs.js +130 -0
- package/script/parse/toDeclaredTypes.d.ts +20 -0
- package/script/parse/toDeclaredTypes.js +48 -0
- package/script/parse/v3-0/_merge-all-of/merge-intersection.js +8 -4
- package/script/parse/v3-0/_merge-all-of/merge-union.js +7 -1
- package/script/parse/v3-0/_merge-all-of/merge.js +13 -0
- package/script/parse/v3-0/_merge-all-of/types.d.ts +3 -0
- package/script/parse/v3-0/intersection/toIntersection.d.ts +12 -0
- package/script/parse/v3-0/intersection/toIntersection.js +65 -0
- package/script/parse/v3-0/schema/toSchemasV3.js +13 -1
- package/script/parse/v3-1/_merge-all-of/merge-intersection.js +8 -4
- package/script/parse/v3-1/_merge-all-of/merge-union.js +7 -1
- package/script/parse/v3-1/_merge-all-of/merge.js +13 -0
- package/script/parse/v3-1/_merge-all-of/types.d.ts +3 -0
- package/script/parse/v3-1/intersection/toIntersection.d.ts +12 -0
- package/script/parse/v3-1/intersection/toIntersection.js +65 -0
- package/script/parse/v3-1/schema/toSchemasV3.js +15 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.js +8 -4
- package/script/parse/v3-2/_merge-all-of/merge-union.js +7 -1
- package/script/parse/v3-2/_merge-all-of/merge.js +13 -0
- package/script/parse/v3-2/_merge-all-of/types.d.ts +3 -0
- package/script/parse/v3-2/intersection/toIntersection.d.ts +12 -0
- package/script/parse/v3-2/intersection/toIntersection.js +65 -0
- package/script/parse/v3-2/schema/toSchemasV3.js +15 -2
- package/script/types/Settings.d.ts +9 -0
- package/script/types/Settings.js +2 -1
- package/script/types/TypeSystem.d.ts +17 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toIntersection = void 0;
|
|
4
|
+
const Intersection_js_1 = require("../../../oas/intersection/Intersection.js");
|
|
5
|
+
const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
6
|
+
const anyOfSystem_js_1 = require("../../anyOfSystem.js");
|
|
7
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
8
|
+
const toSchemasV3_js_1 = require("../schema/toSchemasV3.js");
|
|
9
|
+
const toUnknown_js_1 = require("../unknown/toUnknown.js");
|
|
10
|
+
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
11
|
+
const parseNullable_js_1 = require("../_helpers/parseNullable.js");
|
|
12
|
+
const parseExample_js_1 = require("../_helpers/parseExample.js");
|
|
13
|
+
const parseDefault_js_1 = require("../_helpers/parseDefault.js");
|
|
14
|
+
const toExternalDocs_js_1 = require("../externalDocs/toExternalDocs.js");
|
|
15
|
+
const toIntersection = ({ value, members, stackTrail, context }) => {
|
|
16
|
+
const { nullable, value: valueWithoutNullable } = (0, parseNullable_js_1.parseNullable)({ value, context, stackTrail });
|
|
17
|
+
const { title, description, externalDocs, readOnly, writeOnly, deprecated, example: unparsedExample, default: unparsedDefaultValue, ...skipped } = valueWithoutNullable;
|
|
18
|
+
const example = (0, parseExample_js_1.parseExample)({
|
|
19
|
+
value: unparsedExample,
|
|
20
|
+
context,
|
|
21
|
+
parent: value,
|
|
22
|
+
nullable,
|
|
23
|
+
check: isPresent,
|
|
24
|
+
toMessage: item => `Removed invalid example. Expected a non-null value, got: ${item}`,
|
|
25
|
+
stackTrail
|
|
26
|
+
});
|
|
27
|
+
const defaultValue = (0, parseDefault_js_1.parseDefault)({
|
|
28
|
+
value: unparsedDefaultValue,
|
|
29
|
+
context,
|
|
30
|
+
parent: value,
|
|
31
|
+
nullable,
|
|
32
|
+
check: isPresent,
|
|
33
|
+
toMessage: item => `Removed invalid default. Expected a non-null value, got: ${item}`,
|
|
34
|
+
stackTrail
|
|
35
|
+
});
|
|
36
|
+
const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({
|
|
37
|
+
skipped,
|
|
38
|
+
parent: value,
|
|
39
|
+
context,
|
|
40
|
+
stackTrail,
|
|
41
|
+
parentType: 'schema:allOf'
|
|
42
|
+
});
|
|
43
|
+
// A member with no shape of its own (`{ description }`) is any value: the
|
|
44
|
+
// parser must not guess a type from its `example`.
|
|
45
|
+
const membersParsed = members.map(keptIntersection_js_1.withKeywordType).map((member, index) => stackTrail.trace(`${index}`, st => (0, refFns_js_1.isRef)(member) || (0, anyOfSystem_js_1.hasShapeKeyword)(member) || 'anyOf' in member || 'not' in member
|
|
46
|
+
? (0, toSchemasV3_js_1.toSchemaV3)({ schema: member, stackTrail: st, context })
|
|
47
|
+
: (0, toUnknown_js_1.toUnknown)({ value: member, stackTrail: st, context })));
|
|
48
|
+
return context.withStackTrail(stackTrail, () => new Intersection_js_1.OasIntersection({
|
|
49
|
+
title,
|
|
50
|
+
description,
|
|
51
|
+
externalDocs: stackTrail.trace('externalDocs', st => (0, toExternalDocs_js_1.toExternalDocs)({ externalDocs, stackTrail: st, context })),
|
|
52
|
+
nullable,
|
|
53
|
+
readOnly,
|
|
54
|
+
writeOnly,
|
|
55
|
+
deprecated,
|
|
56
|
+
default: defaultValue,
|
|
57
|
+
members: membersParsed,
|
|
58
|
+
example,
|
|
59
|
+
extensionFields
|
|
60
|
+
}, context));
|
|
61
|
+
};
|
|
62
|
+
exports.toIntersection = toIntersection;
|
|
63
|
+
// A value matches every member, so without resolving them the most we can
|
|
64
|
+
// check is that a present default/example is not `null` on a non-nullable schema.
|
|
65
|
+
const isPresent = (value) => value !== null && value !== undefined;
|
|
@@ -13,6 +13,8 @@ const toBoolean_js_1 = require("../boolean/toBoolean.js");
|
|
|
13
13
|
const toString_js_1 = require("../string/toString.js");
|
|
14
14
|
const toUnknown_js_1 = require("../unknown/toUnknown.js");
|
|
15
15
|
const toUnion_js_1 = require("../union/toUnion.js");
|
|
16
|
+
const toIntersection_js_1 = require("../intersection/toIntersection.js");
|
|
17
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
16
18
|
const refFns_js_2 = require("../../../helpers/refFns.js");
|
|
17
19
|
const toSiblingKeywords_js_1 = require("../../toSiblingKeywords.js");
|
|
18
20
|
const allOfSystem_js_1 = require("../../allOfSystem.js");
|
|
@@ -187,7 +189,17 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
187
189
|
});
|
|
188
190
|
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
189
191
|
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
190
|
-
|
|
192
|
+
const parts = system.keptRefs && (0, keptIntersection_js_1.toIntersectionParts)(merged, system.keptRefs);
|
|
193
|
+
if (parts === undefined) {
|
|
194
|
+
return (0, exports.toSchemaV3)({ schema: merged, stackTrail: st, context });
|
|
195
|
+
}
|
|
196
|
+
const { own, members: kept } = (0, keptIntersection_js_1.toSiteIntersection)(parts);
|
|
197
|
+
const [only] = kept;
|
|
198
|
+
if (kept.length > 1 || only === undefined) {
|
|
199
|
+
return (0, toIntersection_js_1.toIntersection)({ value: own, members: kept, stackTrail: st, context });
|
|
200
|
+
}
|
|
201
|
+
// An intersection of one ref is that ref with the keywords beside it.
|
|
202
|
+
return (0, exports.toSchemaV3)({ schema: (0, isEmpty_js_1.isEmpty)(own) ? only : { ...own, allOf: [only] }, stackTrail: st, context });
|
|
191
203
|
});
|
|
192
204
|
}
|
|
193
205
|
if ('oneOf' in schema && Array.isArray(schema.oneOf)) {
|
|
@@ -3,18 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mergeIntersection = void 0;
|
|
4
4
|
const decompose_intersection_js_1 = require("./decompose-intersection.js");
|
|
5
5
|
const merge_js_1 = require("./merge.js");
|
|
6
|
+
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
7
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
6
8
|
const mergeIntersection = ({ schema, getRef, normalize, system }) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
// Where a ref stays a ref, the wrapper's own keywords stay beside the `allOf`.
|
|
10
|
+
const { own, rest } = system.keptRefs?.holds(schema) ? (0, keptIntersection_js_1.splitOwnKeywords)(schema) : { own: {}, rest: schema };
|
|
11
|
+
const decomposed = (0, decompose_intersection_js_1.decomposeIntersection)({ schema: rest });
|
|
12
|
+
if (decomposed.length === 1 && (0, isEmpty_js_1.isEmpty)(own)) {
|
|
9
13
|
return decomposed[0];
|
|
10
14
|
}
|
|
11
15
|
const dereffed = decomposed.map(decomposed => {
|
|
12
|
-
return '$ref' in decomposed ? getRef(decomposed) : decomposed;
|
|
16
|
+
return '$ref' in decomposed && !system.keptRefs?.has(decomposed) ? getRef(decomposed) : decomposed;
|
|
13
17
|
});
|
|
14
18
|
const result = dereffed.reduce((acc, decomposed) => {
|
|
15
19
|
const merged = (0, merge_js_1.mergeSchemasOrRefs)({ first: acc, second: decomposed, getRef, normalize, system });
|
|
16
20
|
return merged;
|
|
17
21
|
}, {});
|
|
18
|
-
return result;
|
|
22
|
+
return (0, keptIntersection_js_1.withOwnKeywords)(result, own);
|
|
19
23
|
};
|
|
20
24
|
exports.mergeIntersection = mergeIntersection;
|
|
@@ -106,7 +106,13 @@ const mergeCrossProduct = ({ first, second, getRef, normalize, system, groupType
|
|
|
106
106
|
secondGroup.length !== secondMembers.length;
|
|
107
107
|
const mergedGroup = mergePairs({
|
|
108
108
|
pairs: (0, cross_product_js_1.crossProduct)(withGroupSiblings({ schema: first, members: firstGroup, getRef, normalize, system, groupType }), withGroupSiblings({ schema: second, members: secondGroup, getRef, normalize, system, groupType })),
|
|
109
|
-
merge: ([firstItem, secondItem], pairSystem) =>
|
|
109
|
+
merge: ([firstItem, secondItem], pairSystem) => {
|
|
110
|
+
// A kept ref is not read into the merge, so its type is compared here.
|
|
111
|
+
if (pairSystem.allOf === 'strict' && system.keptRefs?.contradict(firstItem, secondItem)) {
|
|
112
|
+
throw new Error('Cannot merge schemas: a member has another type than the reference');
|
|
113
|
+
}
|
|
114
|
+
return (0, merge_js_1.mergeSchemasOrRefs)({ first: firstItem, second: secondItem, getRef, normalize, system: pairSystem });
|
|
115
|
+
},
|
|
110
116
|
system
|
|
111
117
|
});
|
|
112
118
|
// A nested group is spread into this one below; its `nullable` carries over.
|
|
@@ -20,6 +20,7 @@ const merge_intersection_js_1 = require("./merge-intersection.js");
|
|
|
20
20
|
const merge_union_js_1 = require("./merge-union.js");
|
|
21
21
|
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
22
22
|
const nullable_merge_js_1 = require("./nullable-merge.js");
|
|
23
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
23
24
|
const anyOfSystem_js_1 = require("../../anyOfSystem.js");
|
|
24
25
|
const mergeSchemasOrRefs = ({ first: inputFirst, second: inputSecond, getRef, normalize, system }) => {
|
|
25
26
|
const first = (0, refFns_js_1.isRef)(inputFirst)
|
|
@@ -28,6 +29,18 @@ const mergeSchemasOrRefs = ({ first: inputFirst, second: inputSecond, getRef, no
|
|
|
28
29
|
const second = (0, refFns_js_1.isRef)(inputSecond)
|
|
29
30
|
? inputSecond
|
|
30
31
|
: (0, merge_union_js_1.collapseNullOnlyUnion)(normalize(inputSecond), normalize);
|
|
32
|
+
const { keptRefs } = system;
|
|
33
|
+
if (keptRefs && ((0, keptIntersection_js_1.toIntersectionParts)(first, keptRefs) || (0, keptIntersection_js_1.toIntersectionParts)(second, keptRefs))) {
|
|
34
|
+
return (0, keptIntersection_js_1.mergeKept)({
|
|
35
|
+
first,
|
|
36
|
+
second,
|
|
37
|
+
keptRefs,
|
|
38
|
+
merge: (a, b) => (0, exports.mergeSchemasOrRefs)({ first: a, second: b, getRef, normalize, system }),
|
|
39
|
+
mergeAllOf: schema => (0, merge_intersection_js_1.mergeIntersection)({ schema, getRef, normalize, system: (0, merge_union_js_1.toOwnSystem)(system) }),
|
|
40
|
+
readRef: ref => normalize(getRef(ref)),
|
|
41
|
+
normalize
|
|
42
|
+
});
|
|
43
|
+
}
|
|
31
44
|
if (containsRef(first, second)) {
|
|
32
45
|
return mergeWithRef({ first, second, getRef, normalize, system });
|
|
33
46
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
import type { KeptRefs } from '../../keptRefs.js';
|
|
3
4
|
export type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObject;
|
|
4
5
|
/**
|
|
5
6
|
* Maps a schema the merge reads (a member, a nested property or item schema,
|
|
@@ -28,6 +29,8 @@ export type MergeSystem = {
|
|
|
28
29
|
anyOf?: 'union' | 'unknown';
|
|
29
30
|
/** The keywords the merge read as any value: `anyOf` under `system.anyOf: unknown`. */
|
|
30
31
|
unknown?: Set<string>;
|
|
32
|
+
/** The refs that stay refs (`system.intersections`). Left out: every ref is followed. */
|
|
33
|
+
keptRefs?: KeptRefs;
|
|
31
34
|
};
|
|
32
35
|
export type OneOfObject = {
|
|
33
36
|
oneOf?: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
3
|
+
import type { StackTrail } from '../../../context/StackTrail.js';
|
|
4
|
+
import { OasIntersection } from '../../../oas/intersection/Intersection.js';
|
|
5
|
+
export type ToIntersectionArgs = {
|
|
6
|
+
/** The intersection's own keywords, without `allOf`. */
|
|
7
|
+
value: OpenAPIV3.SchemaObject;
|
|
8
|
+
members: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
9
|
+
stackTrail: StackTrail;
|
|
10
|
+
context: ParseContextType;
|
|
11
|
+
};
|
|
12
|
+
export declare const toIntersection: ({ value, members, stackTrail, context }: ToIntersectionArgs) => OasIntersection;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toIntersection = void 0;
|
|
4
|
+
const Intersection_js_1 = require("../../../oas/intersection/Intersection.js");
|
|
5
|
+
const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
6
|
+
const anyOfSystem_js_1 = require("../../anyOfSystem.js");
|
|
7
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
8
|
+
const toSchemasV3_js_1 = require("../schema/toSchemasV3.js");
|
|
9
|
+
const toUnknown_js_1 = require("../unknown/toUnknown.js");
|
|
10
|
+
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
11
|
+
const parseNullable_js_1 = require("../_helpers/parseNullable.js");
|
|
12
|
+
const parseExample_js_1 = require("../_helpers/parseExample.js");
|
|
13
|
+
const parseDefault_js_1 = require("../_helpers/parseDefault.js");
|
|
14
|
+
const toExternalDocs_js_1 = require("../externalDocs/toExternalDocs.js");
|
|
15
|
+
const toIntersection = ({ value, members, stackTrail, context }) => {
|
|
16
|
+
const { nullable, value: valueWithoutNullable } = (0, parseNullable_js_1.parseNullable)({ value, context, stackTrail });
|
|
17
|
+
const { title, description, externalDocs, readOnly, writeOnly, deprecated, example: unparsedExample, default: unparsedDefaultValue, ...skipped } = valueWithoutNullable;
|
|
18
|
+
const example = (0, parseExample_js_1.parseExample)({
|
|
19
|
+
value: unparsedExample,
|
|
20
|
+
context,
|
|
21
|
+
parent: value,
|
|
22
|
+
nullable,
|
|
23
|
+
check: isPresent,
|
|
24
|
+
toMessage: item => `Removed invalid example. Expected a non-null value, got: ${item}`,
|
|
25
|
+
stackTrail
|
|
26
|
+
});
|
|
27
|
+
const defaultValue = (0, parseDefault_js_1.parseDefault)({
|
|
28
|
+
value: unparsedDefaultValue,
|
|
29
|
+
context,
|
|
30
|
+
parent: value,
|
|
31
|
+
nullable,
|
|
32
|
+
check: isPresent,
|
|
33
|
+
toMessage: item => `Removed invalid default. Expected a non-null value, got: ${item}`,
|
|
34
|
+
stackTrail
|
|
35
|
+
});
|
|
36
|
+
const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({
|
|
37
|
+
skipped,
|
|
38
|
+
parent: value,
|
|
39
|
+
context,
|
|
40
|
+
stackTrail,
|
|
41
|
+
parentType: 'schema:allOf'
|
|
42
|
+
});
|
|
43
|
+
// A member with no shape of its own (`{ description }`) is any value: the
|
|
44
|
+
// parser must not guess a type from its `example`.
|
|
45
|
+
const membersParsed = members.map(keptIntersection_js_1.withKeywordType).map((member, index) => stackTrail.trace(`${index}`, st => (0, refFns_js_1.isRef)(member) || (0, anyOfSystem_js_1.hasShapeKeyword)(member) || 'anyOf' in member || 'not' in member
|
|
46
|
+
? (0, toSchemasV3_js_1.toSchemaV3)({ schema: member, stackTrail: st, context })
|
|
47
|
+
: (0, toUnknown_js_1.toUnknown)({ value: member, stackTrail: st, context })));
|
|
48
|
+
return context.withStackTrail(stackTrail, () => new Intersection_js_1.OasIntersection({
|
|
49
|
+
title,
|
|
50
|
+
description,
|
|
51
|
+
externalDocs: stackTrail.trace('externalDocs', st => (0, toExternalDocs_js_1.toExternalDocs)({ externalDocs, stackTrail: st, context })),
|
|
52
|
+
nullable,
|
|
53
|
+
readOnly,
|
|
54
|
+
writeOnly,
|
|
55
|
+
deprecated,
|
|
56
|
+
default: defaultValue,
|
|
57
|
+
members: membersParsed,
|
|
58
|
+
example,
|
|
59
|
+
extensionFields
|
|
60
|
+
}, context));
|
|
61
|
+
};
|
|
62
|
+
exports.toIntersection = toIntersection;
|
|
63
|
+
// A value matches every member, so without resolving them the most we can
|
|
64
|
+
// check is that a present default/example is not `null` on a non-nullable schema.
|
|
65
|
+
const isPresent = (value) => value !== null && value !== undefined;
|
|
@@ -13,6 +13,8 @@ const toBoolean_js_1 = require("../boolean/toBoolean.js");
|
|
|
13
13
|
const toString_js_1 = require("../string/toString.js");
|
|
14
14
|
const toUnknown_js_1 = require("../unknown/toUnknown.js");
|
|
15
15
|
const toUnion_js_1 = require("../union/toUnion.js");
|
|
16
|
+
const toIntersection_js_1 = require("../intersection/toIntersection.js");
|
|
17
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
16
18
|
const refFns_js_2 = require("../../../helpers/refFns.js");
|
|
17
19
|
const toSiblingKeywords_js_1 = require("../../toSiblingKeywords.js");
|
|
18
20
|
const allOfSystem_js_1 = require("../../allOfSystem.js");
|
|
@@ -137,8 +139,9 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
141
|
const members = Array.isArray(allOf) ? allOf : [];
|
|
142
|
+
const bareRef = context.keptRefs?.copy(schema, { $ref }) ?? { $ref };
|
|
140
143
|
return Object.keys(keywords).length > 0
|
|
141
|
-
? (0, exports.toSchemaV3)({ schema: { ...keywords, allOf: [
|
|
144
|
+
? (0, exports.toSchemaV3)({ schema: { ...keywords, allOf: [bareRef, ...members] }, stackTrail, context })
|
|
142
145
|
: (0, toRefV31_js_1.toRefV31)({ ref: schema, refType: 'schema', stackTrail, context });
|
|
143
146
|
}
|
|
144
147
|
// OpenAPI `not` has no faithful TypeScript representation: a generated type
|
|
@@ -240,7 +243,17 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
240
243
|
});
|
|
241
244
|
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
242
245
|
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
243
|
-
|
|
246
|
+
const parts = system.keptRefs && (0, keptIntersection_js_1.toIntersectionParts)(merged, system.keptRefs);
|
|
247
|
+
if (parts === undefined) {
|
|
248
|
+
return (0, exports.toSchemaV3)({ schema: merged, stackTrail: st, context });
|
|
249
|
+
}
|
|
250
|
+
const { own, members: kept } = (0, keptIntersection_js_1.toSiteIntersection)(parts);
|
|
251
|
+
const [only] = kept;
|
|
252
|
+
if (kept.length > 1 || only === undefined) {
|
|
253
|
+
return (0, toIntersection_js_1.toIntersection)({ value: own, members: kept, stackTrail: st, context });
|
|
254
|
+
}
|
|
255
|
+
// An intersection of one ref is that ref with the keywords beside it.
|
|
256
|
+
return (0, exports.toSchemaV3)({ schema: (0, isEmpty_js_1.isEmpty)(own) ? only : { ...own, allOf: [only] }, stackTrail: st, context });
|
|
244
257
|
});
|
|
245
258
|
}
|
|
246
259
|
// A `oneOf`/`anyOf` of only null members reads as nullable, not as an
|
|
@@ -3,18 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mergeIntersection = void 0;
|
|
4
4
|
const decompose_intersection_js_1 = require("./decompose-intersection.js");
|
|
5
5
|
const merge_js_1 = require("./merge.js");
|
|
6
|
+
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
7
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
6
8
|
const mergeIntersection = ({ schema, getRef, normalize, system }) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
// Where a ref stays a ref, the wrapper's own keywords stay beside the `allOf`.
|
|
10
|
+
const { own, rest } = system.keptRefs?.holds(schema) ? (0, keptIntersection_js_1.splitOwnKeywords)(schema) : { own: {}, rest: schema };
|
|
11
|
+
const decomposed = (0, decompose_intersection_js_1.decomposeIntersection)({ schema: rest });
|
|
12
|
+
if (decomposed.length === 1 && (0, isEmpty_js_1.isEmpty)(own)) {
|
|
9
13
|
return decomposed[0];
|
|
10
14
|
}
|
|
11
15
|
const dereffed = decomposed.map(decomposed => {
|
|
12
|
-
return '$ref' in decomposed ? getRef(decomposed) : decomposed;
|
|
16
|
+
return '$ref' in decomposed && !system.keptRefs?.has(decomposed) ? getRef(decomposed) : decomposed;
|
|
13
17
|
});
|
|
14
18
|
const result = dereffed.reduce((acc, decomposed) => {
|
|
15
19
|
const merged = (0, merge_js_1.mergeSchemasOrRefs)({ first: acc, second: decomposed, getRef, normalize, system });
|
|
16
20
|
return merged;
|
|
17
21
|
}, {});
|
|
18
|
-
return result;
|
|
22
|
+
return (0, keptIntersection_js_1.withOwnKeywords)(result, own);
|
|
19
23
|
};
|
|
20
24
|
exports.mergeIntersection = mergeIntersection;
|
|
@@ -106,7 +106,13 @@ const mergeCrossProduct = ({ first, second, getRef, normalize, system, groupType
|
|
|
106
106
|
secondGroup.length !== secondMembers.length;
|
|
107
107
|
const mergedGroup = mergePairs({
|
|
108
108
|
pairs: (0, cross_product_js_1.crossProduct)(withGroupSiblings({ schema: first, members: firstGroup, getRef, normalize, system, groupType }), withGroupSiblings({ schema: second, members: secondGroup, getRef, normalize, system, groupType })),
|
|
109
|
-
merge: ([firstItem, secondItem], pairSystem) =>
|
|
109
|
+
merge: ([firstItem, secondItem], pairSystem) => {
|
|
110
|
+
// A kept ref is not read into the merge, so its type is compared here.
|
|
111
|
+
if (pairSystem.allOf === 'strict' && system.keptRefs?.contradict(firstItem, secondItem)) {
|
|
112
|
+
throw new Error('Cannot merge schemas: a member has another type than the reference');
|
|
113
|
+
}
|
|
114
|
+
return (0, merge_js_1.mergeSchemasOrRefs)({ first: firstItem, second: secondItem, getRef, normalize, system: pairSystem });
|
|
115
|
+
},
|
|
110
116
|
system
|
|
111
117
|
});
|
|
112
118
|
// A nested group is spread into this one below; its `nullable` carries over.
|
|
@@ -20,6 +20,7 @@ const merge_intersection_js_1 = require("./merge-intersection.js");
|
|
|
20
20
|
const merge_union_js_1 = require("./merge-union.js");
|
|
21
21
|
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
22
22
|
const nullable_merge_js_1 = require("./nullable-merge.js");
|
|
23
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
23
24
|
const anyOfSystem_js_1 = require("../../anyOfSystem.js");
|
|
24
25
|
const mergeSchemasOrRefs = ({ first: inputFirst, second: inputSecond, getRef, normalize, system }) => {
|
|
25
26
|
const first = (0, refFns_js_1.isRef)(inputFirst)
|
|
@@ -28,6 +29,18 @@ const mergeSchemasOrRefs = ({ first: inputFirst, second: inputSecond, getRef, no
|
|
|
28
29
|
const second = (0, refFns_js_1.isRef)(inputSecond)
|
|
29
30
|
? inputSecond
|
|
30
31
|
: (0, merge_union_js_1.collapseNullOnlyUnion)(normalize(inputSecond), normalize);
|
|
32
|
+
const { keptRefs } = system;
|
|
33
|
+
if (keptRefs && ((0, keptIntersection_js_1.toIntersectionParts)(first, keptRefs) || (0, keptIntersection_js_1.toIntersectionParts)(second, keptRefs))) {
|
|
34
|
+
return (0, keptIntersection_js_1.mergeKept)({
|
|
35
|
+
first,
|
|
36
|
+
second,
|
|
37
|
+
keptRefs,
|
|
38
|
+
merge: (a, b) => (0, exports.mergeSchemasOrRefs)({ first: a, second: b, getRef, normalize, system }),
|
|
39
|
+
mergeAllOf: schema => (0, merge_intersection_js_1.mergeIntersection)({ schema, getRef, normalize, system: (0, merge_union_js_1.toOwnSystem)(system) }),
|
|
40
|
+
readRef: ref => normalize(getRef(ref)),
|
|
41
|
+
normalize
|
|
42
|
+
});
|
|
43
|
+
}
|
|
31
44
|
if (containsRef(first, second)) {
|
|
32
45
|
return mergeWithRef({ first, second, getRef, normalize, system });
|
|
33
46
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
import type { KeptRefs } from '../../keptRefs.js';
|
|
3
4
|
export type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObject;
|
|
4
5
|
/**
|
|
5
6
|
* Maps a schema the merge reads (a member, a nested property or item schema,
|
|
@@ -28,6 +29,8 @@ export type MergeSystem = {
|
|
|
28
29
|
anyOf?: 'union' | 'unknown';
|
|
29
30
|
/** The keywords the merge read as any value: `anyOf` under `system.anyOf: unknown`. */
|
|
30
31
|
unknown?: Set<string>;
|
|
32
|
+
/** The refs that stay refs (`system.intersections`). Left out: every ref is followed. */
|
|
33
|
+
keptRefs?: KeptRefs;
|
|
31
34
|
};
|
|
32
35
|
export type OneOfObject = {
|
|
33
36
|
oneOf?: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
3
|
+
import type { StackTrail } from '../../../context/StackTrail.js';
|
|
4
|
+
import { OasIntersection } from '../../../oas/intersection/Intersection.js';
|
|
5
|
+
export type ToIntersectionArgs = {
|
|
6
|
+
/** The intersection's own keywords, without `allOf`. */
|
|
7
|
+
value: OpenAPIV3.SchemaObject;
|
|
8
|
+
members: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
9
|
+
stackTrail: StackTrail;
|
|
10
|
+
context: ParseContextType;
|
|
11
|
+
};
|
|
12
|
+
export declare const toIntersection: ({ value, members, stackTrail, context }: ToIntersectionArgs) => OasIntersection;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toIntersection = void 0;
|
|
4
|
+
const Intersection_js_1 = require("../../../oas/intersection/Intersection.js");
|
|
5
|
+
const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
6
|
+
const anyOfSystem_js_1 = require("../../anyOfSystem.js");
|
|
7
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
8
|
+
const toSchemasV3_js_1 = require("../schema/toSchemasV3.js");
|
|
9
|
+
const toUnknown_js_1 = require("../unknown/toUnknown.js");
|
|
10
|
+
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
11
|
+
const parseNullable_js_1 = require("../_helpers/parseNullable.js");
|
|
12
|
+
const parseExample_js_1 = require("../_helpers/parseExample.js");
|
|
13
|
+
const parseDefault_js_1 = require("../_helpers/parseDefault.js");
|
|
14
|
+
const toExternalDocs_js_1 = require("../externalDocs/toExternalDocs.js");
|
|
15
|
+
const toIntersection = ({ value, members, stackTrail, context }) => {
|
|
16
|
+
const { nullable, value: valueWithoutNullable } = (0, parseNullable_js_1.parseNullable)({ value, context, stackTrail });
|
|
17
|
+
const { title, description, externalDocs, readOnly, writeOnly, deprecated, example: unparsedExample, default: unparsedDefaultValue, ...skipped } = valueWithoutNullable;
|
|
18
|
+
const example = (0, parseExample_js_1.parseExample)({
|
|
19
|
+
value: unparsedExample,
|
|
20
|
+
context,
|
|
21
|
+
parent: value,
|
|
22
|
+
nullable,
|
|
23
|
+
check: isPresent,
|
|
24
|
+
toMessage: item => `Removed invalid example. Expected a non-null value, got: ${item}`,
|
|
25
|
+
stackTrail
|
|
26
|
+
});
|
|
27
|
+
const defaultValue = (0, parseDefault_js_1.parseDefault)({
|
|
28
|
+
value: unparsedDefaultValue,
|
|
29
|
+
context,
|
|
30
|
+
parent: value,
|
|
31
|
+
nullable,
|
|
32
|
+
check: isPresent,
|
|
33
|
+
toMessage: item => `Removed invalid default. Expected a non-null value, got: ${item}`,
|
|
34
|
+
stackTrail
|
|
35
|
+
});
|
|
36
|
+
const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({
|
|
37
|
+
skipped,
|
|
38
|
+
parent: value,
|
|
39
|
+
context,
|
|
40
|
+
stackTrail,
|
|
41
|
+
parentType: 'schema:allOf'
|
|
42
|
+
});
|
|
43
|
+
// A member with no shape of its own (`{ description }`) is any value: the
|
|
44
|
+
// parser must not guess a type from its `example`.
|
|
45
|
+
const membersParsed = members.map(keptIntersection_js_1.withKeywordType).map((member, index) => stackTrail.trace(`${index}`, st => (0, refFns_js_1.isRef)(member) || (0, anyOfSystem_js_1.hasShapeKeyword)(member) || 'anyOf' in member || 'not' in member
|
|
46
|
+
? (0, toSchemasV3_js_1.toSchemaV3)({ schema: member, stackTrail: st, context })
|
|
47
|
+
: (0, toUnknown_js_1.toUnknown)({ value: member, stackTrail: st, context })));
|
|
48
|
+
return context.withStackTrail(stackTrail, () => new Intersection_js_1.OasIntersection({
|
|
49
|
+
title,
|
|
50
|
+
description,
|
|
51
|
+
externalDocs: stackTrail.trace('externalDocs', st => (0, toExternalDocs_js_1.toExternalDocs)({ externalDocs, stackTrail: st, context })),
|
|
52
|
+
nullable,
|
|
53
|
+
readOnly,
|
|
54
|
+
writeOnly,
|
|
55
|
+
deprecated,
|
|
56
|
+
default: defaultValue,
|
|
57
|
+
members: membersParsed,
|
|
58
|
+
example,
|
|
59
|
+
extensionFields
|
|
60
|
+
}, context));
|
|
61
|
+
};
|
|
62
|
+
exports.toIntersection = toIntersection;
|
|
63
|
+
// A value matches every member, so without resolving them the most we can
|
|
64
|
+
// check is that a present default/example is not `null` on a non-nullable schema.
|
|
65
|
+
const isPresent = (value) => value !== null && value !== undefined;
|
|
@@ -13,6 +13,8 @@ const toBoolean_js_1 = require("../boolean/toBoolean.js");
|
|
|
13
13
|
const toString_js_1 = require("../string/toString.js");
|
|
14
14
|
const toUnknown_js_1 = require("../unknown/toUnknown.js");
|
|
15
15
|
const toUnion_js_1 = require("../union/toUnion.js");
|
|
16
|
+
const toIntersection_js_1 = require("../intersection/toIntersection.js");
|
|
17
|
+
const keptIntersection_js_1 = require("../../keptIntersection.js");
|
|
16
18
|
const refFns_js_2 = require("../../../helpers/refFns.js");
|
|
17
19
|
const toSiblingKeywords_js_1 = require("../../toSiblingKeywords.js");
|
|
18
20
|
const allOfSystem_js_1 = require("../../allOfSystem.js");
|
|
@@ -137,8 +139,9 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
141
|
const members = Array.isArray(allOf) ? allOf : [];
|
|
142
|
+
const bareRef = context.keptRefs?.copy(schema, { $ref }) ?? { $ref };
|
|
140
143
|
return Object.keys(keywords).length > 0
|
|
141
|
-
? (0, exports.toSchemaV3)({ schema: { ...keywords, allOf: [
|
|
144
|
+
? (0, exports.toSchemaV3)({ schema: { ...keywords, allOf: [bareRef, ...members] }, stackTrail, context })
|
|
142
145
|
: (0, toRefV31_js_1.toRefV31)({ ref: schema, refType: 'schema', stackTrail, context });
|
|
143
146
|
}
|
|
144
147
|
// OpenAPI `not` has no faithful TypeScript representation: a generated type
|
|
@@ -240,7 +243,17 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
240
243
|
});
|
|
241
244
|
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
242
245
|
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
243
|
-
|
|
246
|
+
const parts = system.keptRefs && (0, keptIntersection_js_1.toIntersectionParts)(merged, system.keptRefs);
|
|
247
|
+
if (parts === undefined) {
|
|
248
|
+
return (0, exports.toSchemaV3)({ schema: merged, stackTrail: st, context });
|
|
249
|
+
}
|
|
250
|
+
const { own, members: kept } = (0, keptIntersection_js_1.toSiteIntersection)(parts);
|
|
251
|
+
const [only] = kept;
|
|
252
|
+
if (kept.length > 1 || only === undefined) {
|
|
253
|
+
return (0, toIntersection_js_1.toIntersection)({ value: own, members: kept, stackTrail: st, context });
|
|
254
|
+
}
|
|
255
|
+
// An intersection of one ref is that ref with the keywords beside it.
|
|
256
|
+
return (0, exports.toSchemaV3)({ schema: (0, isEmpty_js_1.isEmpty)(own) ? only : { ...own, allOf: [only] }, stackTrail: st, context });
|
|
244
257
|
});
|
|
245
258
|
}
|
|
246
259
|
// A `oneOf`/`anyOf` of only null members reads as nullable, not as an
|
|
@@ -470,6 +470,15 @@ export type SystemSettings = {
|
|
|
470
470
|
* default, `[]`, lists none.
|
|
471
471
|
*/
|
|
472
472
|
danglingRefs?: DanglingRefKind[];
|
|
473
|
+
/**
|
|
474
|
+
* The `$ref`s that stay refs where core would merge their target in: the
|
|
475
|
+
* members of an `allOf`, and the members of a `oneOf` or `anyOf` with a
|
|
476
|
+
* keyword beside it that merges into each member. The schema is then an
|
|
477
|
+
* `OasIntersection` of the refs and one schema that the other members merge
|
|
478
|
+
* into. `cycles` (the default): a `$ref` whose target leads back to the
|
|
479
|
+
* schema that holds it. `all`: each one. `merge`: none.
|
|
480
|
+
*/
|
|
481
|
+
intersections?: 'merge' | 'cycles' | 'all';
|
|
473
482
|
};
|
|
474
483
|
export type ClientSettings = {
|
|
475
484
|
/** Base output path for generated files */
|
package/script/types/Settings.js
CHANGED
|
@@ -228,7 +228,8 @@ exports.systemSettings = v.object({
|
|
|
228
228
|
responseContradictions: v.optional(v.picklist(['strict', 'unknown'])),
|
|
229
229
|
not: v.optional(v.picklist(['strict', 'unknown'])),
|
|
230
230
|
anyOf: v.optional(v.picklist(['union', 'unknown'])),
|
|
231
|
-
danglingRefs: v.optional(v.array(v.picklist(exports.danglingRefKinds)))
|
|
231
|
+
danglingRefs: v.optional(v.array(v.picklist(exports.danglingRefKinds))),
|
|
232
|
+
intersections: v.optional(v.picklist(['merge', 'cycles', 'all']))
|
|
232
233
|
});
|
|
233
234
|
exports.clientSettings = v.object({
|
|
234
235
|
basePath: v.optional(v.pipe(v.string(), v.check(basePath => !(0, normalizeWorkspacePath_js_1.isAbsolutePath)(basePath), 'basePath must be relative to the SKMTC root (the directory containing .skmtc/); ' +
|
|
@@ -19,7 +19,7 @@ import type { RefParts } from '../helpers/refFns.js';
|
|
|
19
19
|
* ## Type Categories
|
|
20
20
|
*
|
|
21
21
|
* - **Primitive Types**: `string`, `number`, `integer`, `boolean`, `null`
|
|
22
|
-
* - **Complex Types**: `array`, `object`, `union`
|
|
22
|
+
* - **Complex Types**: `array`, `object`, `union`, `intersection`
|
|
23
23
|
* - **Special Types**: `void`, `never`, `unknown`, `custom`
|
|
24
24
|
* - **Reference Types**: `ref` for schema references
|
|
25
25
|
*
|
|
@@ -63,7 +63,7 @@ import type { RefParts } from '../helpers/refFns.js';
|
|
|
63
63
|
* }
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
export type TypeSystemValue = TypeSystemArray | TypeSystemObject | TypeSystemUnion | TypeSystemString | TypeSystemNumber | TypeSystemInteger | TypeSystemBoolean | TypeSystemUnknown | TypeSystemVoid | TypeSystemNever | TypeSystemRef | TypeSystemNull | TypeSystemCustom;
|
|
66
|
+
export type TypeSystemValue = TypeSystemArray | TypeSystemObject | TypeSystemUnion | TypeSystemIntersection | TypeSystemString | TypeSystemNumber | TypeSystemInteger | TypeSystemBoolean | TypeSystemUnknown | TypeSystemVoid | TypeSystemNever | TypeSystemRef | TypeSystemNull | TypeSystemCustom;
|
|
67
67
|
/**
|
|
68
68
|
* Type system representation of a reference to another schema.
|
|
69
69
|
*
|
|
@@ -360,6 +360,17 @@ export type TypeSystemUnion = {
|
|
|
360
360
|
/** Optional generator-specific key for tracking */
|
|
361
361
|
generatorKey?: GeneratorKey;
|
|
362
362
|
};
|
|
363
|
+
/** Type system representation of an intersection: a value that is of every member's type. */
|
|
364
|
+
export type TypeSystemIntersection = {
|
|
365
|
+
/** Discriminator for the intersection type */
|
|
366
|
+
type: 'intersection';
|
|
367
|
+
/** The types a value has all of */
|
|
368
|
+
members: TypeSystemValue[];
|
|
369
|
+
/** Type modifiers (optional, nullable, etc.) */
|
|
370
|
+
modifiers: Modifiers;
|
|
371
|
+
/** Optional generator-specific key for tracking */
|
|
372
|
+
generatorKey?: GeneratorKey;
|
|
373
|
+
};
|
|
363
374
|
/**
|
|
364
375
|
* Type system representation of object types.
|
|
365
376
|
*
|
|
@@ -464,6 +475,10 @@ export type SchemaToTypeSystemMap = {
|
|
|
464
475
|
source: OasSchema;
|
|
465
476
|
output: TypeSystemUnion;
|
|
466
477
|
};
|
|
478
|
+
intersection: {
|
|
479
|
+
source: OasSchema;
|
|
480
|
+
output: TypeSystemIntersection;
|
|
481
|
+
};
|
|
467
482
|
custom: {
|
|
468
483
|
source: CustomValue;
|
|
469
484
|
output: TypeSystemCustom;
|