@skmtc/core 0.34.0 → 0.35.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/esm/context/generateTypes.d.ts +2 -2
- package/esm/context/generateTypes.js +5 -0
- package/esm/parse/descriptiveFields.d.ts +36 -0
- package/esm/parse/descriptiveFields.js +56 -0
- package/esm/parse/isPlainObject.d.ts +2 -0
- package/esm/parse/isPlainObject.js +2 -0
- package/esm/parse/toComponentEntries.d.ts +29 -0
- package/esm/parse/toComponentEntries.js +31 -0
- package/esm/parse/toPresentInfo.d.ts +30 -0
- package/esm/parse/toPresentInfo.js +40 -0
- package/esm/parse/v3-0/_merge-all-of/merge-bounds.d.ts +7 -0
- package/esm/parse/v3-0/_merge-all-of/merge-bounds.js +46 -0
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -20
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -20
- package/esm/parse/v3-0/components/toComponentsV3.js +2 -2
- package/esm/parse/v3-0/externalDocs/toExternalDocs.d.ts +3 -1
- package/esm/parse/v3-0/externalDocs/toExternalDocs.js +9 -8
- package/esm/parse/v3-0/header/toHeadersV3.d.ts +12 -0
- package/esm/parse/v3-0/header/toHeadersV3.js +20 -0
- package/esm/parse/v3-0/info/toInfoV3.d.ts +2 -1
- package/esm/parse/v3-0/info/toInfoV3.js +15 -4
- package/esm/parse/v3-0/requestBody/toRequestBodiesV3.js +9 -9
- package/esm/parse/v3-0/tag/toTagsV3.js +7 -2
- package/esm/parse/v3-1/_merge-all-of/decompose-union.d.ts +2 -0
- package/esm/parse/v3-1/_merge-all-of/decompose-union.js +3 -1
- package/esm/parse/v3-1/_merge-all-of/merge-bounds.d.ts +24 -0
- package/esm/parse/v3-1/_merge-all-of/merge-bounds.js +57 -0
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -20
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -20
- package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +7 -0
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +65 -7
- package/esm/parse/v3-1/_merge-all-of/merge.js +7 -3
- package/esm/parse/v3-1/array/toArray.js +4 -15
- package/esm/parse/v3-1/components/toComponentsV3.js +2 -2
- package/esm/parse/v3-1/externalDocs/toExternalDocs.d.ts +3 -1
- package/esm/parse/v3-1/externalDocs/toExternalDocs.js +9 -8
- package/esm/parse/v3-1/header/toHeadersV3.d.ts +12 -0
- package/esm/parse/v3-1/header/toHeadersV3.js +20 -0
- package/esm/parse/v3-1/info/toInfoV3.d.ts +2 -1
- package/esm/parse/v3-1/info/toInfoV3.js +15 -4
- package/esm/parse/v3-1/requestBody/toRequestBodiesV3.js +9 -9
- package/esm/parse/v3-1/schema/normalize-schema-shape.js +10 -8
- package/esm/parse/v3-1/schema/toSchemasV3.js +7 -1
- package/esm/parse/v3-1/tag/toTagsV3.js +7 -2
- package/esm/parse/v3-2/_merge-all-of/decompose-union.d.ts +2 -0
- package/esm/parse/v3-2/_merge-all-of/decompose-union.js +3 -1
- package/esm/parse/v3-2/_merge-all-of/merge-bounds.d.ts +24 -0
- package/esm/parse/v3-2/_merge-all-of/merge-bounds.js +57 -0
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -20
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -20
- package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +7 -0
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +65 -7
- package/esm/parse/v3-2/_merge-all-of/merge.js +7 -3
- package/esm/parse/v3-2/array/toArray.js +4 -15
- package/esm/parse/v3-2/components/toComponentsV3.js +2 -2
- package/esm/parse/v3-2/externalDocs/toExternalDocs.d.ts +3 -1
- package/esm/parse/v3-2/externalDocs/toExternalDocs.js +9 -8
- package/esm/parse/v3-2/header/toHeadersV3.d.ts +12 -0
- package/esm/parse/v3-2/header/toHeadersV3.js +20 -0
- package/esm/parse/v3-2/info/toInfoV3.d.ts +2 -1
- package/esm/parse/v3-2/info/toInfoV3.js +15 -4
- package/esm/parse/v3-2/requestBody/toRequestBodiesV3.js +9 -9
- package/esm/parse/v3-2/schema/normalize-schema-shape.js +10 -8
- package/esm/parse/v3-2/schema/toSchemasV3.js +7 -1
- package/esm/parse/v3-2/tag/toTagsV3.js +14 -7
- package/package.json +1 -1
- package/script/context/generateTypes.d.ts +2 -2
- package/script/context/generateTypes.js +5 -0
- package/script/parse/descriptiveFields.d.ts +36 -0
- package/script/parse/descriptiveFields.js +95 -0
- package/script/parse/isPlainObject.d.ts +2 -0
- package/script/parse/isPlainObject.js +6 -0
- package/script/parse/toComponentEntries.d.ts +29 -0
- package/script/parse/toComponentEntries.js +35 -0
- package/script/parse/toPresentInfo.d.ts +30 -0
- package/script/parse/toPresentInfo.js +45 -0
- package/script/parse/v3-0/_merge-all-of/merge-bounds.d.ts +7 -0
- package/script/parse/v3-0/_merge-all-of/merge-bounds.js +50 -0
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -20
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -20
- package/script/parse/v3-0/components/toComponentsV3.js +1 -1
- package/script/parse/v3-0/externalDocs/toExternalDocs.d.ts +3 -1
- package/script/parse/v3-0/externalDocs/toExternalDocs.js +9 -41
- package/script/parse/v3-0/header/toHeadersV3.d.ts +12 -0
- package/script/parse/v3-0/header/toHeadersV3.js +22 -1
- package/script/parse/v3-0/info/toInfoV3.d.ts +2 -1
- package/script/parse/v3-0/info/toInfoV3.js +15 -4
- package/script/parse/v3-0/requestBody/toRequestBodiesV3.js +9 -9
- package/script/parse/v3-0/tag/toTagsV3.js +7 -2
- package/script/parse/v3-1/_merge-all-of/decompose-union.d.ts +2 -0
- package/script/parse/v3-1/_merge-all-of/decompose-union.js +5 -2
- package/script/parse/v3-1/_merge-all-of/merge-bounds.d.ts +24 -0
- package/script/parse/v3-1/_merge-all-of/merge-bounds.js +66 -0
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -20
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -20
- package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +7 -0
- package/script/parse/v3-1/_merge-all-of/merge-union.js +66 -7
- package/script/parse/v3-1/_merge-all-of/merge.js +6 -2
- package/script/parse/v3-1/array/toArray.js +4 -15
- package/script/parse/v3-1/components/toComponentsV3.js +1 -1
- package/script/parse/v3-1/externalDocs/toExternalDocs.d.ts +3 -1
- package/script/parse/v3-1/externalDocs/toExternalDocs.js +9 -41
- package/script/parse/v3-1/header/toHeadersV3.d.ts +12 -0
- package/script/parse/v3-1/header/toHeadersV3.js +22 -1
- package/script/parse/v3-1/info/toInfoV3.d.ts +2 -1
- package/script/parse/v3-1/info/toInfoV3.js +15 -4
- package/script/parse/v3-1/requestBody/toRequestBodiesV3.js +9 -9
- package/script/parse/v3-1/schema/normalize-schema-shape.js +10 -8
- package/script/parse/v3-1/schema/toSchemasV3.js +6 -0
- package/script/parse/v3-1/tag/toTagsV3.js +7 -2
- package/script/parse/v3-2/_merge-all-of/decompose-union.d.ts +2 -0
- package/script/parse/v3-2/_merge-all-of/decompose-union.js +5 -2
- package/script/parse/v3-2/_merge-all-of/merge-bounds.d.ts +24 -0
- package/script/parse/v3-2/_merge-all-of/merge-bounds.js +66 -0
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -20
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -20
- package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +7 -0
- package/script/parse/v3-2/_merge-all-of/merge-union.js +66 -7
- package/script/parse/v3-2/_merge-all-of/merge.js +6 -2
- package/script/parse/v3-2/array/toArray.js +4 -15
- package/script/parse/v3-2/components/toComponentsV3.js +1 -1
- package/script/parse/v3-2/externalDocs/toExternalDocs.d.ts +3 -1
- package/script/parse/v3-2/externalDocs/toExternalDocs.js +9 -41
- package/script/parse/v3-2/header/toHeadersV3.d.ts +12 -0
- package/script/parse/v3-2/header/toHeadersV3.js +22 -1
- package/script/parse/v3-2/info/toInfoV3.d.ts +2 -1
- package/script/parse/v3-2/info/toInfoV3.js +15 -4
- package/script/parse/v3-2/requestBody/toRequestBodiesV3.js +9 -9
- package/script/parse/v3-2/schema/normalize-schema-shape.js +10 -8
- package/script/parse/v3-2/schema/toSchemasV3.js +6 -0
- package/script/parse/v3-2/tag/toTagsV3.js +14 -7
|
@@ -5,22 +5,33 @@ const Info_js_1 = require("../../../oas/info/Info.js");
|
|
|
5
5
|
const toContactV3_js_1 = require("../contact/toContactV3.js");
|
|
6
6
|
const toLicenseV3_js_1 = require("../license/toLicenseV3.js");
|
|
7
7
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
8
|
+
const toPresentInfo_js_1 = require("../../toPresentInfo.js");
|
|
8
9
|
const toInfoV3 = ({ info, stackTrail, context }) => {
|
|
9
|
-
const
|
|
10
|
+
const presentInfo = (0, toPresentInfo_js_1.toPresentInfo)({ info, stackTrail, context });
|
|
11
|
+
if (presentInfo === undefined) {
|
|
12
|
+
return new Info_js_1.OasInfo({ title: '', version: '' });
|
|
13
|
+
}
|
|
14
|
+
const { title, description, termsOfService, contact, license, version, ...skipped } = presentInfo;
|
|
10
15
|
const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({
|
|
11
16
|
skipped,
|
|
12
|
-
parent:
|
|
17
|
+
parent: presentInfo,
|
|
13
18
|
context,
|
|
14
19
|
stackTrail,
|
|
15
20
|
parentType: 'info'
|
|
16
21
|
});
|
|
17
22
|
return new Info_js_1.OasInfo({
|
|
18
|
-
title,
|
|
23
|
+
title: (0, toPresentInfo_js_1.toInfoString)({ value: title, key: 'title', parent: presentInfo, stackTrail, context }),
|
|
19
24
|
description,
|
|
20
25
|
termsOfService,
|
|
21
26
|
contact: contact ? (0, toContactV3_js_1.toContactV3)(contact, stackTrail, context) : undefined,
|
|
22
27
|
license: license ? (0, toLicenseV3_js_1.toLicenseV3)(license, stackTrail, context) : undefined,
|
|
23
|
-
version,
|
|
28
|
+
version: (0, toPresentInfo_js_1.toInfoString)({
|
|
29
|
+
value: version,
|
|
30
|
+
key: 'version',
|
|
31
|
+
parent: presentInfo,
|
|
32
|
+
stackTrail,
|
|
33
|
+
context
|
|
34
|
+
}),
|
|
24
35
|
extensionFields
|
|
25
36
|
});
|
|
26
37
|
};
|
|
@@ -7,6 +7,7 @@ const toMediaTypeItemV3_js_1 = require("../mediaType/toMediaTypeItemV3.js");
|
|
|
7
7
|
const RequestBody_js_1 = require("../../../oas/requestBody/RequestBody.js");
|
|
8
8
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
9
9
|
const logBodyMediaTypes_js_1 = require("../../logBodyMediaTypes.js");
|
|
10
|
+
const toComponentEntries_js_1 = require("../../toComponentEntries.js");
|
|
10
11
|
const toRequestBodyV3 = ({ requestBody, stackTrail, context }) => {
|
|
11
12
|
if (!requestBody) {
|
|
12
13
|
return undefined;
|
|
@@ -39,14 +40,13 @@ const toRequestBodiesV3 = ({ requestBodies, stackTrail, context }) => {
|
|
|
39
40
|
if (!requestBodies) {
|
|
40
41
|
return undefined;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return Object.fromEntries(entries);
|
|
43
|
+
return (0, toComponentEntries_js_1.toComponentEntries)({
|
|
44
|
+
entries: requestBodies,
|
|
45
|
+
stackTrail,
|
|
46
|
+
context,
|
|
47
|
+
type: 'INVALID_REQUEST_BODY',
|
|
48
|
+
label: 'Request body',
|
|
49
|
+
parse: ({ entry, stackTrail: st }) => (0, exports.toRequestBodyV3)({ requestBody: entry, stackTrail: st, context })
|
|
50
|
+
});
|
|
51
51
|
};
|
|
52
52
|
exports.toRequestBodiesV3 = toRequestBodiesV3;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeMergeMember = exports.isNullOnlyType = exports.normalizeSchemaShape = void 0;
|
|
4
|
+
const merge_bounds_js_1 = require("../_merge-all-of/merge-bounds.js");
|
|
4
5
|
/**
|
|
5
6
|
* OpenAPI 3.1 lets a schema's `type` be an ARRAY (e.g. `['string', 'null']`),
|
|
6
7
|
* which the shared IR — modelling a single `type` plus a `nullable` flag —
|
|
@@ -97,15 +98,16 @@ const normalizeExclusiveBounds = (schema) => {
|
|
|
97
98
|
if (typeof exclusiveMinimum !== 'number' && typeof exclusiveMaximum !== 'number') {
|
|
98
99
|
return schema;
|
|
99
100
|
}
|
|
101
|
+
// A schema may carry both `minimum` and a numeric `exclusiveMinimum`:
|
|
102
|
+
// keep the tighter of the two (the same for maximum).
|
|
103
|
+
const minimum = typeof exclusiveMinimum === 'number'
|
|
104
|
+
? (0, merge_bounds_js_1.toTighterMinimum)((0, merge_bounds_js_1.toMinimum)(schema), { value: exclusiveMinimum, exclusive: true })
|
|
105
|
+
: undefined;
|
|
106
|
+
const maximum = typeof exclusiveMaximum === 'number'
|
|
107
|
+
? (0, merge_bounds_js_1.toTighterMaximum)((0, merge_bounds_js_1.toMaximum)(schema), { value: exclusiveMaximum, exclusive: true })
|
|
108
|
+
: undefined;
|
|
100
109
|
const next = { ...schema };
|
|
101
|
-
|
|
102
|
-
next.minimum = exclusiveMinimum;
|
|
103
|
-
next.exclusiveMinimum = true;
|
|
104
|
-
}
|
|
105
|
-
if (typeof exclusiveMaximum === 'number') {
|
|
106
|
-
next.maximum = exclusiveMaximum;
|
|
107
|
-
next.exclusiveMaximum = true;
|
|
108
|
-
}
|
|
110
|
+
(0, merge_bounds_js_1.writeBounds)(next, minimum, maximum);
|
|
109
111
|
return next;
|
|
110
112
|
};
|
|
111
113
|
/**
|
|
@@ -171,6 +171,12 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
171
171
|
return (0, exports.toSchemaV3)({ schema: merged, stackTrail: st, context });
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
+
// A `oneOf`/`anyOf` of only null members reads as nullable, not as an
|
|
175
|
+
// empty union.
|
|
176
|
+
const collapsed = (0, merge_union_js_1.collapseNullOnlyUnion)(schema, normalize_schema_shape_js_1.normalizeMergeMember);
|
|
177
|
+
if (collapsed !== schema) {
|
|
178
|
+
return (0, exports.toSchemaV3)({ schema: collapsed, stackTrail, context });
|
|
179
|
+
}
|
|
174
180
|
if ('oneOf' in schema && Array.isArray(schema.oneOf)) {
|
|
175
181
|
const wrapper = withoutWrapperUnevaluatedProperties({
|
|
176
182
|
schema,
|
|
@@ -4,11 +4,16 @@ exports.toTagV3 = exports.toTagsV3 = void 0;
|
|
|
4
4
|
const Tag_js_1 = require("../../../oas/tag/Tag.js");
|
|
5
5
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
6
6
|
const toExternalDocs_js_1 = require("../externalDocs/toExternalDocs.js");
|
|
7
|
+
const descriptiveFields_js_1 = require("../../descriptiveFields.js");
|
|
7
8
|
const toTagsV3 = ({ tags, stackTrail, context }) => {
|
|
8
|
-
if (
|
|
9
|
+
if (tags === undefined) {
|
|
9
10
|
return undefined;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
// A malformed entry, or a `tags` that is not an array, is left out with a
|
|
13
|
+
// warning: tags do not change how an operation renders.
|
|
14
|
+
return (0, descriptiveFields_js_1.toTagList)({ tags, stackTrail, context })?.flatMap((tag, index) => stackTrail.trace(`${index}`, st => (0, descriptiveFields_js_1.isValidTag)({ tag, stackTrail: st, context })
|
|
15
|
+
? [(0, exports.toTagV3)({ tag, stackTrail: st, context })]
|
|
16
|
+
: []));
|
|
12
17
|
};
|
|
13
18
|
exports.toTagsV3 = toTagsV3;
|
|
14
19
|
const toTagV3 = ({ tag, stackTrail, context }) => {
|
|
@@ -9,4 +9,6 @@ type DecomposeUnionReturn = {
|
|
|
9
9
|
afterExcluded: SchemaObject;
|
|
10
10
|
};
|
|
11
11
|
export declare const decomposeUnion: ({ schema, groupType }: DecomposeUnionArgs) => DecomposeUnionReturn;
|
|
12
|
+
/** Is `key` a union-level key, kept on the union rather than merged into each member? */
|
|
13
|
+
export declare const isUnionLevelKey: (key: string) => boolean;
|
|
12
14
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decomposeUnion = void 0;
|
|
3
|
+
exports.isUnionLevelKey = exports.decomposeUnion = void 0;
|
|
4
4
|
// Convert a schema object into an array of schemas that can be merged iteratively into a new schema
|
|
5
5
|
const decomposeUnion = ({ schema, groupType }) => {
|
|
6
6
|
if (!schema[groupType]) {
|
|
@@ -60,9 +60,12 @@ const excludedProperties = [
|
|
|
60
60
|
'writeOnly',
|
|
61
61
|
'deprecated'
|
|
62
62
|
];
|
|
63
|
+
/** Is `key` a union-level key, kept on the union rather than merged into each member? */
|
|
64
|
+
const isUnionLevelKey = (key) => excludedProperties.includes(key);
|
|
65
|
+
exports.isUnionLevelKey = isUnionLevelKey;
|
|
63
66
|
const exclude = (entries) => {
|
|
64
67
|
return entries.reduce((acc, [key, value]) => {
|
|
65
|
-
if (
|
|
68
|
+
if ((0, exports.isUnionLevelKey)(key)) {
|
|
66
69
|
acc.excluded.push([key, value]);
|
|
67
70
|
}
|
|
68
71
|
else {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SchemaObject } from './types.js';
|
|
2
|
+
export type Bound = {
|
|
3
|
+
value: number;
|
|
4
|
+
exclusive: boolean;
|
|
5
|
+
};
|
|
6
|
+
/** The tighter of two lower bounds. */
|
|
7
|
+
export declare const toTighterMinimum: (first: Bound | undefined, second: Bound | undefined) => Bound | undefined;
|
|
8
|
+
/** The tighter of two upper bounds. */
|
|
9
|
+
export declare const toTighterMaximum: (first: Bound | undefined, second: Bound | undefined) => Bound | undefined;
|
|
10
|
+
/** The lower bound of `schema`; exclusive only when `exclusiveMinimum` is `true`. */
|
|
11
|
+
export declare const toMinimum: (schema: SchemaObject) => Bound | undefined;
|
|
12
|
+
/** The upper bound of `schema`; exclusive only when `exclusiveMaximum` is `true`. */
|
|
13
|
+
export declare const toMaximum: (schema: SchemaObject) => Bound | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Write the merged `minimum`/`exclusiveMinimum` and `maximum`/`exclusiveMaximum`
|
|
16
|
+
* of `first` and `second` onto `result`. Members are in the normalized form,
|
|
17
|
+
* where an exclusive bound is `minimum` plus `exclusiveMinimum: true`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const mergeBounds: (result: SchemaObject, first: SchemaObject, second: SchemaObject) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Write `minimum` and `maximum` onto `result` in the normalized form. An
|
|
22
|
+
* undefined bound leaves `result` unchanged.
|
|
23
|
+
*/
|
|
24
|
+
export declare const writeBounds: (result: SchemaObject, minimum: Bound | undefined, maximum: Bound | undefined) => void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeBounds = exports.mergeBounds = exports.toMaximum = exports.toMinimum = exports.toTighterMaximum = exports.toTighterMinimum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Pick the tighter of two bounds. The tighter bound keeps its own
|
|
6
|
+
* exclusivity; when both bounds are equal, exclusive wins.
|
|
7
|
+
*/
|
|
8
|
+
const toTighterBound = (first, second, isTighter) => {
|
|
9
|
+
if (first === undefined || second === undefined) {
|
|
10
|
+
return first ?? second;
|
|
11
|
+
}
|
|
12
|
+
if (first.value === second.value) {
|
|
13
|
+
return { value: first.value, exclusive: first.exclusive || second.exclusive };
|
|
14
|
+
}
|
|
15
|
+
return isTighter(first.value, second.value) ? first : second;
|
|
16
|
+
};
|
|
17
|
+
/** The tighter of two lower bounds. */
|
|
18
|
+
const toTighterMinimum = (first, second) => toTighterBound(first, second, (a, b) => a > b);
|
|
19
|
+
exports.toTighterMinimum = toTighterMinimum;
|
|
20
|
+
/** The tighter of two upper bounds. */
|
|
21
|
+
const toTighterMaximum = (first, second) => toTighterBound(first, second, (a, b) => a < b);
|
|
22
|
+
exports.toTighterMaximum = toTighterMaximum;
|
|
23
|
+
/** The lower bound of `schema`; exclusive only when `exclusiveMinimum` is `true`. */
|
|
24
|
+
const toMinimum = (schema) => schema.minimum === undefined
|
|
25
|
+
? undefined
|
|
26
|
+
: { value: schema.minimum, exclusive: schema.exclusiveMinimum === true };
|
|
27
|
+
exports.toMinimum = toMinimum;
|
|
28
|
+
/** The upper bound of `schema`; exclusive only when `exclusiveMaximum` is `true`. */
|
|
29
|
+
const toMaximum = (schema) => schema.maximum === undefined
|
|
30
|
+
? undefined
|
|
31
|
+
: { value: schema.maximum, exclusive: schema.exclusiveMaximum === true };
|
|
32
|
+
exports.toMaximum = toMaximum;
|
|
33
|
+
/**
|
|
34
|
+
* Write the merged `minimum`/`exclusiveMinimum` and `maximum`/`exclusiveMaximum`
|
|
35
|
+
* of `first` and `second` onto `result`. Members are in the normalized form,
|
|
36
|
+
* where an exclusive bound is `minimum` plus `exclusiveMinimum: true`.
|
|
37
|
+
*/
|
|
38
|
+
const mergeBounds = (result, first, second) => {
|
|
39
|
+
(0, exports.writeBounds)(result, (0, exports.toTighterMinimum)((0, exports.toMinimum)(first), (0, exports.toMinimum)(second)), (0, exports.toTighterMaximum)((0, exports.toMaximum)(first), (0, exports.toMaximum)(second)));
|
|
40
|
+
};
|
|
41
|
+
exports.mergeBounds = mergeBounds;
|
|
42
|
+
/**
|
|
43
|
+
* Write `minimum` and `maximum` onto `result` in the normalized form. An
|
|
44
|
+
* undefined bound leaves `result` unchanged.
|
|
45
|
+
*/
|
|
46
|
+
const writeBounds = (result, minimum, maximum) => {
|
|
47
|
+
if (minimum !== undefined) {
|
|
48
|
+
result.minimum = minimum.value;
|
|
49
|
+
if (minimum.exclusive) {
|
|
50
|
+
result.exclusiveMinimum = true;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
delete result.exclusiveMinimum;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (maximum !== undefined) {
|
|
57
|
+
result.maximum = maximum.value;
|
|
58
|
+
if (maximum.exclusive) {
|
|
59
|
+
result.exclusiveMaximum = true;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
delete result.exclusiveMaximum;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.writeBounds = writeBounds;
|
|
@@ -37,32 +37,14 @@ exports.mergeIntegerConstraints = mergeIntegerConstraints;
|
|
|
37
37
|
const generic_merge_js_1 = require("./generic-merge.js");
|
|
38
38
|
const v = __importStar(require("valibot"));
|
|
39
39
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
40
|
+
const merge_bounds_js_1 = require("./merge-bounds.js");
|
|
40
41
|
function mergeIntegerConstraints(first, second, getRef, normalize) {
|
|
41
42
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
42
43
|
// First merge enum values if present
|
|
43
44
|
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.number());
|
|
44
45
|
// Then merge other constraints
|
|
45
46
|
result.type = 'integer';
|
|
46
|
-
|
|
47
|
-
if (first.minimum !== undefined || second.minimum !== undefined) {
|
|
48
|
-
const minA = first.minimum ?? -Infinity;
|
|
49
|
-
const minB = second.minimum ?? -Infinity;
|
|
50
|
-
result.minimum = Math.max(minA, minB);
|
|
51
|
-
// If either minimum is exclusive, the result is exclusive
|
|
52
|
-
if (first.exclusiveMinimum || second.exclusiveMinimum) {
|
|
53
|
-
result.exclusiveMinimum = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Merge maximum and exclusiveMaximum
|
|
57
|
-
if (first.maximum !== undefined || second.maximum !== undefined) {
|
|
58
|
-
const maxA = first.maximum ?? Infinity;
|
|
59
|
-
const maxB = second.maximum ?? Infinity;
|
|
60
|
-
result.maximum = Math.min(maxA, maxB);
|
|
61
|
-
// If either maximum is exclusive, the result is exclusive
|
|
62
|
-
if (first.exclusiveMaximum || second.exclusiveMaximum) {
|
|
63
|
-
result.exclusiveMaximum = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
47
|
+
(0, merge_bounds_js_1.mergeBounds)(result, first, second);
|
|
66
48
|
// Merge multipleOf
|
|
67
49
|
if (first.multipleOf !== undefined && second.multipleOf !== undefined) {
|
|
68
50
|
result.multipleOf = first.multipleOf * second.multipleOf;
|
|
@@ -37,32 +37,14 @@ exports.mergeNumberConstraints = mergeNumberConstraints;
|
|
|
37
37
|
const generic_merge_js_1 = require("./generic-merge.js");
|
|
38
38
|
const v = __importStar(require("valibot"));
|
|
39
39
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
40
|
+
const merge_bounds_js_1 = require("./merge-bounds.js");
|
|
40
41
|
function mergeNumberConstraints(first, second, getRef, normalize) {
|
|
41
42
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
42
43
|
// First merge enum values if present
|
|
43
44
|
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.number());
|
|
44
45
|
// Then merge other constraints
|
|
45
46
|
result.type = 'number';
|
|
46
|
-
|
|
47
|
-
if (first.minimum !== undefined || second.minimum !== undefined) {
|
|
48
|
-
const minA = first.minimum ?? -Infinity;
|
|
49
|
-
const minB = second.minimum ?? -Infinity;
|
|
50
|
-
result.minimum = Math.max(minA, minB);
|
|
51
|
-
// If either minimum is exclusive, the result is exclusive
|
|
52
|
-
if (first.exclusiveMinimum || second.exclusiveMinimum) {
|
|
53
|
-
result.exclusiveMinimum = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Merge maximum and exclusiveMaximum
|
|
57
|
-
if (first.maximum !== undefined || second.maximum !== undefined) {
|
|
58
|
-
const maxA = first.maximum ?? Infinity;
|
|
59
|
-
const maxB = second.maximum ?? Infinity;
|
|
60
|
-
result.maximum = Math.min(maxA, maxB);
|
|
61
|
-
// If either maximum is exclusive, the result is exclusive
|
|
62
|
-
if (first.exclusiveMaximum || second.exclusiveMaximum) {
|
|
63
|
-
result.exclusiveMaximum = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
47
|
+
(0, merge_bounds_js_1.mergeBounds)(result, first, second);
|
|
66
48
|
// Merge multipleOf
|
|
67
49
|
if (first.multipleOf !== undefined && second.multipleOf !== undefined) {
|
|
68
50
|
result.multipleOf = first.multipleOf * second.multipleOf;
|
|
@@ -14,4 +14,11 @@ type MergeCrossProductArgs = {
|
|
|
14
14
|
groupType: 'oneOf' | 'anyOf';
|
|
15
15
|
};
|
|
16
16
|
export declare const mergeCrossProduct: ({ first, second, getRef, normalize, groupType }: MergeCrossProductArgs) => SchemaObject;
|
|
17
|
+
/**
|
|
18
|
+
* A `oneOf`/`anyOf` whose every member is null-only (for example
|
|
19
|
+
* `oneOf: [{ type: 'null' }]`) reads as nullable with no other type, not
|
|
20
|
+
* as an empty union: the group is replaced by `nullable: true`. Any other
|
|
21
|
+
* schema is returned unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export declare const collapseNullOnlyUnion: (schema: SchemaObject, normalize: NormalizeFn) => SchemaObject;
|
|
17
24
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeCrossProduct = exports.mergeUnion = void 0;
|
|
3
|
+
exports.collapseNullOnlyUnion = exports.mergeCrossProduct = exports.mergeUnion = void 0;
|
|
4
4
|
const decompose_union_js_1 = require("./decompose-union.js");
|
|
5
5
|
const merge_js_1 = require("./merge.js");
|
|
6
6
|
const cross_product_js_1 = require("./cross-product.js");
|
|
@@ -41,15 +41,16 @@ exports.mergeUnion = mergeUnion;
|
|
|
41
41
|
const mergeCrossProduct = ({ first, second, getRef, normalize, groupType }) => {
|
|
42
42
|
const firstMembers = Array.isArray(first[groupType]) ? first[groupType] : [first];
|
|
43
43
|
const secondMembers = Array.isArray(second[groupType]) ? second[groupType] : [second];
|
|
44
|
-
// A member that normalizes to
|
|
45
|
-
// member: it makes the union nullable
|
|
44
|
+
// A member that normalizes to `{ nullable: true }`, with at most union-level
|
|
45
|
+
// keys beside it, is a null-only member: it makes the union nullable
|
|
46
|
+
// instead of joining the cross product.
|
|
46
47
|
const firstGroup = firstMembers.filter(member => !isNullableOnly(member, normalize));
|
|
47
48
|
const secondGroup = secondMembers.filter(member => !isNullableOnly(member, normalize));
|
|
48
49
|
const nullable = isNullableGroup(first, groupType) ||
|
|
49
50
|
isNullableGroup(second, groupType) ||
|
|
50
51
|
firstGroup.length !== firstMembers.length ||
|
|
51
52
|
secondGroup.length !== secondMembers.length;
|
|
52
|
-
const mergedGroup = (0, cross_product_js_1.crossProduct)(firstGroup, secondGroup)
|
|
53
|
+
const mergedGroup = (0, cross_product_js_1.crossProduct)(withGroupSiblings({ schema: first, members: firstGroup, getRef, normalize, groupType }), withGroupSiblings({ schema: second, members: secondGroup, getRef, normalize, groupType }))
|
|
53
54
|
.map(([firstItem, secondItem]) => {
|
|
54
55
|
try {
|
|
55
56
|
const result = (0, merge_js_1.mergeSchemasOrRefs)(firstItem, secondItem, getRef, normalize);
|
|
@@ -60,6 +61,8 @@ const mergeCrossProduct = ({ first, second, getRef, normalize, groupType }) => {
|
|
|
60
61
|
}
|
|
61
62
|
})
|
|
62
63
|
.filter(item => item !== undefined);
|
|
64
|
+
// A nested group is spread into this one below; its `nullable` carries over.
|
|
65
|
+
const nestedNullable = mergedGroup.some(item => !(0, refFns_js_1.isRef)(item) && Array.isArray(item[groupType]) && item.nullable === true);
|
|
63
66
|
return {
|
|
64
67
|
[groupType]: mergedGroup.flatMap(item => {
|
|
65
68
|
if (!(0, refFns_js_1.isRef)(item) && Array.isArray(item[groupType])) {
|
|
@@ -67,16 +70,72 @@ const mergeCrossProduct = ({ first, second, getRef, normalize, groupType }) => {
|
|
|
67
70
|
}
|
|
68
71
|
return [item];
|
|
69
72
|
}),
|
|
70
|
-
...(nullable ? { nullable: true } : {})
|
|
73
|
+
...(nullable || nestedNullable ? { nullable: true } : {})
|
|
71
74
|
};
|
|
72
75
|
};
|
|
73
76
|
exports.mergeCrossProduct = mergeCrossProduct;
|
|
77
|
+
/**
|
|
78
|
+
* Merge the sibling keys of a `oneOf`/`anyOf` wrapper into each of its
|
|
79
|
+
* `members`. A 3.1 `type: ['string', 'number']` with `minLength` normalizes
|
|
80
|
+
* to a `oneOf` with `minLength` beside it. Union-level keys (`nullable`,
|
|
81
|
+
* `description`, …) are not merged in, and a `$ref` member is returned
|
|
82
|
+
* unchanged. A member that conflicts with the
|
|
83
|
+
* siblings is dropped, as in the cross product. A schema with no group is
|
|
84
|
+
* its own only member and is returned unchanged.
|
|
85
|
+
*/
|
|
86
|
+
const withGroupSiblings = ({ schema, members, getRef, normalize, groupType }) => {
|
|
87
|
+
if (!Array.isArray(schema[groupType])) {
|
|
88
|
+
return members;
|
|
89
|
+
}
|
|
90
|
+
const siblings = Object.entries(schema).filter(([key]) => key !== groupType && !(0, decompose_union_js_1.isUnionLevelKey)(key));
|
|
91
|
+
if (siblings.length === 0) {
|
|
92
|
+
return members;
|
|
93
|
+
}
|
|
94
|
+
const siblingSchema = Object.fromEntries(siblings);
|
|
95
|
+
return members
|
|
96
|
+
.map(member => {
|
|
97
|
+
// Merging into a `$ref` member would resolve it and lose its name.
|
|
98
|
+
if ((0, refFns_js_1.isRef)(member)) {
|
|
99
|
+
return member;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
return (0, merge_js_1.mergeSchemasOrRefs)(siblingSchema, member, getRef, normalize);
|
|
103
|
+
}
|
|
104
|
+
catch (_error) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
.filter(member => member !== undefined);
|
|
109
|
+
};
|
|
74
110
|
const isNullableOnly = (member, normalize) => {
|
|
75
111
|
if ((0, refFns_js_1.isRef)(member)) {
|
|
76
112
|
return false;
|
|
77
113
|
}
|
|
78
|
-
const normalized = normalize(member);
|
|
79
|
-
|
|
114
|
+
const normalized = (0, exports.collapseNullOnlyUnion)(normalize(member), normalize);
|
|
115
|
+
// Union-level keys (`description`, `title`, …) do not change what a
|
|
116
|
+
// null-only member allows.
|
|
117
|
+
return normalized.nullable === true && Object.keys(normalized).every(decompose_union_js_1.isUnionLevelKey);
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* A `oneOf`/`anyOf` whose every member is null-only (for example
|
|
121
|
+
* `oneOf: [{ type: 'null' }]`) reads as nullable with no other type, not
|
|
122
|
+
* as an empty union: the group is replaced by `nullable: true`. Any other
|
|
123
|
+
* schema is returned unchanged.
|
|
124
|
+
*/
|
|
125
|
+
const collapseNullOnlyUnion = (schema, normalize) => {
|
|
126
|
+
const isNullOnlyGroup = (members) => Array.isArray(members) &&
|
|
127
|
+
members.length > 0 &&
|
|
128
|
+
members.every(member => isNullableOnly(member, normalize));
|
|
129
|
+
if (isNullOnlyGroup(schema.oneOf)) {
|
|
130
|
+
const { oneOf: _oneOf, ...rest } = schema;
|
|
131
|
+
return { ...rest, nullable: true };
|
|
132
|
+
}
|
|
133
|
+
if (isNullOnlyGroup(schema.anyOf)) {
|
|
134
|
+
const { anyOf: _anyOf, ...rest } = schema;
|
|
135
|
+
return { ...rest, nullable: true };
|
|
136
|
+
}
|
|
137
|
+
return schema;
|
|
80
138
|
};
|
|
139
|
+
exports.collapseNullOnlyUnion = collapseNullOnlyUnion;
|
|
81
140
|
/** Is this a `oneOf`/`anyOf` group wrapper that already carries `nullable`? */
|
|
82
141
|
const isNullableGroup = (schema, groupType) => Array.isArray(schema[groupType]) && schema.nullable === true;
|
|
@@ -21,8 +21,12 @@ 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
23
|
const mergeSchemasOrRefs = (inputFirst, inputSecond, getRef, normalize) => {
|
|
24
|
-
const first = (0, refFns_js_1.isRef)(inputFirst)
|
|
25
|
-
|
|
24
|
+
const first = (0, refFns_js_1.isRef)(inputFirst)
|
|
25
|
+
? inputFirst
|
|
26
|
+
: (0, merge_union_js_1.collapseNullOnlyUnion)(normalize(inputFirst), normalize);
|
|
27
|
+
const second = (0, refFns_js_1.isRef)(inputSecond)
|
|
28
|
+
? inputSecond
|
|
29
|
+
: (0, merge_union_js_1.collapseNullOnlyUnion)(normalize(inputSecond), normalize);
|
|
26
30
|
if (containsRef(first, second)) {
|
|
27
31
|
return mergeWithRef(first, second, getRef, normalize);
|
|
28
32
|
}
|
|
@@ -170,21 +170,10 @@ const toParsedArray = ({ context, stackTrail, nullable, example, enums, defaultV
|
|
|
170
170
|
nullable,
|
|
171
171
|
defaultValue,
|
|
172
172
|
items: stackTrail.trace('items', st => {
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
context.logIssue({
|
|
178
|
-
key: 'items',
|
|
179
|
-
level: 'warning',
|
|
180
|
-
message: 'Array schema has no "items" — treating as an array of unknown values',
|
|
181
|
-
parent: value,
|
|
182
|
-
stackTrail: st,
|
|
183
|
-
type: 'INVALID_SCHEMA'
|
|
184
|
-
});
|
|
185
|
-
return (0, toSchemasV3_js_1.toSchemaV3)({ schema: {}, stackTrail: st, context });
|
|
186
|
-
}
|
|
187
|
-
return (0, toSchemasV3_js_1.toSchemaV3)({ schema: items, stackTrail: st, context });
|
|
173
|
+
// `items` is optional in JSON Schema 2020-12: an array schema
|
|
174
|
+
// without it has unknown items — `{}` falls through toSchemaV3
|
|
175
|
+
// to OasUnknown.
|
|
176
|
+
return (0, toSchemasV3_js_1.toSchemaV3)({ schema: items ?? {}, stackTrail: st, context });
|
|
188
177
|
}),
|
|
189
178
|
extensionFields,
|
|
190
179
|
example,
|
|
@@ -37,7 +37,7 @@ const toComponentsV3 = ({ components, stackTrail, context }) => {
|
|
|
37
37
|
context
|
|
38
38
|
}),
|
|
39
39
|
requestBodies: stackTrail.trace('requestBodies', st => (0, toRequestBodiesV3_js_1.toRequestBodiesV3)({ requestBodies, stackTrail: st, context })),
|
|
40
|
-
headers: stackTrail.trace('headers', st => (0, toHeadersV3_js_1.
|
|
40
|
+
headers: stackTrail.trace('headers', st => (0, toHeadersV3_js_1.toComponentHeadersV3)({ headers, stackTrail: st, context })),
|
|
41
41
|
securitySchemes: stackTrail.trace('securitySchemes', st => (0, toSecuritySchemes_js_1.toSecuritySchemesV3)({ securitySchemes, stackTrail: st, context })),
|
|
42
42
|
links: stackTrail.trace('links', st => (0, toLinksV3_js_1.toLinksV3)({ links, stackTrail: st, context })),
|
|
43
43
|
extensionFields
|
|
@@ -4,7 +4,9 @@ import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
|
4
4
|
import type { StackTrail } from '../../../context/StackTrail.js';
|
|
5
5
|
export type ToExternalDocsArgs = {
|
|
6
6
|
externalDocs: OpenAPIV3.ExternalDocumentationObject | undefined;
|
|
7
|
+
/** Trail that ends in the `externalDocs` key. */
|
|
7
8
|
stackTrail: StackTrail;
|
|
8
9
|
context: ParseContextType;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
/** An invalid `externalDocs` is left out with a warning; its parent is kept. */
|
|
12
|
+
export declare const toExternalDocs: ({ externalDocs, stackTrail, context }: ToExternalDocsArgs) => OasExternalDocs | undefined;
|
|
@@ -1,52 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.toExternalDocs = void 0;
|
|
37
4
|
const ExternalDocs_js_1 = require("../../../oas/externalDocs/ExternalDocs.js");
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const toExternalDocs = ({ externalDocs, stackTrail }) => {
|
|
41
|
-
if (
|
|
5
|
+
const descriptiveFields_js_1 = require("../../descriptiveFields.js");
|
|
6
|
+
/** An invalid `externalDocs` is left out with a warning; its parent is kept. */
|
|
7
|
+
const toExternalDocs = ({ externalDocs, stackTrail, context }) => {
|
|
8
|
+
if (externalDocs === undefined) {
|
|
42
9
|
return undefined;
|
|
43
10
|
}
|
|
44
|
-
|
|
45
|
-
|
|
11
|
+
const valid = (0, descriptiveFields_js_1.toValidExternalDocs)({ externalDocs, stackTrail, context });
|
|
12
|
+
if (!valid) {
|
|
13
|
+
return undefined;
|
|
46
14
|
}
|
|
47
15
|
return new ExternalDocs_js_1.OasExternalDocs({
|
|
48
|
-
url:
|
|
49
|
-
description:
|
|
16
|
+
url: valid.url,
|
|
17
|
+
description: valid.description
|
|
50
18
|
});
|
|
51
19
|
};
|
|
52
20
|
exports.toExternalDocs = toExternalDocs;
|
|
@@ -9,6 +9,18 @@ export type ToHeadersV3Args = {
|
|
|
9
9
|
context: ParseContextType;
|
|
10
10
|
};
|
|
11
11
|
export declare const toHeadersV3: ({ headers, stackTrail, context }: ToHeadersV3Args) => Record<string, OasHeader | OasRef<"header">> | undefined;
|
|
12
|
+
export type ToComponentHeadersV3Args = {
|
|
13
|
+
headers: Record<string, OpenAPIV3.ReferenceObject | OpenAPIV3.HeaderObject> | undefined;
|
|
14
|
+
stackTrail: StackTrail;
|
|
15
|
+
context: ParseContextType;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Parse `components.headers`. Each entry parses inside its own boundary: a
|
|
19
|
+
* broken one is dropped with an INVALID_HEADER error, and the others are
|
|
20
|
+
* kept. Headers inside a response stay with {@link toHeadersV3}, where a
|
|
21
|
+
* broken header drops the response.
|
|
22
|
+
*/
|
|
23
|
+
export declare const toComponentHeadersV3: ({ headers, stackTrail, context }: ToComponentHeadersV3Args) => Record<string, OasHeader | OasRef<"header">> | undefined;
|
|
12
24
|
export type ToHeaderV3Args = {
|
|
13
25
|
header: OpenAPIV3.ReferenceObject | OpenAPIV3.HeaderObject;
|
|
14
26
|
/** The header's name, used to key a singular `example` */
|