@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
|
@@ -167,7 +167,7 @@ export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3
|
|
|
167
167
|
* scalar schema (a text body or a file). A body with only specific
|
|
168
168
|
* non-JSON types (`multipart/form-data`, `text/plain`) logs nothing.
|
|
169
169
|
*/
|
|
170
|
-
export type OasIssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISSING_STRING_TYPE' | 'MISSING_ARRAY_TYPE' | 'MISSING_BOOLEAN_TYPE' | 'MISSING_RESPONSES' | 'EMPTY_PARAMETER' | 'INVALID_EXAMPLE' | 'INVALID_ENUM' | 'INVALID_DEFAULT' | 'INVALID_NULLABLE' | 'UNEXPECTED_FORMAT' | 'INVALID_RESPONSE' | 'INVALID_FORMAT' | 'INVALID_OPERATION' | 'INVALID_SCHEMA' | 'INVALID_PARAMETER' | 'INVALID_SECURITY_SCHEME' | 'INVALID_DEPENDENCY_REF' | 'EXAMPLE_AND_EXAMPLES_DEFINED' | 'INVALID_TAG_PARENT' | 'UNSUPPORTED_OPERATION_METHOD' | 'WILDCARD_MEDIA_TYPE' | 'NO_JSON_MEDIA_TYPE';
|
|
170
|
+
export type OasIssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISSING_STRING_TYPE' | 'MISSING_ARRAY_TYPE' | 'MISSING_BOOLEAN_TYPE' | 'MISSING_RESPONSES' | 'MISSING_INFO' | 'EMPTY_PARAMETER' | 'INVALID_EXAMPLE' | 'INVALID_ENUM' | 'INVALID_DEFAULT' | 'INVALID_NULLABLE' | 'UNEXPECTED_FORMAT' | 'INVALID_RESPONSE' | 'INVALID_REQUEST_BODY' | 'INVALID_HEADER' | 'INVALID_FORMAT' | 'INVALID_OPERATION' | 'INVALID_SCHEMA' | 'INVALID_PARAMETER' | 'INVALID_SECURITY_SCHEME' | 'INVALID_DEPENDENCY_REF' | 'EXAMPLE_AND_EXAMPLES_DEFINED' | 'INVALID_TAG_PARENT' | 'INVALID_TAG' | 'INVALID_EXTERNAL_DOCS' | 'UNSUPPORTED_OPERATION_METHOD' | 'WILDCARD_MEDIA_TYPE' | 'NO_JSON_MEDIA_TYPE';
|
|
171
171
|
/**
|
|
172
172
|
* Valibot schema for {@link OasIssueType}. Annotation deliberately omitted
|
|
173
173
|
* so the precise literal-union output type flows through to consumers
|
|
@@ -175,7 +175,7 @@ export type OasIssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISS
|
|
|
175
175
|
* this list and {@link OasIssueType} is caught by `assertSchemaMatchesType`
|
|
176
176
|
* below.
|
|
177
177
|
*/
|
|
178
|
-
export declare const oasIssueType: v.UnionSchema<[v.LiteralSchema<"UNEXPECTED_PROPERTY", undefined>, v.LiteralSchema<"MISSING_OBJECT_TYPE", undefined>, v.LiteralSchema<"MISSING_STRING_TYPE", undefined>, v.LiteralSchema<"MISSING_ARRAY_TYPE", undefined>, v.LiteralSchema<"MISSING_BOOLEAN_TYPE", undefined>, v.LiteralSchema<"MISSING_RESPONSES", undefined>, v.LiteralSchema<"EMPTY_PARAMETER", undefined>, v.LiteralSchema<"INVALID_EXAMPLE", undefined>, v.LiteralSchema<"INVALID_ENUM", undefined>, v.LiteralSchema<"INVALID_DEFAULT", undefined>, v.LiteralSchema<"INVALID_NULLABLE", undefined>, v.LiteralSchema<"UNEXPECTED_FORMAT", undefined>, v.LiteralSchema<"INVALID_RESPONSE", undefined>, v.LiteralSchema<"INVALID_FORMAT", undefined>, v.LiteralSchema<"INVALID_OPERATION", undefined>, v.LiteralSchema<"INVALID_SCHEMA", undefined>, v.LiteralSchema<"INVALID_PARAMETER", undefined>, v.LiteralSchema<"INVALID_SECURITY_SCHEME", undefined>, v.LiteralSchema<"INVALID_DEPENDENCY_REF", undefined>, v.LiteralSchema<"EXAMPLE_AND_EXAMPLES_DEFINED", undefined>, v.LiteralSchema<"INVALID_TAG_PARENT", undefined>, v.LiteralSchema<"UNSUPPORTED_OPERATION_METHOD", undefined>, v.LiteralSchema<"WILDCARD_MEDIA_TYPE", undefined>, v.LiteralSchema<"NO_JSON_MEDIA_TYPE", undefined>], undefined>;
|
|
178
|
+
export declare const oasIssueType: v.UnionSchema<[v.LiteralSchema<"UNEXPECTED_PROPERTY", undefined>, v.LiteralSchema<"MISSING_OBJECT_TYPE", undefined>, v.LiteralSchema<"MISSING_STRING_TYPE", undefined>, v.LiteralSchema<"MISSING_ARRAY_TYPE", undefined>, v.LiteralSchema<"MISSING_BOOLEAN_TYPE", undefined>, v.LiteralSchema<"MISSING_RESPONSES", undefined>, v.LiteralSchema<"MISSING_INFO", undefined>, v.LiteralSchema<"EMPTY_PARAMETER", undefined>, v.LiteralSchema<"INVALID_EXAMPLE", undefined>, v.LiteralSchema<"INVALID_ENUM", undefined>, v.LiteralSchema<"INVALID_DEFAULT", undefined>, v.LiteralSchema<"INVALID_NULLABLE", undefined>, v.LiteralSchema<"UNEXPECTED_FORMAT", undefined>, v.LiteralSchema<"INVALID_RESPONSE", undefined>, v.LiteralSchema<"INVALID_REQUEST_BODY", undefined>, v.LiteralSchema<"INVALID_HEADER", undefined>, v.LiteralSchema<"INVALID_FORMAT", undefined>, v.LiteralSchema<"INVALID_OPERATION", undefined>, v.LiteralSchema<"INVALID_SCHEMA", undefined>, v.LiteralSchema<"INVALID_PARAMETER", undefined>, v.LiteralSchema<"INVALID_SECURITY_SCHEME", undefined>, v.LiteralSchema<"INVALID_DEPENDENCY_REF", undefined>, v.LiteralSchema<"EXAMPLE_AND_EXAMPLES_DEFINED", undefined>, v.LiteralSchema<"INVALID_TAG_PARENT", undefined>, v.LiteralSchema<"INVALID_TAG", undefined>, v.LiteralSchema<"INVALID_EXTERNAL_DOCS", undefined>, v.LiteralSchema<"UNSUPPORTED_OPERATION_METHOD", undefined>, v.LiteralSchema<"WILDCARD_MEDIA_TYPE", undefined>, v.LiteralSchema<"NO_JSON_MEDIA_TYPE", undefined>], undefined>;
|
|
179
179
|
export type GenerateResult = {
|
|
180
180
|
files: Map<string, FileBase>;
|
|
181
181
|
previews: Record<string, Preview>;
|
|
@@ -49,6 +49,7 @@ exports.oasIssueType = v.union([
|
|
|
49
49
|
v.literal('MISSING_ARRAY_TYPE'),
|
|
50
50
|
v.literal('MISSING_BOOLEAN_TYPE'),
|
|
51
51
|
v.literal('MISSING_RESPONSES'),
|
|
52
|
+
v.literal('MISSING_INFO'),
|
|
52
53
|
v.literal('EMPTY_PARAMETER'),
|
|
53
54
|
v.literal('INVALID_EXAMPLE'),
|
|
54
55
|
v.literal('INVALID_ENUM'),
|
|
@@ -56,6 +57,8 @@ exports.oasIssueType = v.union([
|
|
|
56
57
|
v.literal('INVALID_NULLABLE'),
|
|
57
58
|
v.literal('UNEXPECTED_FORMAT'),
|
|
58
59
|
v.literal('INVALID_RESPONSE'),
|
|
60
|
+
v.literal('INVALID_REQUEST_BODY'),
|
|
61
|
+
v.literal('INVALID_HEADER'),
|
|
59
62
|
v.literal('INVALID_FORMAT'),
|
|
60
63
|
v.literal('INVALID_OPERATION'),
|
|
61
64
|
v.literal('INVALID_SCHEMA'),
|
|
@@ -64,6 +67,8 @@ exports.oasIssueType = v.union([
|
|
|
64
67
|
v.literal('INVALID_DEPENDENCY_REF'),
|
|
65
68
|
v.literal('EXAMPLE_AND_EXAMPLES_DEFINED'),
|
|
66
69
|
v.literal('INVALID_TAG_PARENT'),
|
|
70
|
+
v.literal('INVALID_TAG'),
|
|
71
|
+
v.literal('INVALID_EXTERNAL_DOCS'),
|
|
67
72
|
v.literal('UNSUPPORTED_OPERATION_METHOD'),
|
|
68
73
|
v.literal('WILDCARD_MEDIA_TYPE'),
|
|
69
74
|
v.literal('NO_JSON_MEDIA_TYPE')
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ParseContextType } from '../context/parseTypes.js';
|
|
2
|
+
import type { StackTrail } from '../context/StackTrail.js';
|
|
3
|
+
import { type OasExternalDocsData } from '../oas/externalDocs/externalDocsTypes.js';
|
|
4
|
+
export type ToTagListArgs<Tag> = {
|
|
5
|
+
tags: Tag[];
|
|
6
|
+
/** Trail that ends in the `tags` key. */
|
|
7
|
+
stackTrail: StackTrail;
|
|
8
|
+
context: ParseContextType;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Check the root `tags` field before its entries are parsed. Not an array:
|
|
12
|
+
* logs one `INVALID_TAG` warning and returns `undefined`, read as no tags.
|
|
13
|
+
*/
|
|
14
|
+
export declare const toTagList: <Tag>({ tags, stackTrail, context }: ToTagListArgs<Tag>) => Tag[] | undefined;
|
|
15
|
+
export type IsValidTagArgs = {
|
|
16
|
+
tag: unknown;
|
|
17
|
+
/** Trail that ends in the entry's index. */
|
|
18
|
+
stackTrail: StackTrail;
|
|
19
|
+
context: ParseContextType;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A tag entry must be a plain object with a string `name`. Any other entry
|
|
23
|
+
* logs one `INVALID_TAG` warning, and the caller leaves it out.
|
|
24
|
+
*/
|
|
25
|
+
export declare const isValidTag: ({ tag, stackTrail, context }: IsValidTagArgs) => boolean;
|
|
26
|
+
export type ToValidExternalDocsArgs = {
|
|
27
|
+
externalDocs: unknown;
|
|
28
|
+
/** Trail that ends in the `externalDocs` key. */
|
|
29
|
+
stackTrail: StackTrail;
|
|
30
|
+
context: ParseContextType;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Validate an `externalDocs` object. One that fails `oasExternalDocsData`
|
|
34
|
+
* logs one `INVALID_EXTERNAL_DOCS` warning and returns `undefined`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const toValidExternalDocs: ({ externalDocs, stackTrail, context }: ToValidExternalDocsArgs) => OasExternalDocsData | undefined;
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.toValidExternalDocs = exports.isValidTag = exports.toTagList = void 0;
|
|
37
|
+
const v = __importStar(require("valibot"));
|
|
38
|
+
const isPlainObject_js_1 = require("./isPlainObject.js");
|
|
39
|
+
const externalDocsTypes_js_1 = require("../oas/externalDocs/externalDocsTypes.js");
|
|
40
|
+
/**
|
|
41
|
+
* Check the root `tags` field before its entries are parsed. Not an array:
|
|
42
|
+
* logs one `INVALID_TAG` warning and returns `undefined`, read as no tags.
|
|
43
|
+
*/
|
|
44
|
+
const toTagList = ({ tags, stackTrail, context }) => {
|
|
45
|
+
if (Array.isArray(tags)) {
|
|
46
|
+
return tags;
|
|
47
|
+
}
|
|
48
|
+
context.logIssueNoKey({
|
|
49
|
+
stackTrail,
|
|
50
|
+
parent: tags,
|
|
51
|
+
level: 'warning',
|
|
52
|
+
type: 'INVALID_TAG',
|
|
53
|
+
message: '"tags" must be an array; left out'
|
|
54
|
+
});
|
|
55
|
+
return undefined;
|
|
56
|
+
};
|
|
57
|
+
exports.toTagList = toTagList;
|
|
58
|
+
/**
|
|
59
|
+
* A tag entry must be a plain object with a string `name`. Any other entry
|
|
60
|
+
* logs one `INVALID_TAG` warning, and the caller leaves it out.
|
|
61
|
+
*/
|
|
62
|
+
const isValidTag = ({ tag, stackTrail, context }) => {
|
|
63
|
+
if ((0, isPlainObject_js_1.isPlainObject)(tag) && typeof tag.name === 'string') {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
context.logIssueNoKey({
|
|
67
|
+
stackTrail,
|
|
68
|
+
parent: tag,
|
|
69
|
+
level: 'warning',
|
|
70
|
+
type: 'INVALID_TAG',
|
|
71
|
+
message: 'Tag is not an object with a string name; left out'
|
|
72
|
+
});
|
|
73
|
+
return false;
|
|
74
|
+
};
|
|
75
|
+
exports.isValidTag = isValidTag;
|
|
76
|
+
/**
|
|
77
|
+
* Validate an `externalDocs` object. One that fails `oasExternalDocsData`
|
|
78
|
+
* logs one `INVALID_EXTERNAL_DOCS` warning and returns `undefined`.
|
|
79
|
+
*/
|
|
80
|
+
const toValidExternalDocs = ({ externalDocs, stackTrail, context }) => {
|
|
81
|
+
const result = v.safeParse(externalDocsTypes_js_1.oasExternalDocsData, externalDocs);
|
|
82
|
+
if (result.success) {
|
|
83
|
+
return result.output;
|
|
84
|
+
}
|
|
85
|
+
const reason = result.issues.map(({ message }) => message).join(', ');
|
|
86
|
+
context.logIssueNoKey({
|
|
87
|
+
stackTrail,
|
|
88
|
+
parent: externalDocs,
|
|
89
|
+
level: 'warning',
|
|
90
|
+
type: 'INVALID_EXTERNAL_DOCS',
|
|
91
|
+
message: `External docs object is invalid (${reason}); left out`
|
|
92
|
+
});
|
|
93
|
+
return undefined;
|
|
94
|
+
};
|
|
95
|
+
exports.toValidExternalDocs = toValidExternalDocs;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPlainObject = void 0;
|
|
4
|
+
/** A non-null object that is not an array. */
|
|
5
|
+
const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
6
|
+
exports.isPlainObject = isPlainObject;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ParseContextType } from '../context/parseTypes.js';
|
|
2
|
+
import type { StackTrail } from '../context/StackTrail.js';
|
|
3
|
+
import type { OasIssueType } from '../context/generateTypes.js';
|
|
4
|
+
export type ToComponentEntriesArgs<Entry, Parsed> = {
|
|
5
|
+
entries: Record<string, Entry>;
|
|
6
|
+
/** Trail that ends in the bucket key, e.g. `components:headers`. */
|
|
7
|
+
stackTrail: StackTrail;
|
|
8
|
+
context: ParseContextType;
|
|
9
|
+
/** Issue type logged for an entry that fails to parse. */
|
|
10
|
+
type: OasIssueType;
|
|
11
|
+
/** Names the entry in the message, e.g. `Request body`. */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Parses one entry. An `undefined` result leaves the entry out. */
|
|
14
|
+
parse: (args: {
|
|
15
|
+
key: string;
|
|
16
|
+
entry: Entry;
|
|
17
|
+
stackTrail: StackTrail;
|
|
18
|
+
}) => Parsed | undefined;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Parse each entry of a `components` bucket inside its own `tryParseAt`
|
|
22
|
+
* boundary. Shared by the 3.0, 3.1 and 3.2 parsers.
|
|
23
|
+
*
|
|
24
|
+
* An entry that is not a plain object (`null`, an array, a string), or that
|
|
25
|
+
* throws while it parses, is dropped with one error of `type` at its
|
|
26
|
+
* location. Consumers reference it by name, so leaving it out silently would
|
|
27
|
+
* change what they render. The other entries are kept.
|
|
28
|
+
*/
|
|
29
|
+
export declare const toComponentEntries: <Entry, Parsed>({ entries, stackTrail, context, type, label, parse }: ToComponentEntriesArgs<Entry, Parsed>) => Record<string, Parsed>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toComponentEntries = void 0;
|
|
4
|
+
const tryParseAt_js_1 = require("../context/tryParseAt.js");
|
|
5
|
+
const isPlainObject_js_1 = require("./isPlainObject.js");
|
|
6
|
+
/**
|
|
7
|
+
* Parse each entry of a `components` bucket inside its own `tryParseAt`
|
|
8
|
+
* boundary. Shared by the 3.0, 3.1 and 3.2 parsers.
|
|
9
|
+
*
|
|
10
|
+
* An entry that is not a plain object (`null`, an array, a string), or that
|
|
11
|
+
* throws while it parses, is dropped with one error of `type` at its
|
|
12
|
+
* location. Consumers reference it by name, so leaving it out silently would
|
|
13
|
+
* change what they render. The other entries are kept.
|
|
14
|
+
*/
|
|
15
|
+
const toComponentEntries = ({ entries, stackTrail, context, type, label, parse }) => {
|
|
16
|
+
const parsedEntries = Object.entries(entries).flatMap(([key, entry]) => {
|
|
17
|
+
const parsed = (0, tryParseAt_js_1.tryParseAt)({
|
|
18
|
+
stackTrail,
|
|
19
|
+
key,
|
|
20
|
+
context,
|
|
21
|
+
type,
|
|
22
|
+
parent: entry,
|
|
23
|
+
fn: st => {
|
|
24
|
+
if (!(0, isPlainObject_js_1.isPlainObject)(entry)) {
|
|
25
|
+
throw new Error(`${label} must be an object, got ${toKind(entry)}`);
|
|
26
|
+
}
|
|
27
|
+
return parse({ key, entry, stackTrail: st });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return parsed === undefined ? [] : [[key, parsed]];
|
|
31
|
+
});
|
|
32
|
+
return Object.fromEntries(parsedEntries);
|
|
33
|
+
};
|
|
34
|
+
exports.toComponentEntries = toComponentEntries;
|
|
35
|
+
const toKind = (value) => value === null ? 'null' : Array.isArray(value) ? 'an array' : typeof value;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ParseContextType } from '../context/parseTypes.js';
|
|
2
|
+
import type { StackTrail } from '../context/StackTrail.js';
|
|
3
|
+
export type ToPresentInfoArgs<Info extends object> = {
|
|
4
|
+
info: Info | null | undefined;
|
|
5
|
+
/** Trail that ends in the `info` key. */
|
|
6
|
+
stackTrail: StackTrail;
|
|
7
|
+
context: ParseContextType;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Check the document's `info` field before its fields are parsed. Shared by
|
|
11
|
+
* the 3.0, 3.1 and 3.2 parsers.
|
|
12
|
+
*
|
|
13
|
+
* Missing, `null` or not a plain object: logs one `MISSING_INFO` warning and
|
|
14
|
+
* returns `undefined`. The caller reads it as an empty title and version.
|
|
15
|
+
*/
|
|
16
|
+
export declare const toPresentInfo: <Info extends object>({ info, stackTrail, context }: ToPresentInfoArgs<Info>) => Info | undefined;
|
|
17
|
+
export type ToInfoStringArgs = {
|
|
18
|
+
value: unknown;
|
|
19
|
+
key: 'title' | 'version';
|
|
20
|
+
parent: unknown;
|
|
21
|
+
/** Trail that ends in the `info` key. */
|
|
22
|
+
stackTrail: StackTrail;
|
|
23
|
+
context: ParseContextType;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Read `info.title` or `info.version`. A value that is not a string (missing,
|
|
27
|
+
* or a YAML number such as `version: 1.0`) logs one `MISSING_INFO` warning
|
|
28
|
+
* and reads as `''`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const toInfoString: ({ value, key, parent, stackTrail, context }: ToInfoStringArgs) => string;
|
|
@@ -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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SchemaObject } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Write the merged `minimum`/`exclusiveMinimum` and `maximum`/`exclusiveMaximum`
|
|
4
|
+
* of `first` and `second` onto `result`. Members are in the normalized form,
|
|
5
|
+
* where an exclusive bound is `minimum` plus `exclusiveMinimum: true`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const mergeBounds: (result: SchemaObject, first: SchemaObject, second: SchemaObject) => void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeBounds = 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
|
+
const toMinimum = (schema) => schema.minimum === undefined
|
|
18
|
+
? undefined
|
|
19
|
+
: { value: schema.minimum, exclusive: schema.exclusiveMinimum === true };
|
|
20
|
+
const toMaximum = (schema) => schema.maximum === undefined
|
|
21
|
+
? undefined
|
|
22
|
+
: { value: schema.maximum, exclusive: schema.exclusiveMaximum === true };
|
|
23
|
+
/**
|
|
24
|
+
* Write the merged `minimum`/`exclusiveMinimum` and `maximum`/`exclusiveMaximum`
|
|
25
|
+
* of `first` and `second` onto `result`. Members are in the normalized form,
|
|
26
|
+
* where an exclusive bound is `minimum` plus `exclusiveMinimum: true`.
|
|
27
|
+
*/
|
|
28
|
+
const mergeBounds = (result, first, second) => {
|
|
29
|
+
const minimum = toTighterBound(toMinimum(first), toMinimum(second), (a, b) => a > b);
|
|
30
|
+
const maximum = toTighterBound(toMaximum(first), toMaximum(second), (a, b) => a < b);
|
|
31
|
+
if (minimum !== undefined) {
|
|
32
|
+
result.minimum = minimum.value;
|
|
33
|
+
if (minimum.exclusive) {
|
|
34
|
+
result.exclusiveMinimum = true;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
delete result.exclusiveMinimum;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (maximum !== undefined) {
|
|
41
|
+
result.maximum = maximum.value;
|
|
42
|
+
if (maximum.exclusive) {
|
|
43
|
+
result.exclusiveMaximum = true;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
delete result.exclusiveMaximum;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.mergeBounds = mergeBounds;
|
|
@@ -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) {
|
|
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, 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) {
|
|
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, 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;
|
|
@@ -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
|
};
|