@skmtc/core 0.34.0 → 0.35.0
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/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/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/tag/toTagsV3.js +7 -2
- 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/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/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/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/tag/toTagsV3.js +7 -2
- 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/tag/toTagsV3.js +14 -7
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toInfoString = exports.toPresentInfo = void 0;
|
|
4
|
+
const isPlainObject_js_1 = require("./isPlainObject.js");
|
|
5
|
+
/**
|
|
6
|
+
* Check the document's `info` field before its fields are parsed. Shared by
|
|
7
|
+
* the 3.0, 3.1 and 3.2 parsers.
|
|
8
|
+
*
|
|
9
|
+
* Missing, `null` or not a plain object: logs one `MISSING_INFO` warning and
|
|
10
|
+
* returns `undefined`. The caller reads it as an empty title and version.
|
|
11
|
+
*/
|
|
12
|
+
const toPresentInfo = ({ info, stackTrail, context }) => {
|
|
13
|
+
if (!(0, isPlainObject_js_1.isPlainObject)(info)) {
|
|
14
|
+
context.logIssueNoKey({
|
|
15
|
+
stackTrail,
|
|
16
|
+
parent: info,
|
|
17
|
+
level: 'warning',
|
|
18
|
+
type: 'MISSING_INFO',
|
|
19
|
+
message: 'Document has no info object; read as empty title and version'
|
|
20
|
+
});
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return info;
|
|
24
|
+
};
|
|
25
|
+
exports.toPresentInfo = toPresentInfo;
|
|
26
|
+
/**
|
|
27
|
+
* Read `info.title` or `info.version`. A value that is not a string (missing,
|
|
28
|
+
* or a YAML number such as `version: 1.0`) logs one `MISSING_INFO` warning
|
|
29
|
+
* and reads as `''`.
|
|
30
|
+
*/
|
|
31
|
+
const toInfoString = ({ value, key, parent, stackTrail, context }) => {
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
context.logIssue({
|
|
36
|
+
key,
|
|
37
|
+
stackTrail,
|
|
38
|
+
parent,
|
|
39
|
+
level: 'warning',
|
|
40
|
+
type: 'MISSING_INFO',
|
|
41
|
+
message: `Info has no string ${key}; read as ''`
|
|
42
|
+
});
|
|
43
|
+
return '';
|
|
44
|
+
};
|
|
45
|
+
exports.toInfoString = toInfoString;
|
|
@@ -35,7 +35,7 @@ const toComponentsV3 = ({ components, stackTrail, context }) => {
|
|
|
35
35
|
context
|
|
36
36
|
}),
|
|
37
37
|
requestBodies: stackTrail.trace('requestBodies', st => (0, toRequestBodiesV3_js_1.toRequestBodiesV3)({ requestBodies, stackTrail: st, context })),
|
|
38
|
-
headers: stackTrail.trace('headers', st => (0, toHeadersV3_js_1.
|
|
38
|
+
headers: stackTrail.trace('headers', st => (0, toHeadersV3_js_1.toComponentHeadersV3)({ headers, stackTrail: st, context })),
|
|
39
39
|
securitySchemes: stackTrail.trace('securitySchemes', st => (0, toSecuritySchemes_js_1.toSecuritySchemesV3)({ securitySchemes, stackTrail: st, context })),
|
|
40
40
|
links: stackTrail.trace('links', st => (0, toLinksV3_js_1.toLinksV3)({ links, stackTrail: st, context })),
|
|
41
41
|
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` */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toHeadersV3 = void 0;
|
|
3
|
+
exports.toComponentHeadersV3 = exports.toHeadersV3 = void 0;
|
|
4
4
|
const toExamplesV3_js_1 = require("../example/toExamplesV3.js");
|
|
5
5
|
const toRefV31_js_1 = require("../ref/toRefV31.js");
|
|
6
6
|
const toSchemasV3_js_1 = require("../schema/toSchemasV3.js");
|
|
@@ -8,6 +8,7 @@ const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
|
8
8
|
const toMediaTypeItemV3_js_1 = require("../mediaType/toMediaTypeItemV3.js");
|
|
9
9
|
const Header_js_1 = require("../../../oas/header/Header.js");
|
|
10
10
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
11
|
+
const toComponentEntries_js_1 = require("../../toComponentEntries.js");
|
|
11
12
|
const toHeadersV3 = ({ headers, stackTrail, context }) => {
|
|
12
13
|
if (!headers) {
|
|
13
14
|
return undefined;
|
|
@@ -20,6 +21,26 @@ const toHeadersV3 = ({ headers, stackTrail, context }) => {
|
|
|
20
21
|
return output;
|
|
21
22
|
};
|
|
22
23
|
exports.toHeadersV3 = toHeadersV3;
|
|
24
|
+
/**
|
|
25
|
+
* Parse `components.headers`. Each entry parses inside its own boundary: a
|
|
26
|
+
* broken one is dropped with an INVALID_HEADER error, and the others are
|
|
27
|
+
* kept. Headers inside a response stay with {@link toHeadersV3}, where a
|
|
28
|
+
* broken header drops the response.
|
|
29
|
+
*/
|
|
30
|
+
const toComponentHeadersV3 = ({ headers, stackTrail, context }) => {
|
|
31
|
+
if (!headers) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return (0, toComponentEntries_js_1.toComponentEntries)({
|
|
35
|
+
entries: headers,
|
|
36
|
+
stackTrail,
|
|
37
|
+
context,
|
|
38
|
+
type: 'INVALID_HEADER',
|
|
39
|
+
label: 'Header',
|
|
40
|
+
parse: ({ key, entry, stackTrail: st }) => toHeaderV3({ header: entry, name: key, stackTrail: st, context })
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.toComponentHeadersV3 = toComponentHeadersV3;
|
|
23
44
|
const toHeaderV3 = ({ header, name, stackTrail, context }) => {
|
|
24
45
|
if ((0, refFns_js_1.isRef)(header)) {
|
|
25
46
|
return (0, toRefV31_js_1.toRefV31)({ ref: header, refType: 'header', stackTrail, context });
|
|
@@ -3,7 +3,8 @@ import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
|
3
3
|
import { OasInfo } from '../../../oas/info/Info.js';
|
|
4
4
|
import type { StackTrail } from '../../../context/StackTrail.js';
|
|
5
5
|
export type ToInfoV3Args = {
|
|
6
|
-
|
|
6
|
+
/** Required by the spec; a document without it still parses (see {@link toPresentInfo}). */
|
|
7
|
+
info: OpenAPIV3.InfoObject | null | undefined;
|
|
7
8
|
stackTrail: StackTrail;
|
|
8
9
|
context: ParseContextType;
|
|
9
10
|
};
|
|
@@ -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;
|
|
@@ -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 }) => {
|
|
@@ -35,7 +35,7 @@ const toComponentsV3 = ({ components, stackTrail, context }) => {
|
|
|
35
35
|
context
|
|
36
36
|
}),
|
|
37
37
|
requestBodies: stackTrail.trace('requestBodies', st => (0, toRequestBodiesV3_js_1.toRequestBodiesV3)({ requestBodies, stackTrail: st, context })),
|
|
38
|
-
headers: stackTrail.trace('headers', st => (0, toHeadersV3_js_1.
|
|
38
|
+
headers: stackTrail.trace('headers', st => (0, toHeadersV3_js_1.toComponentHeadersV3)({ headers, stackTrail: st, context })),
|
|
39
39
|
securitySchemes: stackTrail.trace('securitySchemes', st => (0, toSecuritySchemes_js_1.toSecuritySchemesV3)({ securitySchemes, stackTrail: st, context })),
|
|
40
40
|
links: stackTrail.trace('links', st => (0, toLinksV3_js_1.toLinksV3)({ links, stackTrail: st, context })),
|
|
41
41
|
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` */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toHeadersV3 = void 0;
|
|
3
|
+
exports.toComponentHeadersV3 = exports.toHeadersV3 = void 0;
|
|
4
4
|
const toExamplesV3_js_1 = require("../example/toExamplesV3.js");
|
|
5
5
|
const toRefV31_js_1 = require("../ref/toRefV31.js");
|
|
6
6
|
const toSchemasV3_js_1 = require("../schema/toSchemasV3.js");
|
|
@@ -8,6 +8,7 @@ const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
|
8
8
|
const toMediaTypeItemV3_js_1 = require("../mediaType/toMediaTypeItemV3.js");
|
|
9
9
|
const Header_js_1 = require("../../../oas/header/Header.js");
|
|
10
10
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
11
|
+
const toComponentEntries_js_1 = require("../../toComponentEntries.js");
|
|
11
12
|
const toHeadersV3 = ({ headers, stackTrail, context }) => {
|
|
12
13
|
if (!headers) {
|
|
13
14
|
return undefined;
|
|
@@ -20,6 +21,26 @@ const toHeadersV3 = ({ headers, stackTrail, context }) => {
|
|
|
20
21
|
return output;
|
|
21
22
|
};
|
|
22
23
|
exports.toHeadersV3 = toHeadersV3;
|
|
24
|
+
/**
|
|
25
|
+
* Parse `components.headers`. Each entry parses inside its own boundary: a
|
|
26
|
+
* broken one is dropped with an INVALID_HEADER error, and the others are
|
|
27
|
+
* kept. Headers inside a response stay with {@link toHeadersV3}, where a
|
|
28
|
+
* broken header drops the response.
|
|
29
|
+
*/
|
|
30
|
+
const toComponentHeadersV3 = ({ headers, stackTrail, context }) => {
|
|
31
|
+
if (!headers) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return (0, toComponentEntries_js_1.toComponentEntries)({
|
|
35
|
+
entries: headers,
|
|
36
|
+
stackTrail,
|
|
37
|
+
context,
|
|
38
|
+
type: 'INVALID_HEADER',
|
|
39
|
+
label: 'Header',
|
|
40
|
+
parse: ({ key, entry, stackTrail: st }) => toHeaderV3({ header: entry, name: key, stackTrail: st, context })
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.toComponentHeadersV3 = toComponentHeadersV3;
|
|
23
44
|
const toHeaderV3 = ({ header, name, stackTrail, context }) => {
|
|
24
45
|
if ((0, refFns_js_1.isRef)(header)) {
|
|
25
46
|
return (0, toRefV31_js_1.toRefV31)({ ref: header, refType: 'header', stackTrail, context });
|
|
@@ -3,7 +3,8 @@ import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
|
3
3
|
import { OasInfo } from '../../../oas/info/Info.js';
|
|
4
4
|
import type { StackTrail } from '../../../context/StackTrail.js';
|
|
5
5
|
export type ToInfoV3Args = {
|
|
6
|
-
|
|
6
|
+
/** Required by the spec; a document without it still parses (see {@link toPresentInfo}). */
|
|
7
|
+
info: OpenAPIV3.InfoObject | null | undefined;
|
|
7
8
|
stackTrail: StackTrail;
|
|
8
9
|
context: ParseContextType;
|
|
9
10
|
};
|
|
@@ -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;
|
|
@@ -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 }) => {
|
|
@@ -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;
|