@e22m4u/js-openapi 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -146
- package/dist/cjs/index.cjs +2024 -2092
- package/package.json +10 -8
- package/schema/openapi-3-1/dialect/base.js +21 -0
- package/schema/openapi-3-1/meta/base.js +76 -0
- package/schema/openapi-3-1/schema-base.js +32 -0
- package/schema/openapi-3-1/schema.js +1403 -0
- package/src/ajv.js +32 -0
- package/src/errors/index.d.ts +1 -1
- package/src/errors/index.js +1 -1
- package/src/errors/oa-document-object-validation-error.d.ts +6 -0
- package/src/errors/oa-document-object-validation-error.js +6 -0
- package/src/errors/oa-document-object-validation-error.spec.js +10 -0
- package/src/index.d.ts +1 -3
- package/src/index.js +1 -3
- package/src/json-pointer/resolve-json-pointer.js +1 -1
- package/src/json-pointer/unescape-json-pointer.d.ts +1 -2
- package/src/oa-document-builder.d.ts +302 -111
- package/src/oa-document-builder.js +208 -142
- package/src/oa-document-builder.spec.js +1408 -0
- package/src/oa-document-object/index.d.ts +1 -1
- package/src/oa-document-object/index.js +1 -1
- package/src/oa-document-object/validate-oa-document-object.d.ts +18 -0
- package/src/oa-document-object/validate-oa-document-object.js +53 -0
- package/src/oa-document-object/validate-oa-document-object.spec.js +122 -0
- package/src/{oa-document-scope.d.ts → oa-operation-group.d.ts} +7 -7
- package/src/{oa-document-scope.js → oa-operation-group.js} +101 -46
- package/src/oa-operation-group.spec.js +544 -0
- package/src/oa-reference-object/is-oa-reference-object.js +1 -1
- package/src/oa-reference-object/is-oa-reference-object.spec.js +1 -1
- package/src/oa-reference-object/oa-ref.js +7 -0
- package/src/oa-reference-object/resolve-oa-reference-object.js +1 -11
- package/src/oa-reference-object/resolve-oa-reference-object.spec.js +0 -10
- package/src/oa-specification.d.ts +54 -66
- package/src/oa-specification.js +10 -22
- package/src/data-type/index.d.ts +0 -1
- package/src/data-type/index.js +0 -1
- package/src/data-type/infer-openapi-data-type.d.ts +0 -30
- package/src/data-type/infer-openapi-data-type.js +0 -38
- package/src/data-validation/data-format-validator-map.d.ts +0 -13
- package/src/data-validation/data-format-validator-map.js +0 -36
- package/src/data-validation/data-format-validator-map.spec.js +0 -39
- package/src/data-validation/data-format-validators.d.ts +0 -84
- package/src/data-validation/data-format-validators.js +0 -217
- package/src/data-validation/index.d.ts +0 -3
- package/src/data-validation/index.js +0 -3
- package/src/data-validation/validate-data-with-openapi-schema.d.ts +0 -46
- package/src/data-validation/validate-data-with-openapi-schema.js +0 -1913
- package/src/data-validation/validate-data-with-openapi-schema.spec.js +0 -6953
- package/src/errors/oa-data-validation-error.d.ts +0 -6
- package/src/errors/oa-data-validation-error.js +0 -6
- package/src/errors/oa-data-validation-error.spec.js +0 -17
- package/src/oa-document-object/validate-shallow-oa-document.d.ts +0 -10
- package/src/oa-document-object/validate-shallow-oa-document.js +0 -209
- package/src/oa-document-object/validate-shallow-oa-document.spec.js +0 -362
- package/src/utils/count-unicode.d.ts +0 -11
- package/src/utils/count-unicode.js +0 -15
- package/src/utils/index.d.ts +0 -5
- package/src/utils/index.js +0 -5
- package/src/utils/join-path.d.ts +0 -6
- package/src/utils/join-path.js +0 -36
- package/src/utils/join-path.spec.js +0 -104
- package/src/utils/normalize-path.d.ts +0 -12
- package/src/utils/normalize-path.js +0 -22
- package/src/utils/normalize-path.spec.js +0 -56
- package/src/utils/to-pascal-case.d.ts +0 -6
- package/src/utils/to-pascal-case.js +0 -26
- package/src/utils/to-pascal-case.spec.js +0 -15
- package/src/utils/to-spaced-json.d.ts +0 -17
- package/src/utils/to-spaced-json.js +0 -27
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
9
|
var __export = (target, all) => {
|
|
@@ -16,34 +18,38 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
}
|
|
17
19
|
return to;
|
|
18
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
19
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
30
|
|
|
21
31
|
// src/index.js
|
|
22
32
|
var index_exports = {};
|
|
23
33
|
__export(index_exports, {
|
|
24
|
-
ACCESS_MODE_LIST: () => ACCESS_MODE_LIST,
|
|
25
|
-
JSON_INTEGER_REGEXP: () => JSON_INTEGER_REGEXP,
|
|
26
|
-
JSON_NUMBER_REGEXP: () => JSON_NUMBER_REGEXP,
|
|
27
34
|
OAAccessMode: () => OAAccessMode,
|
|
28
35
|
OAApiKeyLocation: () => OAApiKeyLocation,
|
|
29
36
|
OAComponentType: () => OAComponentType,
|
|
30
37
|
OADataFormat: () => OADataFormat,
|
|
31
38
|
OADataType: () => OADataType,
|
|
32
|
-
OADataValidationError: () => OADataValidationError,
|
|
33
39
|
OADocumentBuilder: () => OADocumentBuilder,
|
|
34
|
-
|
|
40
|
+
OADocumentObjectValidationError: () => OADocumentObjectValidationError,
|
|
35
41
|
OAMediaType: () => OAMediaType,
|
|
42
|
+
OAOperationGroup: () => OAOperationGroup,
|
|
36
43
|
OAOperationMethod: () => OAOperationMethod,
|
|
37
44
|
OAParameterLocation: () => OAParameterLocation,
|
|
38
45
|
OAParameterStyle: () => OAParameterStyle,
|
|
39
46
|
OASecuritySchemeType: () => OASecuritySchemeType,
|
|
40
|
-
|
|
47
|
+
OA_COMPONENT_NAME_REGEX: () => OA_COMPONENT_NAME_REGEX,
|
|
41
48
|
OA_COMPONENT_TYPES: () => OA_COMPONENT_TYPES,
|
|
42
49
|
OA_COMPONENT_TYPE_TO_COMPONENTS_KEY_MAP: () => OA_COMPONENT_TYPE_TO_COMPONENTS_KEY_MAP,
|
|
43
|
-
|
|
50
|
+
OA_COMPONENT_TYPE_TO_DEFINITION_NAME_MAP: () => OA_COMPONENT_TYPE_TO_DEFINITION_NAME_MAP,
|
|
44
51
|
OPENAPI_VERSION: () => OPENAPI_VERSION,
|
|
45
52
|
escapeJsonPointer: () => escapeJsonPointer,
|
|
46
|
-
inferOpenApiDataType: () => inferOpenApiDataType,
|
|
47
53
|
isOAReferenceObject: () => isOAReferenceObject,
|
|
48
54
|
oaCallbackRef: () => oaCallbackRef,
|
|
49
55
|
oaExampleRef: () => oaExampleRef,
|
|
@@ -57,37 +63,20 @@ __export(index_exports, {
|
|
|
57
63
|
resolveJsonPointer: () => resolveJsonPointer,
|
|
58
64
|
resolveOAReferenceObject: () => resolveOAReferenceObject,
|
|
59
65
|
unescapeJsonPointer: () => unescapeJsonPointer,
|
|
60
|
-
|
|
61
|
-
validateDataWithOpenApiSchema: () => validateDataWithOpenApiSchema,
|
|
62
|
-
validateDateFormat: () => validateDateFormat,
|
|
63
|
-
validateDateTimeFormat: () => validateDateTimeFormat,
|
|
64
|
-
validateDoubleFormat: () => validateDoubleFormat,
|
|
65
|
-
validateEmailFormat: () => validateEmailFormat,
|
|
66
|
-
validateFloatFormat: () => validateFloatFormat,
|
|
67
|
-
validateHostnameFormat: () => validateHostnameFormat,
|
|
68
|
-
validateInt32Format: () => validateInt32Format,
|
|
69
|
-
validateInt64Format: () => validateInt64Format,
|
|
70
|
-
validateIpv4Format: () => validateIpv4Format,
|
|
71
|
-
validateIpv6Format: () => validateIpv6Format,
|
|
72
|
-
validateShallowOADocument: () => validateShallowOADocument,
|
|
73
|
-
validateUriFormat: () => validateUriFormat,
|
|
74
|
-
validateUuidFormat: () => validateUuidFormat
|
|
66
|
+
validateOADocumentObject: () => validateOADocumentObject
|
|
75
67
|
});
|
|
76
68
|
module.exports = __toCommonJS(index_exports);
|
|
77
69
|
|
|
78
|
-
// src/errors/oa-
|
|
70
|
+
// src/errors/oa-document-object-validation-error.js
|
|
79
71
|
var import_js_format = require("@e22m4u/js-format");
|
|
80
|
-
var
|
|
72
|
+
var OADocumentObjectValidationError = class extends import_js_format.Errorf {
|
|
81
73
|
static {
|
|
82
|
-
__name(this, "
|
|
74
|
+
__name(this, "OADocumentObjectValidationError");
|
|
83
75
|
}
|
|
84
76
|
};
|
|
85
77
|
|
|
86
|
-
// src/data-type/infer-openapi-data-type.js
|
|
87
|
-
var import_js_format2 = require("@e22m4u/js-format");
|
|
88
|
-
|
|
89
78
|
// src/oa-specification.js
|
|
90
|
-
var OPENAPI_VERSION = "3.1.
|
|
79
|
+
var OPENAPI_VERSION = "3.1.2";
|
|
91
80
|
var OAOperationMethod = {
|
|
92
81
|
GET: "get",
|
|
93
82
|
PUT: "put",
|
|
@@ -122,7 +111,6 @@ var OADataType = {
|
|
|
122
111
|
ARRAY: "array",
|
|
123
112
|
NULL: "null"
|
|
124
113
|
};
|
|
125
|
-
var OA_DATA_TYPE_LIST = Object.values(OADataType);
|
|
126
114
|
var OADataFormat = {
|
|
127
115
|
// number
|
|
128
116
|
INT32: "int32",
|
|
@@ -178,377 +166,1842 @@ var OAAccessMode = {
|
|
|
178
166
|
READ: "read",
|
|
179
167
|
WRITE: "write"
|
|
180
168
|
};
|
|
181
|
-
var ACCESS_MODE_LIST = Object.values(OAAccessMode);
|
|
182
|
-
|
|
183
|
-
// src/data-type/infer-openapi-data-type.js
|
|
184
|
-
function inferOpenApiDataType(data, returnJsTypeOnFail = false) {
|
|
185
|
-
if (data === null) {
|
|
186
|
-
return OADataType.NULL;
|
|
187
|
-
}
|
|
188
|
-
if (Array.isArray(data)) {
|
|
189
|
-
return OADataType.ARRAY;
|
|
190
|
-
}
|
|
191
|
-
const jsType = typeof data;
|
|
192
|
-
switch (jsType) {
|
|
193
|
-
case "string":
|
|
194
|
-
return OADataType.STRING;
|
|
195
|
-
case "boolean":
|
|
196
|
-
return OADataType.BOOLEAN;
|
|
197
|
-
case "number":
|
|
198
|
-
return Number.isInteger(data) ? OADataType.INTEGER : OADataType.NUMBER;
|
|
199
|
-
case "bigint":
|
|
200
|
-
return OADataType.INTEGER;
|
|
201
|
-
case "object":
|
|
202
|
-
return OADataType.OBJECT;
|
|
203
|
-
}
|
|
204
|
-
if (returnJsTypeOnFail === true) {
|
|
205
|
-
return jsType;
|
|
206
|
-
}
|
|
207
|
-
throw new import_js_format2.InvalidArgumentError(
|
|
208
|
-
"Unable to infer the data type from %v value.",
|
|
209
|
-
data
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
__name(inferOpenApiDataType, "inferOpenApiDataType");
|
|
213
|
-
|
|
214
|
-
// src/oa-document-scope.js
|
|
215
|
-
var import_js_format5 = require("@e22m4u/js-format");
|
|
216
|
-
|
|
217
|
-
// src/utils/join-path.js
|
|
218
|
-
function joinPath(...segments) {
|
|
219
|
-
const parts = segments.filter((seg) => seg != void 0 && String(seg) !== "");
|
|
220
|
-
if (parts.length === 0) {
|
|
221
|
-
return "/";
|
|
222
|
-
}
|
|
223
|
-
let joined = parts.join("/").replace(/\/+/g, "/");
|
|
224
|
-
const protocolRegex = /^([a-z][a-z0-9+.-]*):\//i;
|
|
225
|
-
const protocolMatch = joined.match(protocolRegex);
|
|
226
|
-
if (protocolMatch) {
|
|
227
|
-
joined = joined.replace(protocolRegex, "$1://");
|
|
228
|
-
} else {
|
|
229
|
-
if (!joined.startsWith("/")) {
|
|
230
|
-
joined = "/" + joined;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (joined.length > 1 && joined.endsWith("/")) {
|
|
234
|
-
joined = joined.slice(0, -1);
|
|
235
|
-
}
|
|
236
|
-
return joined;
|
|
237
|
-
}
|
|
238
|
-
__name(joinPath, "joinPath");
|
|
239
|
-
|
|
240
|
-
// src/utils/count-unicode.js
|
|
241
|
-
function countUnicode(data) {
|
|
242
|
-
const matchedChars = String(data).match(/[\s\S]/gu);
|
|
243
|
-
return Array.isArray(matchedChars) ? matchedChars.length : 0;
|
|
244
|
-
}
|
|
245
|
-
__name(countUnicode, "countUnicode");
|
|
246
|
-
|
|
247
|
-
// src/utils/normalize-path.js
|
|
248
|
-
function normalizePath(value, noStartingSlash = false) {
|
|
249
|
-
if (typeof value !== "string") {
|
|
250
|
-
return "/";
|
|
251
|
-
}
|
|
252
|
-
const res = value.trim().replace(/\/+/g, "/").replace(/(^\/|\/$)/g, "");
|
|
253
|
-
return noStartingSlash ? res : "/" + res;
|
|
254
|
-
}
|
|
255
|
-
__name(normalizePath, "normalizePath");
|
|
256
|
-
|
|
257
|
-
// src/utils/to-spaced-json.js
|
|
258
|
-
function toSpacedJson(value, options = {}) {
|
|
259
|
-
const stringified = JSON.stringify(value, null, 1);
|
|
260
|
-
const res = stringified ? stringified.replace(/\n\s*/g, " ").replace(/\[\s/g, "[").replace(/\s\]/g, "]").replace(/\{\s/g, "{").replace(/\s\}/g, "}") : "undefined";
|
|
261
|
-
if (options.truncate && typeof options.truncate === "number" && res.length > options.truncate) {
|
|
262
|
-
return res.slice(0, options.truncate) + "...";
|
|
263
|
-
}
|
|
264
|
-
return res;
|
|
265
|
-
}
|
|
266
|
-
__name(toSpacedJson, "toSpacedJson");
|
|
267
169
|
|
|
268
|
-
// src/
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
170
|
+
// src/json-pointer/escape-json-pointer.js
|
|
171
|
+
var import_js_format2 = require("@e22m4u/js-format");
|
|
172
|
+
function escapeJsonPointer(jsonPointer) {
|
|
173
|
+
if (typeof jsonPointer !== "string") {
|
|
174
|
+
throw new import_js_format2.InvalidArgumentError(
|
|
175
|
+
'Parameter "jsonPointer" must be a String, but %v was given.',
|
|
176
|
+
jsonPointer
|
|
177
|
+
);
|
|
272
178
|
}
|
|
273
|
-
return
|
|
179
|
+
return jsonPointer.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
274
180
|
}
|
|
275
|
-
__name(
|
|
276
|
-
|
|
277
|
-
// src/oa-document-builder.js
|
|
278
|
-
var import_js_format4 = require("@e22m4u/js-format");
|
|
279
|
-
var import_js_service = require("@e22m4u/js-service");
|
|
181
|
+
__name(escapeJsonPointer, "escapeJsonPointer");
|
|
280
182
|
|
|
281
|
-
// src/
|
|
183
|
+
// src/json-pointer/resolve-json-pointer.js
|
|
282
184
|
var import_js_format3 = require("@e22m4u/js-format");
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
"OpenAPI Document Object must be an Object, but %v was given.",
|
|
287
|
-
documentObject
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
if (!documentObject.openapi || typeof documentObject.openapi !== "string") {
|
|
185
|
+
var ARRAY_INDEX_PATTERN = /^(0|[1-9][0-9]*)$/;
|
|
186
|
+
function resolveJsonPointer(document, pointer) {
|
|
187
|
+
if (!document || typeof document !== "object") {
|
|
291
188
|
throw new import_js_format3.InvalidArgumentError(
|
|
292
|
-
'
|
|
293
|
-
|
|
189
|
+
'Parameter "document" must be an Object or an Array, but %v was given.',
|
|
190
|
+
document
|
|
294
191
|
);
|
|
295
192
|
}
|
|
296
|
-
if (
|
|
193
|
+
if (typeof pointer !== "string") {
|
|
297
194
|
throw new import_js_format3.InvalidArgumentError(
|
|
298
|
-
|
|
299
|
-
|
|
195
|
+
"JSON pointer must be a String, but %v was given.",
|
|
196
|
+
pointer
|
|
300
197
|
);
|
|
301
198
|
}
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
'Property "info.title" must be a non-empty String, but %v was given.',
|
|
305
|
-
documentObject.info.title
|
|
306
|
-
);
|
|
199
|
+
if (pointer === "") {
|
|
200
|
+
return document;
|
|
307
201
|
}
|
|
308
|
-
if (!
|
|
202
|
+
if (!pointer.startsWith("/")) {
|
|
309
203
|
throw new import_js_format3.InvalidArgumentError(
|
|
310
|
-
'
|
|
311
|
-
|
|
204
|
+
'JSON pointer must start with "/", but %v was given.',
|
|
205
|
+
pointer
|
|
312
206
|
);
|
|
313
207
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
'Property "servers" must be an Array, but %v was given.',
|
|
326
|
-
documentObject.servers
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
documentObject.servers.forEach((serverObject, index) => {
|
|
330
|
-
if (!serverObject || typeof serverObject !== "object" || Array.isArray(serverObject)) {
|
|
331
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
332
|
-
'Element "servers[%d]" must be an Object, but %v was given.',
|
|
333
|
-
index,
|
|
334
|
-
serverObject
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
if (!serverObject.url || typeof serverObject.url !== "string") {
|
|
338
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
339
|
-
'Property "servers[%d].url" must be a non-empty String, but %v was given.',
|
|
340
|
-
index,
|
|
341
|
-
serverObject.url
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
if (documentObject.paths !== void 0) {
|
|
347
|
-
if (!documentObject.paths || typeof documentObject.paths !== "object" || Array.isArray(documentObject.paths)) {
|
|
348
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
349
|
-
'Property "paths" must be an Object, but %v was given.',
|
|
350
|
-
documentObject.paths
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
if (documentObject.webhooks !== void 0) {
|
|
355
|
-
if (!documentObject.webhooks || typeof documentObject.webhooks !== "object" || Array.isArray(documentObject.webhooks)) {
|
|
356
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
357
|
-
'Property "webhooks" must be an Object, but %v was given.',
|
|
358
|
-
documentObject.webhooks
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if (documentObject.components !== void 0) {
|
|
363
|
-
if (!documentObject.components || typeof documentObject.components !== "object" || Array.isArray(documentObject.components)) {
|
|
364
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
365
|
-
'Property "components" must be an Object, but %v was given.',
|
|
366
|
-
documentObject.components
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
if (documentObject.security !== void 0) {
|
|
371
|
-
if (!Array.isArray(documentObject.security)) {
|
|
372
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
373
|
-
'Property "security" must be an Array, but %v was given.',
|
|
374
|
-
documentObject.security
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
documentObject.security.forEach((securityRequirementObject, index) => {
|
|
378
|
-
if (!securityRequirementObject || typeof securityRequirementObject !== "object" || Array.isArray(securityRequirementObject)) {
|
|
379
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
380
|
-
'Element "security[%d]" must be an Object, but %v was given.',
|
|
381
|
-
index,
|
|
382
|
-
securityRequirementObject
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
if (documentObject.tags !== void 0) {
|
|
388
|
-
if (!Array.isArray(documentObject.tags)) {
|
|
208
|
+
const pathParts = pointer.substring(1).split("/");
|
|
209
|
+
let current = document;
|
|
210
|
+
for (let i = 0, l = pathParts.length; i < l; i++) {
|
|
211
|
+
const part = pathParts[i];
|
|
212
|
+
const segment = unescapeJsonPointer(part);
|
|
213
|
+
if (current && typeof current === "object" && !Array.isArray(current) && Object.hasOwn(current, segment) && current[segment] !== void 0) {
|
|
214
|
+
current = current[segment];
|
|
215
|
+
} else if (Array.isArray(current) && ARRAY_INDEX_PATTERN.test(segment) && current[segment] !== void 0) {
|
|
216
|
+
current = current[segment];
|
|
217
|
+
} else {
|
|
218
|
+
const currentPointer = "/" + pathParts.slice(0, i + 1).join("/");
|
|
389
219
|
throw new import_js_format3.InvalidArgumentError(
|
|
390
|
-
|
|
391
|
-
|
|
220
|
+
"Unable to resolve %v in the given document.",
|
|
221
|
+
currentPointer
|
|
392
222
|
);
|
|
393
223
|
}
|
|
394
|
-
documentObject.tags.forEach((tagObject, index) => {
|
|
395
|
-
if (!tagObject || typeof tagObject !== "object" || Array.isArray(tagObject)) {
|
|
396
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
397
|
-
'Element "tags[%d]" must be an Object, but %v was given.',
|
|
398
|
-
index,
|
|
399
|
-
tagObject
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
if (!tagObject.name || typeof tagObject.name !== "string") {
|
|
403
|
-
throw new import_js_format3.InvalidArgumentError(
|
|
404
|
-
'Property "tags[%d].name" must be a non-empty String, but %v was given.',
|
|
405
|
-
index,
|
|
406
|
-
tagObject.name
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
224
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
225
|
+
return current;
|
|
226
|
+
}
|
|
227
|
+
__name(resolveJsonPointer, "resolveJsonPointer");
|
|
228
|
+
|
|
229
|
+
// src/json-pointer/unescape-json-pointer.js
|
|
230
|
+
var import_js_format4 = require("@e22m4u/js-format");
|
|
231
|
+
function unescapeJsonPointer(jsonPointer) {
|
|
232
|
+
if (typeof jsonPointer !== "string") {
|
|
233
|
+
throw new import_js_format4.InvalidArgumentError(
|
|
234
|
+
'Parameter "jsonPointer" must be a String, but %v was given.',
|
|
235
|
+
jsonPointer
|
|
236
|
+
);
|
|
418
237
|
}
|
|
238
|
+
return jsonPointer.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
419
239
|
}
|
|
420
|
-
__name(
|
|
240
|
+
__name(unescapeJsonPointer, "unescapeJsonPointer");
|
|
241
|
+
|
|
242
|
+
// src/oa-operation-group.js
|
|
243
|
+
var import_js_format7 = require("@e22m4u/js-format");
|
|
421
244
|
|
|
422
245
|
// src/oa-document-builder.js
|
|
423
|
-
var
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
* @param {object} [document]
|
|
470
|
-
*/
|
|
471
|
-
constructor(containerOrDocument, document) {
|
|
472
|
-
if ((0, import_js_service.isServiceContainer)(containerOrDocument)) {
|
|
473
|
-
super(containerOrDocument);
|
|
474
|
-
} else {
|
|
475
|
-
super();
|
|
476
|
-
document = containerOrDocument;
|
|
477
|
-
}
|
|
478
|
-
if (document !== void 0) {
|
|
479
|
-
if (!document || typeof document !== "object" || Array.isArray(document)) {
|
|
480
|
-
throw new import_js_format4.InvalidArgumentError(
|
|
481
|
-
"OpenAPI Document Object must be an Object, but %v was given.",
|
|
482
|
-
document
|
|
483
|
-
);
|
|
246
|
+
var import_js_format6 = require("@e22m4u/js-format");
|
|
247
|
+
var import_js_service = require("@e22m4u/js-service");
|
|
248
|
+
|
|
249
|
+
// src/oa-document-object/validate-oa-document-object.js
|
|
250
|
+
var import_js_format5 = require("@e22m4u/js-format");
|
|
251
|
+
|
|
252
|
+
// src/ajv.js
|
|
253
|
+
var import_ajv_formats = __toESM(require("ajv-formats"), 1);
|
|
254
|
+
var import__ = __toESM(require("ajv/dist/2020.js"), 1);
|
|
255
|
+
|
|
256
|
+
// schema/openapi-3-1/schema.js
|
|
257
|
+
var schema_default = {
|
|
258
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
259
|
+
"description": "The description of OpenAPI v3.1.x Documents without Schema Object validation",
|
|
260
|
+
"type": "object",
|
|
261
|
+
"properties": {
|
|
262
|
+
"openapi": {
|
|
263
|
+
"type": "string",
|
|
264
|
+
"pattern": "^3\\.1\\.\\d+(-.+)?$"
|
|
265
|
+
},
|
|
266
|
+
"info": {
|
|
267
|
+
"$ref": "#/$defs/info"
|
|
268
|
+
},
|
|
269
|
+
"jsonSchemaDialect": {
|
|
270
|
+
"type": "string",
|
|
271
|
+
"format": "uri-reference",
|
|
272
|
+
"default": "https://spec.openapis.org/oas/3.1/dialect/base"
|
|
273
|
+
},
|
|
274
|
+
"servers": {
|
|
275
|
+
"type": "array",
|
|
276
|
+
"items": {
|
|
277
|
+
"$ref": "#/$defs/server"
|
|
278
|
+
},
|
|
279
|
+
"default": [
|
|
280
|
+
{
|
|
281
|
+
"url": "/"
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
"paths": {
|
|
286
|
+
"$ref": "#/$defs/paths"
|
|
287
|
+
},
|
|
288
|
+
"webhooks": {
|
|
289
|
+
"type": "object",
|
|
290
|
+
"additionalProperties": {
|
|
291
|
+
"$ref": "#/$defs/path-item"
|
|
484
292
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
293
|
+
},
|
|
294
|
+
"components": {
|
|
295
|
+
"$ref": "#/$defs/components"
|
|
296
|
+
},
|
|
297
|
+
"security": {
|
|
298
|
+
"type": "array",
|
|
299
|
+
"items": {
|
|
300
|
+
"$ref": "#/$defs/security-requirement"
|
|
488
301
|
}
|
|
489
|
-
|
|
490
|
-
|
|
302
|
+
},
|
|
303
|
+
"tags": {
|
|
304
|
+
"type": "array",
|
|
305
|
+
"items": {
|
|
306
|
+
"$ref": "#/$defs/tag"
|
|
491
307
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
308
|
+
},
|
|
309
|
+
"externalDocs": {
|
|
310
|
+
"$ref": "#/$defs/external-documentation"
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
"required": [
|
|
314
|
+
"openapi",
|
|
315
|
+
"info"
|
|
316
|
+
],
|
|
317
|
+
"anyOf": [
|
|
318
|
+
{
|
|
319
|
+
"required": [
|
|
320
|
+
"paths"
|
|
321
|
+
]
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"required": [
|
|
325
|
+
"components"
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"required": [
|
|
330
|
+
"webhooks"
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
],
|
|
334
|
+
"$ref": "#/$defs/specification-extensions",
|
|
335
|
+
"unevaluatedProperties": false,
|
|
336
|
+
"$defs": {
|
|
337
|
+
"info": {
|
|
338
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#info-object",
|
|
339
|
+
"type": "object",
|
|
340
|
+
"properties": {
|
|
341
|
+
"title": {
|
|
342
|
+
"type": "string"
|
|
343
|
+
},
|
|
344
|
+
"summary": {
|
|
345
|
+
"type": "string"
|
|
346
|
+
},
|
|
347
|
+
"description": {
|
|
348
|
+
"type": "string"
|
|
349
|
+
},
|
|
350
|
+
"termsOfService": {
|
|
351
|
+
"type": "string",
|
|
352
|
+
"format": "uri-reference"
|
|
353
|
+
},
|
|
354
|
+
"contact": {
|
|
355
|
+
"$ref": "#/$defs/contact"
|
|
356
|
+
},
|
|
357
|
+
"license": {
|
|
358
|
+
"$ref": "#/$defs/license"
|
|
359
|
+
},
|
|
360
|
+
"version": {
|
|
361
|
+
"type": "string"
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
"required": [
|
|
365
|
+
"title",
|
|
366
|
+
"version"
|
|
367
|
+
],
|
|
368
|
+
"$ref": "#/$defs/specification-extensions",
|
|
369
|
+
"unevaluatedProperties": false
|
|
370
|
+
},
|
|
371
|
+
"contact": {
|
|
372
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#contact-object",
|
|
373
|
+
"type": "object",
|
|
374
|
+
"properties": {
|
|
375
|
+
"name": {
|
|
376
|
+
"type": "string"
|
|
377
|
+
},
|
|
378
|
+
"url": {
|
|
379
|
+
"type": "string",
|
|
380
|
+
"format": "uri-reference"
|
|
381
|
+
},
|
|
382
|
+
"email": {
|
|
383
|
+
"type": "string",
|
|
384
|
+
"format": "email"
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
"$ref": "#/$defs/specification-extensions",
|
|
388
|
+
"unevaluatedProperties": false
|
|
389
|
+
},
|
|
390
|
+
"license": {
|
|
391
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#license-object",
|
|
392
|
+
"type": "object",
|
|
393
|
+
"properties": {
|
|
394
|
+
"name": {
|
|
395
|
+
"type": "string"
|
|
396
|
+
},
|
|
397
|
+
"identifier": {
|
|
398
|
+
"type": "string"
|
|
399
|
+
},
|
|
400
|
+
"url": {
|
|
401
|
+
"type": "string",
|
|
402
|
+
"format": "uri-reference"
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
"required": [
|
|
406
|
+
"name"
|
|
407
|
+
],
|
|
408
|
+
"dependentSchemas": {
|
|
409
|
+
"identifier": {
|
|
410
|
+
"not": {
|
|
411
|
+
"required": [
|
|
412
|
+
"url"
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
"$ref": "#/$defs/specification-extensions",
|
|
418
|
+
"unevaluatedProperties": false
|
|
419
|
+
},
|
|
420
|
+
"server": {
|
|
421
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#server-object",
|
|
422
|
+
"type": "object",
|
|
423
|
+
"properties": {
|
|
424
|
+
"url": {
|
|
425
|
+
"type": "string"
|
|
426
|
+
},
|
|
427
|
+
"description": {
|
|
428
|
+
"type": "string"
|
|
429
|
+
},
|
|
430
|
+
"variables": {
|
|
431
|
+
"type": "object",
|
|
432
|
+
"additionalProperties": {
|
|
433
|
+
"$ref": "#/$defs/server-variable"
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
"required": [
|
|
438
|
+
"url"
|
|
439
|
+
],
|
|
440
|
+
"$ref": "#/$defs/specification-extensions",
|
|
441
|
+
"unevaluatedProperties": false
|
|
442
|
+
},
|
|
443
|
+
"server-variable": {
|
|
444
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#server-variable-object",
|
|
445
|
+
"type": "object",
|
|
446
|
+
"properties": {
|
|
447
|
+
"enum": {
|
|
448
|
+
"type": "array",
|
|
449
|
+
"items": {
|
|
450
|
+
"type": "string"
|
|
451
|
+
},
|
|
452
|
+
"minItems": 1
|
|
453
|
+
},
|
|
454
|
+
"default": {
|
|
455
|
+
"type": "string"
|
|
456
|
+
},
|
|
457
|
+
"description": {
|
|
458
|
+
"type": "string"
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
"required": [
|
|
462
|
+
"default"
|
|
463
|
+
],
|
|
464
|
+
"$ref": "#/$defs/specification-extensions",
|
|
465
|
+
"unevaluatedProperties": false
|
|
466
|
+
},
|
|
467
|
+
"components": {
|
|
468
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#components-object",
|
|
469
|
+
"type": "object",
|
|
470
|
+
"properties": {
|
|
471
|
+
"schemas": {
|
|
472
|
+
"type": "object",
|
|
473
|
+
"additionalProperties": {
|
|
474
|
+
"$ref": "#/$defs/schema"
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
"responses": {
|
|
478
|
+
"type": "object",
|
|
479
|
+
"additionalProperties": {
|
|
480
|
+
"$ref": "#/$defs/response-or-reference"
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
"parameters": {
|
|
484
|
+
"type": "object",
|
|
485
|
+
"additionalProperties": {
|
|
486
|
+
"$ref": "#/$defs/parameter-or-reference"
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
"examples": {
|
|
490
|
+
"type": "object",
|
|
491
|
+
"additionalProperties": {
|
|
492
|
+
"$ref": "#/$defs/example-or-reference"
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
"requestBodies": {
|
|
496
|
+
"type": "object",
|
|
497
|
+
"additionalProperties": {
|
|
498
|
+
"$ref": "#/$defs/request-body-or-reference"
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
"headers": {
|
|
502
|
+
"type": "object",
|
|
503
|
+
"additionalProperties": {
|
|
504
|
+
"$ref": "#/$defs/header-or-reference"
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
"securitySchemes": {
|
|
508
|
+
"type": "object",
|
|
509
|
+
"additionalProperties": {
|
|
510
|
+
"$ref": "#/$defs/security-scheme-or-reference"
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
"links": {
|
|
514
|
+
"type": "object",
|
|
515
|
+
"additionalProperties": {
|
|
516
|
+
"$ref": "#/$defs/link-or-reference"
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
"callbacks": {
|
|
520
|
+
"type": "object",
|
|
521
|
+
"additionalProperties": {
|
|
522
|
+
"$ref": "#/$defs/callbacks-or-reference"
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
"pathItems": {
|
|
526
|
+
"type": "object",
|
|
527
|
+
"additionalProperties": {
|
|
528
|
+
"$ref": "#/$defs/path-item"
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
"patternProperties": {
|
|
533
|
+
"^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems)$": {
|
|
534
|
+
"$comment": "Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected",
|
|
535
|
+
"propertyNames": {
|
|
536
|
+
"pattern": "^[a-zA-Z0-9._-]+$"
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
"$ref": "#/$defs/specification-extensions",
|
|
541
|
+
"unevaluatedProperties": false
|
|
542
|
+
},
|
|
543
|
+
"paths": {
|
|
544
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#paths-object",
|
|
545
|
+
"type": "object",
|
|
546
|
+
"patternProperties": {
|
|
547
|
+
"^/": {
|
|
548
|
+
"$ref": "#/$defs/path-item"
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
"$ref": "#/$defs/specification-extensions",
|
|
552
|
+
"unevaluatedProperties": false
|
|
553
|
+
},
|
|
554
|
+
"path-item": {
|
|
555
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#path-item-object",
|
|
556
|
+
"type": "object",
|
|
557
|
+
"properties": {
|
|
558
|
+
"$ref": {
|
|
559
|
+
"type": "string",
|
|
560
|
+
"format": "uri-reference"
|
|
561
|
+
},
|
|
562
|
+
"summary": {
|
|
563
|
+
"type": "string"
|
|
564
|
+
},
|
|
565
|
+
"description": {
|
|
566
|
+
"type": "string"
|
|
567
|
+
},
|
|
568
|
+
"servers": {
|
|
569
|
+
"type": "array",
|
|
570
|
+
"items": {
|
|
571
|
+
"$ref": "#/$defs/server"
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
"parameters": {
|
|
575
|
+
"type": "array",
|
|
576
|
+
"items": {
|
|
577
|
+
"$ref": "#/$defs/parameter-or-reference"
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
"get": {
|
|
581
|
+
"$ref": "#/$defs/operation"
|
|
582
|
+
},
|
|
583
|
+
"put": {
|
|
584
|
+
"$ref": "#/$defs/operation"
|
|
585
|
+
},
|
|
586
|
+
"post": {
|
|
587
|
+
"$ref": "#/$defs/operation"
|
|
588
|
+
},
|
|
589
|
+
"delete": {
|
|
590
|
+
"$ref": "#/$defs/operation"
|
|
591
|
+
},
|
|
592
|
+
"options": {
|
|
593
|
+
"$ref": "#/$defs/operation"
|
|
594
|
+
},
|
|
595
|
+
"head": {
|
|
596
|
+
"$ref": "#/$defs/operation"
|
|
597
|
+
},
|
|
598
|
+
"patch": {
|
|
599
|
+
"$ref": "#/$defs/operation"
|
|
600
|
+
},
|
|
601
|
+
"trace": {
|
|
602
|
+
"$ref": "#/$defs/operation"
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
"$ref": "#/$defs/specification-extensions",
|
|
606
|
+
"unevaluatedProperties": false
|
|
607
|
+
},
|
|
608
|
+
"operation": {
|
|
609
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#operation-object",
|
|
610
|
+
"type": "object",
|
|
611
|
+
"properties": {
|
|
612
|
+
"tags": {
|
|
613
|
+
"type": "array",
|
|
614
|
+
"items": {
|
|
615
|
+
"type": "string"
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
"summary": {
|
|
619
|
+
"type": "string"
|
|
620
|
+
},
|
|
621
|
+
"description": {
|
|
622
|
+
"type": "string"
|
|
623
|
+
},
|
|
624
|
+
"externalDocs": {
|
|
625
|
+
"$ref": "#/$defs/external-documentation"
|
|
626
|
+
},
|
|
627
|
+
"operationId": {
|
|
628
|
+
"type": "string"
|
|
629
|
+
},
|
|
630
|
+
"parameters": {
|
|
631
|
+
"type": "array",
|
|
632
|
+
"items": {
|
|
633
|
+
"$ref": "#/$defs/parameter-or-reference"
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
"requestBody": {
|
|
637
|
+
"$ref": "#/$defs/request-body-or-reference"
|
|
638
|
+
},
|
|
639
|
+
"responses": {
|
|
640
|
+
"$ref": "#/$defs/responses"
|
|
641
|
+
},
|
|
642
|
+
"callbacks": {
|
|
643
|
+
"type": "object",
|
|
644
|
+
"additionalProperties": {
|
|
645
|
+
"$ref": "#/$defs/callbacks-or-reference"
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
"deprecated": {
|
|
649
|
+
"default": false,
|
|
650
|
+
"type": "boolean"
|
|
651
|
+
},
|
|
652
|
+
"security": {
|
|
653
|
+
"type": "array",
|
|
654
|
+
"items": {
|
|
655
|
+
"$ref": "#/$defs/security-requirement"
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
"servers": {
|
|
659
|
+
"type": "array",
|
|
660
|
+
"items": {
|
|
661
|
+
"$ref": "#/$defs/server"
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
"$ref": "#/$defs/specification-extensions",
|
|
666
|
+
"unevaluatedProperties": false
|
|
667
|
+
},
|
|
668
|
+
"external-documentation": {
|
|
669
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#external-documentation-object",
|
|
670
|
+
"type": "object",
|
|
671
|
+
"properties": {
|
|
672
|
+
"description": {
|
|
673
|
+
"type": "string"
|
|
674
|
+
},
|
|
675
|
+
"url": {
|
|
676
|
+
"type": "string",
|
|
677
|
+
"format": "uri-reference"
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
"required": [
|
|
681
|
+
"url"
|
|
682
|
+
],
|
|
683
|
+
"$ref": "#/$defs/specification-extensions",
|
|
684
|
+
"unevaluatedProperties": false
|
|
685
|
+
},
|
|
686
|
+
"parameter": {
|
|
687
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#parameter-object",
|
|
688
|
+
"type": "object",
|
|
689
|
+
"properties": {
|
|
690
|
+
"name": {
|
|
691
|
+
"type": "string"
|
|
692
|
+
},
|
|
693
|
+
"in": {
|
|
694
|
+
"enum": [
|
|
695
|
+
"query",
|
|
696
|
+
"header",
|
|
697
|
+
"path",
|
|
698
|
+
"cookie"
|
|
699
|
+
]
|
|
700
|
+
},
|
|
701
|
+
"description": {
|
|
702
|
+
"type": "string"
|
|
703
|
+
},
|
|
704
|
+
"required": {
|
|
705
|
+
"default": false,
|
|
706
|
+
"type": "boolean"
|
|
707
|
+
},
|
|
708
|
+
"deprecated": {
|
|
709
|
+
"default": false,
|
|
710
|
+
"type": "boolean"
|
|
711
|
+
},
|
|
712
|
+
"schema": {
|
|
713
|
+
"$ref": "#/$defs/schema"
|
|
714
|
+
},
|
|
715
|
+
"content": {
|
|
716
|
+
"$ref": "#/$defs/content",
|
|
717
|
+
"minProperties": 1,
|
|
718
|
+
"maxProperties": 1
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
"required": [
|
|
722
|
+
"name",
|
|
723
|
+
"in"
|
|
724
|
+
],
|
|
725
|
+
"oneOf": [
|
|
726
|
+
{
|
|
727
|
+
"required": [
|
|
728
|
+
"schema"
|
|
729
|
+
]
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
"required": [
|
|
733
|
+
"content"
|
|
734
|
+
]
|
|
735
|
+
}
|
|
736
|
+
],
|
|
737
|
+
"if": {
|
|
738
|
+
"properties": {
|
|
739
|
+
"in": {
|
|
740
|
+
"const": "query"
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
"required": [
|
|
744
|
+
"in"
|
|
745
|
+
]
|
|
746
|
+
},
|
|
747
|
+
"then": {
|
|
748
|
+
"properties": {
|
|
749
|
+
"allowEmptyValue": {
|
|
750
|
+
"default": false,
|
|
751
|
+
"type": "boolean"
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
"dependentSchemas": {
|
|
756
|
+
"schema": {
|
|
757
|
+
"properties": {
|
|
758
|
+
"style": {
|
|
759
|
+
"type": "string"
|
|
760
|
+
},
|
|
761
|
+
"explode": {
|
|
762
|
+
"type": "boolean"
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
"allOf": [
|
|
766
|
+
{
|
|
767
|
+
"$ref": "#/$defs/examples"
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-path"
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header"
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie"
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"$ref": "#/$defs/styles-for-form"
|
|
783
|
+
}
|
|
784
|
+
],
|
|
785
|
+
"$defs": {
|
|
786
|
+
"styles-for-path": {
|
|
787
|
+
"if": {
|
|
788
|
+
"properties": {
|
|
789
|
+
"in": {
|
|
790
|
+
"const": "path"
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
"required": [
|
|
794
|
+
"in"
|
|
795
|
+
]
|
|
796
|
+
},
|
|
797
|
+
"then": {
|
|
798
|
+
"properties": {
|
|
799
|
+
"style": {
|
|
800
|
+
"default": "simple",
|
|
801
|
+
"enum": [
|
|
802
|
+
"matrix",
|
|
803
|
+
"label",
|
|
804
|
+
"simple"
|
|
805
|
+
]
|
|
806
|
+
},
|
|
807
|
+
"required": {
|
|
808
|
+
"const": true
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
"required": [
|
|
812
|
+
"required"
|
|
813
|
+
]
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
"styles-for-header": {
|
|
817
|
+
"if": {
|
|
818
|
+
"properties": {
|
|
819
|
+
"in": {
|
|
820
|
+
"const": "header"
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
"required": [
|
|
824
|
+
"in"
|
|
825
|
+
]
|
|
826
|
+
},
|
|
827
|
+
"then": {
|
|
828
|
+
"properties": {
|
|
829
|
+
"style": {
|
|
830
|
+
"default": "simple",
|
|
831
|
+
"const": "simple"
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
"styles-for-query": {
|
|
837
|
+
"if": {
|
|
838
|
+
"properties": {
|
|
839
|
+
"in": {
|
|
840
|
+
"const": "query"
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
"required": [
|
|
844
|
+
"in"
|
|
845
|
+
]
|
|
846
|
+
},
|
|
847
|
+
"then": {
|
|
848
|
+
"properties": {
|
|
849
|
+
"style": {
|
|
850
|
+
"default": "form",
|
|
851
|
+
"enum": [
|
|
852
|
+
"form",
|
|
853
|
+
"spaceDelimited",
|
|
854
|
+
"pipeDelimited",
|
|
855
|
+
"deepObject"
|
|
856
|
+
]
|
|
857
|
+
},
|
|
858
|
+
"allowReserved": {
|
|
859
|
+
"default": false,
|
|
860
|
+
"type": "boolean"
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
"styles-for-cookie": {
|
|
866
|
+
"if": {
|
|
867
|
+
"properties": {
|
|
868
|
+
"in": {
|
|
869
|
+
"const": "cookie"
|
|
870
|
+
}
|
|
871
|
+
},
|
|
872
|
+
"required": [
|
|
873
|
+
"in"
|
|
874
|
+
]
|
|
875
|
+
},
|
|
876
|
+
"then": {
|
|
877
|
+
"properties": {
|
|
878
|
+
"style": {
|
|
879
|
+
"default": "form",
|
|
880
|
+
"const": "form"
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
},
|
|
888
|
+
"$ref": "#/$defs/specification-extensions",
|
|
889
|
+
"unevaluatedProperties": false
|
|
890
|
+
},
|
|
891
|
+
"parameter-or-reference": {
|
|
892
|
+
"if": {
|
|
893
|
+
"type": "object",
|
|
894
|
+
"required": [
|
|
895
|
+
"$ref"
|
|
896
|
+
]
|
|
897
|
+
},
|
|
898
|
+
"then": {
|
|
899
|
+
"$ref": "#/$defs/reference"
|
|
900
|
+
},
|
|
901
|
+
"else": {
|
|
902
|
+
"$ref": "#/$defs/parameter"
|
|
497
903
|
}
|
|
498
|
-
|
|
499
|
-
|
|
904
|
+
},
|
|
905
|
+
"request-body": {
|
|
906
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#request-body-object",
|
|
907
|
+
"type": "object",
|
|
908
|
+
"properties": {
|
|
909
|
+
"description": {
|
|
910
|
+
"type": "string"
|
|
911
|
+
},
|
|
912
|
+
"content": {
|
|
913
|
+
"$ref": "#/$defs/content"
|
|
914
|
+
},
|
|
915
|
+
"required": {
|
|
916
|
+
"default": false,
|
|
917
|
+
"type": "boolean"
|
|
918
|
+
}
|
|
919
|
+
},
|
|
920
|
+
"required": [
|
|
921
|
+
"content"
|
|
922
|
+
],
|
|
923
|
+
"$ref": "#/$defs/specification-extensions",
|
|
924
|
+
"unevaluatedProperties": false
|
|
925
|
+
},
|
|
926
|
+
"request-body-or-reference": {
|
|
927
|
+
"if": {
|
|
928
|
+
"type": "object",
|
|
929
|
+
"required": [
|
|
930
|
+
"$ref"
|
|
931
|
+
]
|
|
932
|
+
},
|
|
933
|
+
"then": {
|
|
934
|
+
"$ref": "#/$defs/reference"
|
|
935
|
+
},
|
|
936
|
+
"else": {
|
|
937
|
+
"$ref": "#/$defs/request-body"
|
|
500
938
|
}
|
|
501
|
-
|
|
502
|
-
|
|
939
|
+
},
|
|
940
|
+
"content": {
|
|
941
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#fixed-fields-10",
|
|
942
|
+
"type": "object",
|
|
943
|
+
"additionalProperties": {
|
|
944
|
+
"$ref": "#/$defs/media-type"
|
|
945
|
+
},
|
|
946
|
+
"propertyNames": {
|
|
947
|
+
"format": "media-range"
|
|
503
948
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
949
|
+
},
|
|
950
|
+
"media-type": {
|
|
951
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#media-type-object",
|
|
952
|
+
"type": "object",
|
|
953
|
+
"properties": {
|
|
954
|
+
"schema": {
|
|
955
|
+
"$ref": "#/$defs/schema"
|
|
956
|
+
},
|
|
957
|
+
"encoding": {
|
|
958
|
+
"type": "object",
|
|
959
|
+
"additionalProperties": {
|
|
960
|
+
"$ref": "#/$defs/encoding"
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
"allOf": [
|
|
965
|
+
{
|
|
966
|
+
"$ref": "#/$defs/specification-extensions"
|
|
967
|
+
},
|
|
968
|
+
{
|
|
969
|
+
"$ref": "#/$defs/examples"
|
|
970
|
+
}
|
|
971
|
+
],
|
|
972
|
+
"unevaluatedProperties": false
|
|
973
|
+
},
|
|
974
|
+
"encoding": {
|
|
975
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#encoding-object",
|
|
976
|
+
"type": "object",
|
|
977
|
+
"properties": {
|
|
978
|
+
"contentType": {
|
|
979
|
+
"type": "string",
|
|
980
|
+
"format": "media-range"
|
|
981
|
+
},
|
|
982
|
+
"headers": {
|
|
983
|
+
"type": "object",
|
|
984
|
+
"additionalProperties": {
|
|
985
|
+
"$ref": "#/$defs/header-or-reference"
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
"style": {
|
|
989
|
+
"default": "form",
|
|
990
|
+
"enum": [
|
|
991
|
+
"form",
|
|
992
|
+
"spaceDelimited",
|
|
993
|
+
"pipeDelimited",
|
|
994
|
+
"deepObject"
|
|
995
|
+
]
|
|
996
|
+
},
|
|
997
|
+
"explode": {
|
|
998
|
+
"type": "boolean"
|
|
999
|
+
},
|
|
1000
|
+
"allowReserved": {
|
|
1001
|
+
"default": false,
|
|
1002
|
+
"type": "boolean"
|
|
1003
|
+
}
|
|
1004
|
+
},
|
|
1005
|
+
"allOf": [
|
|
1006
|
+
{
|
|
1007
|
+
"$ref": "#/$defs/specification-extensions"
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
"$ref": "#/$defs/styles-for-form"
|
|
1011
|
+
}
|
|
1012
|
+
],
|
|
1013
|
+
"unevaluatedProperties": false
|
|
1014
|
+
},
|
|
1015
|
+
"responses": {
|
|
1016
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#responses-object",
|
|
1017
|
+
"type": "object",
|
|
1018
|
+
"properties": {
|
|
1019
|
+
"default": {
|
|
1020
|
+
"$ref": "#/$defs/response-or-reference"
|
|
1021
|
+
}
|
|
1022
|
+
},
|
|
1023
|
+
"patternProperties": {
|
|
1024
|
+
"^[1-5](?:[0-9]{2}|XX)$": {
|
|
1025
|
+
"$ref": "#/$defs/response-or-reference"
|
|
1026
|
+
}
|
|
1027
|
+
},
|
|
1028
|
+
"minProperties": 1,
|
|
1029
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1030
|
+
"unevaluatedProperties": false,
|
|
1031
|
+
"if": {
|
|
1032
|
+
"$comment": "either default, or at least one response code property must exist",
|
|
1033
|
+
"patternProperties": {
|
|
1034
|
+
"^[1-5](?:[0-9]{2}|XX)$": false
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
"then": {
|
|
1038
|
+
"required": [
|
|
1039
|
+
"default"
|
|
1040
|
+
]
|
|
1041
|
+
}
|
|
1042
|
+
},
|
|
1043
|
+
"response": {
|
|
1044
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#response-object",
|
|
1045
|
+
"type": "object",
|
|
1046
|
+
"properties": {
|
|
1047
|
+
"description": {
|
|
1048
|
+
"type": "string"
|
|
1049
|
+
},
|
|
1050
|
+
"headers": {
|
|
1051
|
+
"type": "object",
|
|
1052
|
+
"additionalProperties": {
|
|
1053
|
+
"$ref": "#/$defs/header-or-reference"
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
"content": {
|
|
1057
|
+
"$ref": "#/$defs/content"
|
|
1058
|
+
},
|
|
1059
|
+
"links": {
|
|
1060
|
+
"type": "object",
|
|
1061
|
+
"additionalProperties": {
|
|
1062
|
+
"$ref": "#/$defs/link-or-reference"
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
"required": [
|
|
1067
|
+
"description"
|
|
1068
|
+
],
|
|
1069
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1070
|
+
"unevaluatedProperties": false
|
|
1071
|
+
},
|
|
1072
|
+
"response-or-reference": {
|
|
1073
|
+
"if": {
|
|
1074
|
+
"type": "object",
|
|
1075
|
+
"required": [
|
|
1076
|
+
"$ref"
|
|
1077
|
+
]
|
|
1078
|
+
},
|
|
1079
|
+
"then": {
|
|
1080
|
+
"$ref": "#/$defs/reference"
|
|
1081
|
+
},
|
|
1082
|
+
"else": {
|
|
1083
|
+
"$ref": "#/$defs/response"
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
"callbacks": {
|
|
1087
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#callback-object",
|
|
1088
|
+
"type": "object",
|
|
1089
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1090
|
+
"additionalProperties": {
|
|
1091
|
+
"$ref": "#/$defs/path-item"
|
|
1092
|
+
}
|
|
1093
|
+
},
|
|
1094
|
+
"callbacks-or-reference": {
|
|
1095
|
+
"if": {
|
|
1096
|
+
"type": "object",
|
|
1097
|
+
"required": [
|
|
1098
|
+
"$ref"
|
|
1099
|
+
]
|
|
1100
|
+
},
|
|
1101
|
+
"then": {
|
|
1102
|
+
"$ref": "#/$defs/reference"
|
|
1103
|
+
},
|
|
1104
|
+
"else": {
|
|
1105
|
+
"$ref": "#/$defs/callbacks"
|
|
1106
|
+
}
|
|
1107
|
+
},
|
|
1108
|
+
"example": {
|
|
1109
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#example-object",
|
|
1110
|
+
"type": "object",
|
|
1111
|
+
"properties": {
|
|
1112
|
+
"summary": {
|
|
1113
|
+
"type": "string"
|
|
1114
|
+
},
|
|
1115
|
+
"description": {
|
|
1116
|
+
"type": "string"
|
|
1117
|
+
},
|
|
1118
|
+
"value": true,
|
|
1119
|
+
"externalValue": {
|
|
1120
|
+
"type": "string",
|
|
1121
|
+
"format": "uri-reference"
|
|
1122
|
+
}
|
|
1123
|
+
},
|
|
1124
|
+
"not": {
|
|
1125
|
+
"required": [
|
|
1126
|
+
"value",
|
|
1127
|
+
"externalValue"
|
|
1128
|
+
]
|
|
1129
|
+
},
|
|
1130
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1131
|
+
"unevaluatedProperties": false
|
|
1132
|
+
},
|
|
1133
|
+
"example-or-reference": {
|
|
1134
|
+
"if": {
|
|
1135
|
+
"type": "object",
|
|
1136
|
+
"required": [
|
|
1137
|
+
"$ref"
|
|
1138
|
+
]
|
|
1139
|
+
},
|
|
1140
|
+
"then": {
|
|
1141
|
+
"$ref": "#/$defs/reference"
|
|
1142
|
+
},
|
|
1143
|
+
"else": {
|
|
1144
|
+
"$ref": "#/$defs/example"
|
|
1145
|
+
}
|
|
1146
|
+
},
|
|
1147
|
+
"link": {
|
|
1148
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#link-object",
|
|
1149
|
+
"type": "object",
|
|
1150
|
+
"properties": {
|
|
1151
|
+
"operationRef": {
|
|
1152
|
+
"type": "string",
|
|
1153
|
+
"format": "uri-reference"
|
|
1154
|
+
},
|
|
1155
|
+
"operationId": {
|
|
1156
|
+
"type": "string"
|
|
1157
|
+
},
|
|
1158
|
+
"parameters": {
|
|
1159
|
+
"$ref": "#/$defs/map-of-strings"
|
|
1160
|
+
},
|
|
1161
|
+
"requestBody": true,
|
|
1162
|
+
"description": {
|
|
1163
|
+
"type": "string"
|
|
1164
|
+
},
|
|
1165
|
+
"server": {
|
|
1166
|
+
"$ref": "#/$defs/server"
|
|
1167
|
+
}
|
|
1168
|
+
},
|
|
1169
|
+
"oneOf": [
|
|
1170
|
+
{
|
|
1171
|
+
"required": [
|
|
1172
|
+
"operationRef"
|
|
1173
|
+
]
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
"required": [
|
|
1177
|
+
"operationId"
|
|
1178
|
+
]
|
|
1179
|
+
}
|
|
1180
|
+
],
|
|
1181
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1182
|
+
"unevaluatedProperties": false
|
|
1183
|
+
},
|
|
1184
|
+
"link-or-reference": {
|
|
1185
|
+
"if": {
|
|
1186
|
+
"type": "object",
|
|
1187
|
+
"required": [
|
|
1188
|
+
"$ref"
|
|
1189
|
+
]
|
|
1190
|
+
},
|
|
1191
|
+
"then": {
|
|
1192
|
+
"$ref": "#/$defs/reference"
|
|
1193
|
+
},
|
|
1194
|
+
"else": {
|
|
1195
|
+
"$ref": "#/$defs/link"
|
|
1196
|
+
}
|
|
1197
|
+
},
|
|
1198
|
+
"header": {
|
|
1199
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#header-object",
|
|
1200
|
+
"type": "object",
|
|
1201
|
+
"properties": {
|
|
1202
|
+
"description": {
|
|
1203
|
+
"type": "string"
|
|
1204
|
+
},
|
|
1205
|
+
"required": {
|
|
1206
|
+
"default": false,
|
|
1207
|
+
"type": "boolean"
|
|
1208
|
+
},
|
|
1209
|
+
"deprecated": {
|
|
1210
|
+
"default": false,
|
|
1211
|
+
"type": "boolean"
|
|
1212
|
+
},
|
|
1213
|
+
"schema": {
|
|
1214
|
+
"$ref": "#/$defs/schema"
|
|
1215
|
+
},
|
|
1216
|
+
"content": {
|
|
1217
|
+
"$ref": "#/$defs/content",
|
|
1218
|
+
"minProperties": 1,
|
|
1219
|
+
"maxProperties": 1
|
|
1220
|
+
}
|
|
1221
|
+
},
|
|
1222
|
+
"oneOf": [
|
|
1223
|
+
{
|
|
1224
|
+
"required": [
|
|
1225
|
+
"schema"
|
|
1226
|
+
]
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"required": [
|
|
1230
|
+
"content"
|
|
1231
|
+
]
|
|
1232
|
+
}
|
|
1233
|
+
],
|
|
1234
|
+
"dependentSchemas": {
|
|
1235
|
+
"schema": {
|
|
1236
|
+
"properties": {
|
|
1237
|
+
"style": {
|
|
1238
|
+
"default": "simple",
|
|
1239
|
+
"const": "simple"
|
|
1240
|
+
},
|
|
1241
|
+
"explode": {
|
|
1242
|
+
"default": false,
|
|
1243
|
+
"type": "boolean"
|
|
1244
|
+
}
|
|
1245
|
+
},
|
|
1246
|
+
"$ref": "#/$defs/examples"
|
|
1247
|
+
}
|
|
1248
|
+
},
|
|
1249
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1250
|
+
"unevaluatedProperties": false
|
|
1251
|
+
},
|
|
1252
|
+
"header-or-reference": {
|
|
1253
|
+
"if": {
|
|
1254
|
+
"type": "object",
|
|
1255
|
+
"required": [
|
|
1256
|
+
"$ref"
|
|
1257
|
+
]
|
|
1258
|
+
},
|
|
1259
|
+
"then": {
|
|
1260
|
+
"$ref": "#/$defs/reference"
|
|
1261
|
+
},
|
|
1262
|
+
"else": {
|
|
1263
|
+
"$ref": "#/$defs/header"
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
"tag": {
|
|
1267
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#tag-object",
|
|
1268
|
+
"type": "object",
|
|
1269
|
+
"properties": {
|
|
1270
|
+
"name": {
|
|
1271
|
+
"type": "string"
|
|
1272
|
+
},
|
|
1273
|
+
"description": {
|
|
1274
|
+
"type": "string"
|
|
1275
|
+
},
|
|
1276
|
+
"externalDocs": {
|
|
1277
|
+
"$ref": "#/$defs/external-documentation"
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
"required": [
|
|
1281
|
+
"name"
|
|
1282
|
+
],
|
|
1283
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1284
|
+
"unevaluatedProperties": false
|
|
1285
|
+
},
|
|
1286
|
+
"reference": {
|
|
1287
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#reference-object",
|
|
1288
|
+
"type": "object",
|
|
1289
|
+
"properties": {
|
|
1290
|
+
"$ref": {
|
|
1291
|
+
"type": "string",
|
|
1292
|
+
"format": "uri-reference"
|
|
1293
|
+
},
|
|
1294
|
+
"summary": {
|
|
1295
|
+
"type": "string"
|
|
1296
|
+
},
|
|
1297
|
+
"description": {
|
|
1298
|
+
"type": "string"
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
"schema": {
|
|
1303
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#schema-object",
|
|
1304
|
+
"$ref": "https://spec.openapis.org/oas/3.1/dialect/base"
|
|
1305
|
+
},
|
|
1306
|
+
"security-scheme": {
|
|
1307
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#security-scheme-object",
|
|
1308
|
+
"type": "object",
|
|
1309
|
+
"properties": {
|
|
1310
|
+
"type": {
|
|
1311
|
+
"enum": [
|
|
1312
|
+
"apiKey",
|
|
1313
|
+
"http",
|
|
1314
|
+
"mutualTLS",
|
|
1315
|
+
"oauth2",
|
|
1316
|
+
"openIdConnect"
|
|
1317
|
+
]
|
|
1318
|
+
},
|
|
1319
|
+
"description": {
|
|
1320
|
+
"type": "string"
|
|
1321
|
+
}
|
|
1322
|
+
},
|
|
1323
|
+
"required": [
|
|
1324
|
+
"type"
|
|
1325
|
+
],
|
|
1326
|
+
"allOf": [
|
|
1327
|
+
{
|
|
1328
|
+
"$ref": "#/$defs/specification-extensions"
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
"$ref": "#/$defs/security-scheme/$defs/type-apikey"
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
"$ref": "#/$defs/security-scheme/$defs/type-http"
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
"$ref": "#/$defs/security-scheme/$defs/type-http-bearer"
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
"$ref": "#/$defs/security-scheme/$defs/type-oauth2"
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
"$ref": "#/$defs/security-scheme/$defs/type-oidc"
|
|
1344
|
+
}
|
|
1345
|
+
],
|
|
1346
|
+
"unevaluatedProperties": false,
|
|
1347
|
+
"$defs": {
|
|
1348
|
+
"type-apikey": {
|
|
1349
|
+
"if": {
|
|
1350
|
+
"properties": {
|
|
1351
|
+
"type": {
|
|
1352
|
+
"const": "apiKey"
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
"required": [
|
|
1356
|
+
"type"
|
|
1357
|
+
]
|
|
1358
|
+
},
|
|
1359
|
+
"then": {
|
|
1360
|
+
"properties": {
|
|
1361
|
+
"name": {
|
|
1362
|
+
"type": "string"
|
|
1363
|
+
},
|
|
1364
|
+
"in": {
|
|
1365
|
+
"enum": [
|
|
1366
|
+
"query",
|
|
1367
|
+
"header",
|
|
1368
|
+
"cookie"
|
|
1369
|
+
]
|
|
1370
|
+
}
|
|
1371
|
+
},
|
|
1372
|
+
"required": [
|
|
1373
|
+
"name",
|
|
1374
|
+
"in"
|
|
1375
|
+
]
|
|
1376
|
+
}
|
|
1377
|
+
},
|
|
1378
|
+
"type-http": {
|
|
1379
|
+
"if": {
|
|
1380
|
+
"properties": {
|
|
1381
|
+
"type": {
|
|
1382
|
+
"const": "http"
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
"required": [
|
|
1386
|
+
"type"
|
|
1387
|
+
]
|
|
1388
|
+
},
|
|
1389
|
+
"then": {
|
|
1390
|
+
"properties": {
|
|
1391
|
+
"scheme": {
|
|
1392
|
+
"type": "string"
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
"required": [
|
|
1396
|
+
"scheme"
|
|
1397
|
+
]
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1400
|
+
"type-http-bearer": {
|
|
1401
|
+
"if": {
|
|
1402
|
+
"properties": {
|
|
1403
|
+
"type": {
|
|
1404
|
+
"const": "http"
|
|
1405
|
+
},
|
|
1406
|
+
"scheme": {
|
|
1407
|
+
"type": "string",
|
|
1408
|
+
"pattern": "^[Bb][Ee][Aa][Rr][Ee][Rr]$"
|
|
1409
|
+
}
|
|
1410
|
+
},
|
|
1411
|
+
"required": [
|
|
1412
|
+
"type",
|
|
1413
|
+
"scheme"
|
|
1414
|
+
]
|
|
1415
|
+
},
|
|
1416
|
+
"then": {
|
|
1417
|
+
"properties": {
|
|
1418
|
+
"bearerFormat": {
|
|
1419
|
+
"type": "string"
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
"type-oauth2": {
|
|
1425
|
+
"if": {
|
|
1426
|
+
"properties": {
|
|
1427
|
+
"type": {
|
|
1428
|
+
"const": "oauth2"
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
"required": [
|
|
1432
|
+
"type"
|
|
1433
|
+
]
|
|
1434
|
+
},
|
|
1435
|
+
"then": {
|
|
1436
|
+
"properties": {
|
|
1437
|
+
"flows": {
|
|
1438
|
+
"$ref": "#/$defs/oauth-flows"
|
|
1439
|
+
}
|
|
1440
|
+
},
|
|
1441
|
+
"required": [
|
|
1442
|
+
"flows"
|
|
1443
|
+
]
|
|
1444
|
+
}
|
|
1445
|
+
},
|
|
1446
|
+
"type-oidc": {
|
|
1447
|
+
"if": {
|
|
1448
|
+
"properties": {
|
|
1449
|
+
"type": {
|
|
1450
|
+
"const": "openIdConnect"
|
|
1451
|
+
}
|
|
1452
|
+
},
|
|
1453
|
+
"required": [
|
|
1454
|
+
"type"
|
|
1455
|
+
]
|
|
1456
|
+
},
|
|
1457
|
+
"then": {
|
|
1458
|
+
"properties": {
|
|
1459
|
+
"openIdConnectUrl": {
|
|
1460
|
+
"type": "string",
|
|
1461
|
+
"format": "uri-reference"
|
|
1462
|
+
}
|
|
1463
|
+
},
|
|
1464
|
+
"required": [
|
|
1465
|
+
"openIdConnectUrl"
|
|
1466
|
+
]
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
},
|
|
1471
|
+
"security-scheme-or-reference": {
|
|
1472
|
+
"if": {
|
|
1473
|
+
"type": "object",
|
|
1474
|
+
"required": [
|
|
1475
|
+
"$ref"
|
|
1476
|
+
]
|
|
1477
|
+
},
|
|
1478
|
+
"then": {
|
|
1479
|
+
"$ref": "#/$defs/reference"
|
|
1480
|
+
},
|
|
1481
|
+
"else": {
|
|
1482
|
+
"$ref": "#/$defs/security-scheme"
|
|
1483
|
+
}
|
|
1484
|
+
},
|
|
1485
|
+
"oauth-flows": {
|
|
1486
|
+
"type": "object",
|
|
1487
|
+
"properties": {
|
|
1488
|
+
"implicit": {
|
|
1489
|
+
"$ref": "#/$defs/oauth-flows/$defs/implicit"
|
|
1490
|
+
},
|
|
1491
|
+
"password": {
|
|
1492
|
+
"$ref": "#/$defs/oauth-flows/$defs/password"
|
|
1493
|
+
},
|
|
1494
|
+
"clientCredentials": {
|
|
1495
|
+
"$ref": "#/$defs/oauth-flows/$defs/client-credentials"
|
|
1496
|
+
},
|
|
1497
|
+
"authorizationCode": {
|
|
1498
|
+
"$ref": "#/$defs/oauth-flows/$defs/authorization-code"
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1502
|
+
"unevaluatedProperties": false,
|
|
1503
|
+
"$defs": {
|
|
1504
|
+
"implicit": {
|
|
1505
|
+
"type": "object",
|
|
1506
|
+
"properties": {
|
|
1507
|
+
"authorizationUrl": {
|
|
1508
|
+
"type": "string",
|
|
1509
|
+
"format": "uri-reference"
|
|
1510
|
+
},
|
|
1511
|
+
"refreshUrl": {
|
|
1512
|
+
"type": "string",
|
|
1513
|
+
"format": "uri-reference"
|
|
1514
|
+
},
|
|
1515
|
+
"scopes": {
|
|
1516
|
+
"$ref": "#/$defs/map-of-strings"
|
|
1517
|
+
}
|
|
1518
|
+
},
|
|
1519
|
+
"required": [
|
|
1520
|
+
"authorizationUrl",
|
|
1521
|
+
"scopes"
|
|
1522
|
+
],
|
|
1523
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1524
|
+
"unevaluatedProperties": false
|
|
1525
|
+
},
|
|
1526
|
+
"password": {
|
|
1527
|
+
"type": "object",
|
|
1528
|
+
"properties": {
|
|
1529
|
+
"tokenUrl": {
|
|
1530
|
+
"type": "string",
|
|
1531
|
+
"format": "uri-reference"
|
|
1532
|
+
},
|
|
1533
|
+
"refreshUrl": {
|
|
1534
|
+
"type": "string",
|
|
1535
|
+
"format": "uri-reference"
|
|
1536
|
+
},
|
|
1537
|
+
"scopes": {
|
|
1538
|
+
"$ref": "#/$defs/map-of-strings"
|
|
1539
|
+
}
|
|
1540
|
+
},
|
|
1541
|
+
"required": [
|
|
1542
|
+
"tokenUrl",
|
|
1543
|
+
"scopes"
|
|
1544
|
+
],
|
|
1545
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1546
|
+
"unevaluatedProperties": false
|
|
1547
|
+
},
|
|
1548
|
+
"client-credentials": {
|
|
1549
|
+
"type": "object",
|
|
1550
|
+
"properties": {
|
|
1551
|
+
"tokenUrl": {
|
|
1552
|
+
"type": "string",
|
|
1553
|
+
"format": "uri-reference"
|
|
1554
|
+
},
|
|
1555
|
+
"refreshUrl": {
|
|
1556
|
+
"type": "string",
|
|
1557
|
+
"format": "uri-reference"
|
|
1558
|
+
},
|
|
1559
|
+
"scopes": {
|
|
1560
|
+
"$ref": "#/$defs/map-of-strings"
|
|
1561
|
+
}
|
|
1562
|
+
},
|
|
1563
|
+
"required": [
|
|
1564
|
+
"tokenUrl",
|
|
1565
|
+
"scopes"
|
|
1566
|
+
],
|
|
1567
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1568
|
+
"unevaluatedProperties": false
|
|
1569
|
+
},
|
|
1570
|
+
"authorization-code": {
|
|
1571
|
+
"type": "object",
|
|
1572
|
+
"properties": {
|
|
1573
|
+
"authorizationUrl": {
|
|
1574
|
+
"type": "string",
|
|
1575
|
+
"format": "uri-reference"
|
|
1576
|
+
},
|
|
1577
|
+
"tokenUrl": {
|
|
1578
|
+
"type": "string",
|
|
1579
|
+
"format": "uri-reference"
|
|
1580
|
+
},
|
|
1581
|
+
"refreshUrl": {
|
|
1582
|
+
"type": "string",
|
|
1583
|
+
"format": "uri-reference"
|
|
1584
|
+
},
|
|
1585
|
+
"scopes": {
|
|
1586
|
+
"$ref": "#/$defs/map-of-strings"
|
|
1587
|
+
}
|
|
1588
|
+
},
|
|
1589
|
+
"required": [
|
|
1590
|
+
"authorizationUrl",
|
|
1591
|
+
"tokenUrl",
|
|
1592
|
+
"scopes"
|
|
1593
|
+
],
|
|
1594
|
+
"$ref": "#/$defs/specification-extensions",
|
|
1595
|
+
"unevaluatedProperties": false
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
},
|
|
1599
|
+
"security-requirement": {
|
|
1600
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#security-requirement-object",
|
|
1601
|
+
"type": "object",
|
|
1602
|
+
"additionalProperties": {
|
|
1603
|
+
"type": "array",
|
|
1604
|
+
"items": {
|
|
1605
|
+
"type": "string"
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
"specification-extensions": {
|
|
1610
|
+
"$comment": "https://spec.openapis.org/oas/v3.1#specification-extensions",
|
|
1611
|
+
"patternProperties": {
|
|
1612
|
+
"^x-": true
|
|
1613
|
+
}
|
|
1614
|
+
},
|
|
1615
|
+
"examples": {
|
|
1616
|
+
"properties": {
|
|
1617
|
+
"example": true,
|
|
1618
|
+
"examples": {
|
|
1619
|
+
"type": "object",
|
|
1620
|
+
"additionalProperties": {
|
|
1621
|
+
"$ref": "#/$defs/example-or-reference"
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
},
|
|
1626
|
+
"map-of-strings": {
|
|
1627
|
+
"type": "object",
|
|
1628
|
+
"additionalProperties": {
|
|
1629
|
+
"type": "string"
|
|
1630
|
+
}
|
|
1631
|
+
},
|
|
1632
|
+
"styles-for-form": {
|
|
1633
|
+
"if": {
|
|
1634
|
+
"properties": {
|
|
1635
|
+
"style": {
|
|
1636
|
+
"const": "form"
|
|
1637
|
+
}
|
|
1638
|
+
},
|
|
1639
|
+
"required": [
|
|
1640
|
+
"style"
|
|
1641
|
+
]
|
|
1642
|
+
},
|
|
1643
|
+
"then": {
|
|
1644
|
+
"properties": {
|
|
1645
|
+
"explode": {
|
|
1646
|
+
"default": true
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
},
|
|
1650
|
+
"else": {
|
|
1651
|
+
"properties": {
|
|
1652
|
+
"explode": {
|
|
1653
|
+
"default": false
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
// schema/openapi-3-1/schema-base.js
|
|
1662
|
+
var schema_base_default = {
|
|
1663
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
1664
|
+
"$vocabulary": {
|
|
1665
|
+
"https://json-schema.org/draft/2020-12/vocab/core": true,
|
|
1666
|
+
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
|
|
1667
|
+
"https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
|
|
1668
|
+
"https://json-schema.org/draft/2020-12/vocab/validation": true,
|
|
1669
|
+
"https://json-schema.org/draft/2020-12/vocab/meta-data": true,
|
|
1670
|
+
"https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
|
|
1671
|
+
"https://json-schema.org/draft/2020-12/vocab/content": true,
|
|
1672
|
+
"https://spec.openapis.org/oas/3.1/vocab/base": false
|
|
1673
|
+
},
|
|
1674
|
+
"description": "The description of OpenAPI v3.1.x Documents using the OpenAPI JSON Schema dialect",
|
|
1675
|
+
"$ref": "https://spec.openapis.org/oas/3.1/schema",
|
|
1676
|
+
"properties": {
|
|
1677
|
+
"jsonSchemaDialect": { "$ref": "#/$defs/dialect" }
|
|
1678
|
+
},
|
|
1679
|
+
"$defs": {
|
|
1680
|
+
"dialect": { "const": "https://spec.openapis.org/oas/3.1/dialect/base" },
|
|
1681
|
+
"schema": {
|
|
1682
|
+
"$ref": "https://spec.openapis.org/oas/3.1/dialect/base",
|
|
1683
|
+
"properties": {
|
|
1684
|
+
"$schema": { "$ref": "#/$defs/dialect" }
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
// schema/openapi-3-1/meta/base.js
|
|
1691
|
+
var base_default = {
|
|
1692
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
1693
|
+
"title": "OAS Base Vocabulary",
|
|
1694
|
+
"description": "A JSON Schema Vocabulary used in the OpenAPI Schema Dialect",
|
|
1695
|
+
"type": ["object", "boolean"],
|
|
1696
|
+
"properties": {
|
|
1697
|
+
"example": true,
|
|
1698
|
+
"discriminator": { "$ref": "#/$defs/discriminator" },
|
|
1699
|
+
"externalDocs": { "$ref": "#/$defs/external-docs" },
|
|
1700
|
+
"xml": { "$ref": "#/$defs/xml" }
|
|
1701
|
+
},
|
|
1702
|
+
"$defs": {
|
|
1703
|
+
"extensible": {
|
|
1704
|
+
"patternProperties": {
|
|
1705
|
+
"^x-": true
|
|
1706
|
+
}
|
|
1707
|
+
},
|
|
1708
|
+
"discriminator": {
|
|
1709
|
+
"$ref": "#/$defs/extensible",
|
|
1710
|
+
"type": "object",
|
|
1711
|
+
"properties": {
|
|
1712
|
+
"propertyName": {
|
|
1713
|
+
"type": "string"
|
|
1714
|
+
},
|
|
1715
|
+
"mapping": {
|
|
1716
|
+
"type": "object",
|
|
1717
|
+
"additionalProperties": {
|
|
1718
|
+
"type": "string"
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
},
|
|
1722
|
+
"required": ["propertyName"],
|
|
1723
|
+
"unevaluatedProperties": false
|
|
1724
|
+
},
|
|
1725
|
+
"external-docs": {
|
|
1726
|
+
"$ref": "#/$defs/extensible",
|
|
1727
|
+
"type": "object",
|
|
1728
|
+
"properties": {
|
|
1729
|
+
"url": {
|
|
1730
|
+
"type": "string",
|
|
1731
|
+
"format": "uri-reference"
|
|
1732
|
+
},
|
|
1733
|
+
"description": {
|
|
1734
|
+
"type": "string"
|
|
1735
|
+
}
|
|
1736
|
+
},
|
|
1737
|
+
"required": ["url"],
|
|
1738
|
+
"unevaluatedProperties": false
|
|
1739
|
+
},
|
|
1740
|
+
"xml": {
|
|
1741
|
+
"$ref": "#/$defs/extensible",
|
|
1742
|
+
"type": "object",
|
|
1743
|
+
"properties": {
|
|
1744
|
+
"name": {
|
|
1745
|
+
"type": "string"
|
|
1746
|
+
},
|
|
1747
|
+
"namespace": {
|
|
1748
|
+
"type": "string",
|
|
1749
|
+
"format": "uri"
|
|
1750
|
+
},
|
|
1751
|
+
"prefix": {
|
|
1752
|
+
"type": "string"
|
|
1753
|
+
},
|
|
1754
|
+
"attribute": {
|
|
1755
|
+
"type": "boolean"
|
|
1756
|
+
},
|
|
1757
|
+
"wrapped": {
|
|
1758
|
+
"type": "boolean"
|
|
1759
|
+
}
|
|
1760
|
+
},
|
|
1761
|
+
"unevaluatedProperties": false
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
|
|
1766
|
+
// schema/openapi-3-1/dialect/base.js
|
|
1767
|
+
var base_default2 = {
|
|
1768
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
1769
|
+
"$vocabulary": {
|
|
1770
|
+
"https://json-schema.org/draft/2020-12/vocab/core": true,
|
|
1771
|
+
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
|
|
1772
|
+
"https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
|
|
1773
|
+
"https://json-schema.org/draft/2020-12/vocab/validation": true,
|
|
1774
|
+
"https://json-schema.org/draft/2020-12/vocab/meta-data": true,
|
|
1775
|
+
"https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
|
|
1776
|
+
"https://json-schema.org/draft/2020-12/vocab/content": true,
|
|
1777
|
+
"https://spec.openapis.org/oas/3.1/vocab/base": false
|
|
1778
|
+
},
|
|
1779
|
+
"title": "OpenAPI 3.1 Schema Object Dialect",
|
|
1780
|
+
"description": "A JSON Schema dialect describing schemas found in OpenAPI v3.1 Descriptions",
|
|
1781
|
+
"allOf": [
|
|
1782
|
+
{ "$ref": "https://json-schema.org/draft/2020-12/schema" },
|
|
1783
|
+
{ "$ref": "https://spec.openapis.org/oas/3.1/meta/base" }
|
|
1784
|
+
]
|
|
1785
|
+
};
|
|
1786
|
+
|
|
1787
|
+
// src/ajv.js
|
|
1788
|
+
var ajv = new import__.default({
|
|
1789
|
+
strictTypes: false,
|
|
1790
|
+
validateFormats: true,
|
|
1791
|
+
allowUnionTypes: true,
|
|
1792
|
+
allowMatchingProperties: true
|
|
1793
|
+
});
|
|
1794
|
+
(0, import_ajv_formats.default)(ajv);
|
|
1795
|
+
ajv.addFormat("media-range", {
|
|
1796
|
+
type: "string",
|
|
1797
|
+
validate: /* @__PURE__ */ __name((value) => {
|
|
1798
|
+
return /^[a-z]+\/([a-z0-9\-+.]+|\*)$/i.test(value);
|
|
1799
|
+
}, "validate")
|
|
1800
|
+
});
|
|
1801
|
+
ajv.addSchema(base_default, "https://spec.openapis.org/oas/3.1/meta/base");
|
|
1802
|
+
ajv.addSchema(base_default2, "https://spec.openapis.org/oas/3.1/dialect/base");
|
|
1803
|
+
ajv.addSchema(schema_base_default, "https://spec.openapis.org/oas/3.1/schema-base");
|
|
1804
|
+
ajv.addSchema(schema_default, "https://spec.openapis.org/oas/3.1/schema");
|
|
1805
|
+
var OA_DOCUMENT_OBJECT_JSON_SCHEMA_URI = "https://spec.openapis.org/oas/3.1/schema";
|
|
1806
|
+
ajv.getSchema(OA_DOCUMENT_OBJECT_JSON_SCHEMA_URI);
|
|
1807
|
+
|
|
1808
|
+
// src/oa-document-object/validate-oa-document-object.js
|
|
1809
|
+
function validateOADocumentObject(data, options = {}) {
|
|
1810
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
1811
|
+
throw new import_js_format5.InvalidArgumentError(
|
|
1812
|
+
'Parameter "options" must be an Object, but %v was given.',
|
|
1813
|
+
options
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
if (options.schemaUri !== void 0) {
|
|
1817
|
+
if (typeof options.schemaUri !== "string") {
|
|
1818
|
+
throw new import_js_format5.InvalidArgumentError(
|
|
1819
|
+
'Option "schemaUri" must be a String, but %v was given.',
|
|
1820
|
+
options.schemaUri
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
if (options.dataSourceUri !== void 0) {
|
|
1825
|
+
if (typeof options.dataSourceUri !== "string") {
|
|
1826
|
+
throw new import_js_format5.InvalidArgumentError(
|
|
1827
|
+
'Option "dataSourceUri" must be a String, but %v was given.',
|
|
1828
|
+
options.dataSourceUri
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
const validate = ajv.getSchema(
|
|
1833
|
+
`${OA_DOCUMENT_OBJECT_JSON_SCHEMA_URI}${options.schemaUri || ""}`
|
|
1834
|
+
);
|
|
1835
|
+
const isValid = validate(data);
|
|
1836
|
+
if (!isValid) {
|
|
1837
|
+
const error = validate.errors[0];
|
|
1838
|
+
let instancePath = error.instancePath || "";
|
|
1839
|
+
let dataSourceUri = options.dataSourceUri || "";
|
|
1840
|
+
if (!options.schemaUri && !options.dataSourceUri) {
|
|
1841
|
+
dataSourceUri = "#";
|
|
1842
|
+
}
|
|
1843
|
+
throw new OADocumentObjectValidationError(
|
|
1844
|
+
"Value at %v %s.",
|
|
1845
|
+
dataSourceUri && error.instancePath ? [dataSourceUri, error.instancePath].join("/").replace(/\/+/g, "/") : dataSourceUri + instancePath,
|
|
1846
|
+
error.message.replace(/'/g, '"')
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
__name(validateOADocumentObject, "validateOADocumentObject");
|
|
1851
|
+
|
|
1852
|
+
// src/oa-document-builder.js
|
|
1853
|
+
var OAComponentType = {
|
|
1854
|
+
SCHEMA: "schema",
|
|
1855
|
+
RESPONSE: "response",
|
|
1856
|
+
PARAMETER: "parameter",
|
|
1857
|
+
EXAMPLE: "example",
|
|
1858
|
+
REQUEST_BODY: "requestBody",
|
|
1859
|
+
HEADER: "header",
|
|
1860
|
+
SECURITY_SCHEME: "securityScheme",
|
|
1861
|
+
LINK: "link",
|
|
1862
|
+
CALLBACK: "callback",
|
|
1863
|
+
PATH_ITEM: "pathItem"
|
|
1864
|
+
};
|
|
1865
|
+
var OA_COMPONENT_TYPES = Object.values(OAComponentType);
|
|
1866
|
+
var OA_COMPONENT_NAME_REGEX = /^[a-zA-Z0-9.\-_]+$/;
|
|
1867
|
+
var OA_COMPONENT_TYPE_TO_COMPONENTS_KEY_MAP = {
|
|
1868
|
+
[OAComponentType.SCHEMA]: "schemas",
|
|
1869
|
+
[OAComponentType.RESPONSE]: "responses",
|
|
1870
|
+
[OAComponentType.PARAMETER]: "parameters",
|
|
1871
|
+
[OAComponentType.EXAMPLE]: "examples",
|
|
1872
|
+
[OAComponentType.REQUEST_BODY]: "requestBodies",
|
|
1873
|
+
[OAComponentType.HEADER]: "headers",
|
|
1874
|
+
[OAComponentType.SECURITY_SCHEME]: "securitySchemes",
|
|
1875
|
+
[OAComponentType.LINK]: "links",
|
|
1876
|
+
[OAComponentType.CALLBACK]: "callbacks",
|
|
1877
|
+
[OAComponentType.PATH_ITEM]: "pathItems"
|
|
1878
|
+
};
|
|
1879
|
+
var OA_COMPONENT_TYPE_TO_DEFINITION_NAME_MAP = {
|
|
1880
|
+
[OAComponentType.SCHEMA]: "schema",
|
|
1881
|
+
[OAComponentType.RESPONSE]: "response-or-reference",
|
|
1882
|
+
[OAComponentType.PARAMETER]: "parameter-or-reference",
|
|
1883
|
+
[OAComponentType.EXAMPLE]: "example-or-reference",
|
|
1884
|
+
[OAComponentType.REQUEST_BODY]: "request-body-or-reference",
|
|
1885
|
+
[OAComponentType.HEADER]: "header-or-reference",
|
|
1886
|
+
[OAComponentType.SECURITY_SCHEME]: "security-scheme-or-reference",
|
|
1887
|
+
[OAComponentType.LINK]: "link-or-reference",
|
|
1888
|
+
[OAComponentType.CALLBACK]: "callbacks-or-reference",
|
|
1889
|
+
[OAComponentType.PATH_ITEM]: "path-item"
|
|
1890
|
+
};
|
|
1891
|
+
var OADocumentBuilder = class extends import_js_service.Service {
|
|
1892
|
+
static {
|
|
1893
|
+
__name(this, "OADocumentBuilder");
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Document.
|
|
1897
|
+
*
|
|
1898
|
+
* @private
|
|
1899
|
+
* @type {object}
|
|
1900
|
+
*/
|
|
1901
|
+
_document = {
|
|
1902
|
+
openapi: OPENAPI_VERSION,
|
|
1903
|
+
info: {
|
|
1904
|
+
title: "API Documentation",
|
|
1905
|
+
version: "0.0.1"
|
|
1906
|
+
},
|
|
1907
|
+
paths: {}
|
|
1908
|
+
};
|
|
1909
|
+
/**
|
|
1910
|
+
* Constructor.
|
|
1911
|
+
*
|
|
1912
|
+
* @param {import('@e22m4u/js-service').ServiceContainer|import('./oa-document-builder.js').OADocumentInput} containerOrDocument
|
|
1913
|
+
* @param {import('./oa-document-builder.js').OADocumentInput} document
|
|
1914
|
+
*/
|
|
1915
|
+
constructor(containerOrDocument, document) {
|
|
1916
|
+
if ((0, import_js_service.isServiceContainer)(containerOrDocument)) {
|
|
1917
|
+
super(containerOrDocument);
|
|
1918
|
+
} else {
|
|
1919
|
+
super();
|
|
1920
|
+
if (containerOrDocument !== void 0) {
|
|
1921
|
+
if (!containerOrDocument || typeof containerOrDocument !== "object" || Array.isArray(containerOrDocument)) {
|
|
1922
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
1923
|
+
'Parameter "containerOrDocument" must be an Object, but %v was given.',
|
|
1924
|
+
containerOrDocument
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
document = document === void 0 ? containerOrDocument : document;
|
|
1929
|
+
}
|
|
1930
|
+
if (document !== void 0) {
|
|
1931
|
+
if (!document || typeof document !== "object" || Array.isArray(document)) {
|
|
1932
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
1933
|
+
'Parameter "document" must be an Object, but %v was given.',
|
|
1934
|
+
document
|
|
1935
|
+
);
|
|
1936
|
+
}
|
|
1937
|
+
document = structuredClone(document);
|
|
1938
|
+
this._document = { ...this._document, ...document };
|
|
1939
|
+
}
|
|
1940
|
+
validateOADocumentObject(this._document);
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Get document object reference.
|
|
1944
|
+
*
|
|
1945
|
+
* @returns {import('./oa-specification.js').OADocumentObject}
|
|
1946
|
+
*/
|
|
1947
|
+
getDocumentObjectRef() {
|
|
1948
|
+
return this._document;
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Define component.
|
|
1952
|
+
*
|
|
1953
|
+
* @param {string} type
|
|
1954
|
+
* @param {object} name
|
|
1955
|
+
* @param {object} component
|
|
1956
|
+
* @returns {this}
|
|
1957
|
+
*/
|
|
1958
|
+
defineComponent(type, name, component) {
|
|
1959
|
+
if (!OA_COMPONENT_TYPES.includes(type)) {
|
|
1960
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
518
1961
|
"Components type %v is not supported.",
|
|
519
1962
|
type
|
|
520
1963
|
);
|
|
521
1964
|
}
|
|
522
|
-
if (!
|
|
523
|
-
throw new
|
|
524
|
-
"Component
|
|
525
|
-
|
|
1965
|
+
if (!name || typeof name !== "string") {
|
|
1966
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
1967
|
+
"Component name must be a non-empty String, but %v was given.",
|
|
1968
|
+
name
|
|
526
1969
|
);
|
|
527
1970
|
}
|
|
528
|
-
if (!
|
|
529
|
-
throw new
|
|
530
|
-
|
|
531
|
-
|
|
1971
|
+
if (!OA_COMPONENT_NAME_REGEX.test(name)) {
|
|
1972
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
1973
|
+
"Component name %v contains invalid characters.",
|
|
1974
|
+
name
|
|
532
1975
|
);
|
|
533
1976
|
}
|
|
534
|
-
const component = definition[type];
|
|
535
1977
|
if (!component || typeof component !== "object" || Array.isArray(component)) {
|
|
536
|
-
throw new
|
|
537
|
-
"
|
|
538
|
-
|
|
1978
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
1979
|
+
"Component %v must be an Object, but %v was given.",
|
|
1980
|
+
name,
|
|
539
1981
|
component
|
|
540
1982
|
);
|
|
541
1983
|
}
|
|
542
|
-
const
|
|
543
|
-
if (!
|
|
544
|
-
throw new
|
|
1984
|
+
const componentsKey = OA_COMPONENT_TYPE_TO_COMPONENTS_KEY_MAP[type];
|
|
1985
|
+
if (!componentsKey) {
|
|
1986
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
545
1987
|
"Component type %v does not have a reference to the components key.",
|
|
546
|
-
|
|
1988
|
+
componentsKey
|
|
547
1989
|
);
|
|
548
1990
|
}
|
|
1991
|
+
const definitionName = OA_COMPONENT_TYPE_TO_DEFINITION_NAME_MAP[type];
|
|
1992
|
+
if (!definitionName) {
|
|
1993
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
1994
|
+
"Component type %v does not have a reference to the definition name.",
|
|
1995
|
+
definitionName
|
|
1996
|
+
);
|
|
1997
|
+
}
|
|
1998
|
+
validateOADocumentObject(component, {
|
|
1999
|
+
schemaUri: `#/$defs/${definitionName}`,
|
|
2000
|
+
dataSourceUri: `#/components/${componentsKey}/${escapeJsonPointer(name)}`
|
|
2001
|
+
});
|
|
549
2002
|
this._document.components = this._document.components || {};
|
|
550
|
-
this._document.components[
|
|
551
|
-
this._document.components[
|
|
2003
|
+
this._document.components[componentsKey] = this._document.components[componentsKey] || {};
|
|
2004
|
+
this._document.components[componentsKey][name] = structuredClone(component);
|
|
552
2005
|
return this;
|
|
553
2006
|
}
|
|
554
2007
|
/**
|
|
@@ -559,21 +2012,33 @@ var OADocumentBuilder = class extends import_js_service.Service {
|
|
|
559
2012
|
* @returns {boolean}
|
|
560
2013
|
*/
|
|
561
2014
|
hasComponent(type, name) {
|
|
2015
|
+
if (!OA_COMPONENT_TYPES.includes(type)) {
|
|
2016
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2017
|
+
"Components type %v is not supported.",
|
|
2018
|
+
type
|
|
2019
|
+
);
|
|
2020
|
+
}
|
|
562
2021
|
if (!name || typeof name !== "string") {
|
|
563
|
-
throw new
|
|
564
|
-
|
|
2022
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2023
|
+
"Component name must be a non-empty String, but %v was given.",
|
|
565
2024
|
name
|
|
566
2025
|
);
|
|
567
2026
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
2027
|
+
if (!OA_COMPONENT_NAME_REGEX.test(name)) {
|
|
2028
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2029
|
+
"Component name %v contains invalid characters.",
|
|
2030
|
+
name
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2033
|
+
const componentsKey = OA_COMPONENT_TYPE_TO_COMPONENTS_KEY_MAP[type];
|
|
2034
|
+
if (!componentsKey) {
|
|
2035
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
571
2036
|
"Component type %v does not have a reference to the components key.",
|
|
572
|
-
|
|
2037
|
+
componentsKey
|
|
573
2038
|
);
|
|
574
2039
|
}
|
|
575
2040
|
return Boolean(
|
|
576
|
-
this._document.components && this._document.components[
|
|
2041
|
+
this._document.components && this._document.components[componentsKey] && this._document.components[componentsKey][name]
|
|
577
2042
|
);
|
|
578
2043
|
}
|
|
579
2044
|
/**
|
|
@@ -584,24 +2049,36 @@ var OADocumentBuilder = class extends import_js_service.Service {
|
|
|
584
2049
|
* @returns {object}
|
|
585
2050
|
*/
|
|
586
2051
|
getComponent(type, name) {
|
|
2052
|
+
if (!OA_COMPONENT_TYPES.includes(type)) {
|
|
2053
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2054
|
+
"Components type %v is not supported.",
|
|
2055
|
+
type
|
|
2056
|
+
);
|
|
2057
|
+
}
|
|
587
2058
|
if (!name || typeof name !== "string") {
|
|
588
|
-
throw new
|
|
589
|
-
|
|
2059
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2060
|
+
"Component name must be a non-empty String, but %v was given.",
|
|
2061
|
+
name
|
|
2062
|
+
);
|
|
2063
|
+
}
|
|
2064
|
+
if (!OA_COMPONENT_NAME_REGEX.test(name)) {
|
|
2065
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2066
|
+
"Component name %v contains invalid characters.",
|
|
590
2067
|
name
|
|
591
2068
|
);
|
|
592
2069
|
}
|
|
593
|
-
const
|
|
594
|
-
if (!
|
|
595
|
-
throw new
|
|
2070
|
+
const componentsKey = OA_COMPONENT_TYPE_TO_COMPONENTS_KEY_MAP[type];
|
|
2071
|
+
if (!componentsKey) {
|
|
2072
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
596
2073
|
"Component type %v does not have a reference to the components key.",
|
|
597
2074
|
type
|
|
598
2075
|
);
|
|
599
2076
|
}
|
|
600
|
-
const component = this._document && this._document.components && this._document.components[
|
|
2077
|
+
const component = this._document && this._document.components && this._document.components[componentsKey] && this._document.components[componentsKey][name];
|
|
601
2078
|
if (!component) {
|
|
602
|
-
throw new
|
|
2079
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
603
2080
|
'Component "#/components/%s/%s" does not exist.',
|
|
604
|
-
|
|
2081
|
+
componentsKey,
|
|
605
2082
|
name
|
|
606
2083
|
);
|
|
607
2084
|
}
|
|
@@ -610,151 +2087,168 @@ var OADocumentBuilder = class extends import_js_service.Service {
|
|
|
610
2087
|
/**
|
|
611
2088
|
* Define schema component.
|
|
612
2089
|
*
|
|
613
|
-
* @param {
|
|
2090
|
+
* @param {string} name
|
|
2091
|
+
* @param {object} component
|
|
614
2092
|
* @returns {this}
|
|
615
2093
|
*/
|
|
616
|
-
defineSchemaComponent(
|
|
617
|
-
return this.defineComponent(OAComponentType.SCHEMA,
|
|
2094
|
+
defineSchemaComponent(name, component) {
|
|
2095
|
+
return this.defineComponent(OAComponentType.SCHEMA, name, component);
|
|
618
2096
|
}
|
|
619
2097
|
/**
|
|
620
2098
|
* Define response component.
|
|
621
2099
|
*
|
|
622
|
-
* @param {
|
|
2100
|
+
* @param {string} name
|
|
2101
|
+
* @param {object} component
|
|
623
2102
|
* @returns {this}
|
|
624
2103
|
*/
|
|
625
|
-
defineResponseComponent(
|
|
626
|
-
return this.defineComponent(OAComponentType.RESPONSE,
|
|
2104
|
+
defineResponseComponent(name, component) {
|
|
2105
|
+
return this.defineComponent(OAComponentType.RESPONSE, name, component);
|
|
627
2106
|
}
|
|
628
2107
|
/**
|
|
629
2108
|
* Define parameter component.
|
|
630
2109
|
*
|
|
631
|
-
* @param {
|
|
2110
|
+
* @param {string} name
|
|
2111
|
+
* @param {object} component
|
|
632
2112
|
* @returns {this}
|
|
633
2113
|
*/
|
|
634
|
-
defineParameterComponent(
|
|
635
|
-
return this.defineComponent(OAComponentType.PARAMETER,
|
|
2114
|
+
defineParameterComponent(name, component) {
|
|
2115
|
+
return this.defineComponent(OAComponentType.PARAMETER, name, component);
|
|
636
2116
|
}
|
|
637
2117
|
/**
|
|
638
2118
|
* Define example component.
|
|
639
2119
|
*
|
|
640
|
-
* @param {
|
|
2120
|
+
* @param {string} name
|
|
2121
|
+
* @param {object} component
|
|
641
2122
|
* @returns {this}
|
|
642
2123
|
*/
|
|
643
|
-
defineExampleComponent(
|
|
644
|
-
return this.defineComponent(OAComponentType.EXAMPLE,
|
|
2124
|
+
defineExampleComponent(name, component) {
|
|
2125
|
+
return this.defineComponent(OAComponentType.EXAMPLE, name, component);
|
|
645
2126
|
}
|
|
646
2127
|
/**
|
|
647
2128
|
* Define request body component.
|
|
648
2129
|
*
|
|
649
|
-
* @param {
|
|
2130
|
+
* @param {string} name
|
|
2131
|
+
* @param {object} component
|
|
650
2132
|
* @returns {this}
|
|
651
2133
|
*/
|
|
652
|
-
defineRequestBodyComponent(
|
|
653
|
-
return this.defineComponent(OAComponentType.REQUEST_BODY,
|
|
2134
|
+
defineRequestBodyComponent(name, component) {
|
|
2135
|
+
return this.defineComponent(OAComponentType.REQUEST_BODY, name, component);
|
|
654
2136
|
}
|
|
655
2137
|
/**
|
|
656
2138
|
* Define header component.
|
|
657
2139
|
*
|
|
658
|
-
* @param {
|
|
2140
|
+
* @param {string} name
|
|
2141
|
+
* @param {object} component
|
|
659
2142
|
* @returns {this}
|
|
660
2143
|
*/
|
|
661
|
-
defineHeaderComponent(
|
|
662
|
-
return this.defineComponent(OAComponentType.HEADER,
|
|
2144
|
+
defineHeaderComponent(name, component) {
|
|
2145
|
+
return this.defineComponent(OAComponentType.HEADER, name, component);
|
|
663
2146
|
}
|
|
664
2147
|
/**
|
|
665
2148
|
* Define security scheme component.
|
|
666
2149
|
*
|
|
667
|
-
* @param {
|
|
2150
|
+
* @param {string} name
|
|
2151
|
+
* @param {object} component
|
|
668
2152
|
* @returns {this}
|
|
669
2153
|
*/
|
|
670
|
-
defineSecuritySchemeComponent(
|
|
2154
|
+
defineSecuritySchemeComponent(name, component) {
|
|
671
2155
|
return this.defineComponent(
|
|
672
2156
|
OAComponentType.SECURITY_SCHEME,
|
|
673
|
-
|
|
2157
|
+
name,
|
|
2158
|
+
component
|
|
674
2159
|
);
|
|
675
2160
|
}
|
|
676
2161
|
/**
|
|
677
2162
|
* Define link component.
|
|
678
2163
|
*
|
|
679
|
-
* @param {
|
|
2164
|
+
* @param {string} name
|
|
2165
|
+
* @param {object} component
|
|
680
2166
|
* @returns {this}
|
|
681
2167
|
*/
|
|
682
|
-
defineLinkComponent(
|
|
683
|
-
return this.defineComponent(OAComponentType.LINK,
|
|
2168
|
+
defineLinkComponent(name, component) {
|
|
2169
|
+
return this.defineComponent(OAComponentType.LINK, name, component);
|
|
684
2170
|
}
|
|
685
2171
|
/**
|
|
686
2172
|
* Define callback component.
|
|
687
2173
|
*
|
|
688
|
-
* @param {
|
|
2174
|
+
* @param {string} name
|
|
2175
|
+
* @param {object} component
|
|
689
2176
|
* @returns {this}
|
|
690
2177
|
*/
|
|
691
|
-
defineCallbackComponent(
|
|
692
|
-
return this.defineComponent(OAComponentType.CALLBACK,
|
|
2178
|
+
defineCallbackComponent(name, component) {
|
|
2179
|
+
return this.defineComponent(OAComponentType.CALLBACK, name, component);
|
|
693
2180
|
}
|
|
694
2181
|
/**
|
|
695
2182
|
* Define path item component.
|
|
696
2183
|
*
|
|
697
|
-
* @param {
|
|
2184
|
+
* @param {string} name
|
|
2185
|
+
* @param {object} component
|
|
698
2186
|
* @returns {this}
|
|
699
2187
|
*/
|
|
700
|
-
definePathItemComponent(
|
|
701
|
-
return this.defineComponent(OAComponentType.PATH_ITEM,
|
|
2188
|
+
definePathItemComponent(name, component) {
|
|
2189
|
+
return this.defineComponent(OAComponentType.PATH_ITEM, name, component);
|
|
702
2190
|
}
|
|
703
2191
|
/**
|
|
704
2192
|
* Define operation.
|
|
705
2193
|
*
|
|
706
|
-
* @param {
|
|
2194
|
+
* @param {import('./oa-document-builder.js').OAOperationDefinition} operationDef
|
|
2195
|
+
* @returns {this}
|
|
707
2196
|
*/
|
|
708
2197
|
defineOperation(operationDef) {
|
|
709
2198
|
if (!operationDef || typeof operationDef !== "object" || Array.isArray(operationDef)) {
|
|
710
|
-
throw new
|
|
2199
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
711
2200
|
"Operation Definition must be an Object, but %v was given.",
|
|
712
2201
|
operationDef
|
|
713
2202
|
);
|
|
714
2203
|
}
|
|
715
|
-
if (
|
|
716
|
-
throw new
|
|
717
|
-
'
|
|
2204
|
+
if (typeof operationDef.path !== "string") {
|
|
2205
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2206
|
+
'Keyword "path" must be a String, but %v was given.',
|
|
718
2207
|
operationDef.path
|
|
719
2208
|
);
|
|
720
2209
|
}
|
|
721
|
-
if (!operationDef.
|
|
722
|
-
throw new
|
|
723
|
-
'
|
|
724
|
-
operationDef.
|
|
2210
|
+
if (!operationDef.path.startsWith("/")) {
|
|
2211
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2212
|
+
'Keyword "path" must start with "/", but %v was given.',
|
|
2213
|
+
operationDef.path
|
|
725
2214
|
);
|
|
726
2215
|
}
|
|
727
2216
|
if (!Object.values(OAOperationMethod).includes(operationDef.method)) {
|
|
728
|
-
throw new
|
|
729
|
-
'
|
|
730
|
-
|
|
2217
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2218
|
+
'Keyword "method" must be one of the allowed values, but %v was given.',
|
|
2219
|
+
operationDef.method
|
|
731
2220
|
);
|
|
732
2221
|
}
|
|
733
|
-
if (
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
2222
|
+
if (operationDef.operation !== void 0) {
|
|
2223
|
+
if (!operationDef.operation || typeof operationDef.operation !== "object" || Array.isArray(operationDef.operation)) {
|
|
2224
|
+
throw new import_js_format6.InvalidArgumentError(
|
|
2225
|
+
'Keyword "operation" must be an Object, but %v was given.',
|
|
2226
|
+
operationDef.operation
|
|
2227
|
+
);
|
|
2228
|
+
}
|
|
2229
|
+
validateOADocumentObject(operationDef.operation, {
|
|
2230
|
+
schemaUri: "#/$defs/operation",
|
|
2231
|
+
dataSourceUri: `/paths/${escapeJsonPointer(operationDef.path)}/${escapeJsonPointer(operationDef.method)}`
|
|
2232
|
+
});
|
|
738
2233
|
}
|
|
739
|
-
const
|
|
2234
|
+
const operation = operationDef.operation ? structuredClone(operationDef.operation) : {};
|
|
740
2235
|
if (!this._document.paths) {
|
|
741
2236
|
this._document.paths = {};
|
|
742
2237
|
}
|
|
743
|
-
if (!this._document.paths[
|
|
744
|
-
this._document.paths[
|
|
2238
|
+
if (!this._document.paths[operationDef.path]) {
|
|
2239
|
+
this._document.paths[operationDef.path] = {};
|
|
745
2240
|
}
|
|
746
|
-
this._document.paths[
|
|
747
|
-
|
|
748
|
-
);
|
|
2241
|
+
this._document.paths[operationDef.path][operationDef.method] = operation;
|
|
2242
|
+
return this;
|
|
749
2243
|
}
|
|
750
2244
|
/**
|
|
751
|
-
* Create
|
|
2245
|
+
* Create operation group.
|
|
752
2246
|
*
|
|
753
|
-
* @param {
|
|
754
|
-
* @returns {
|
|
2247
|
+
* @param {import('./oa-operation-group.js').OAOperationGroupOptions} [options]
|
|
2248
|
+
* @returns {OAOperationGroup}
|
|
755
2249
|
*/
|
|
756
|
-
|
|
757
|
-
return new
|
|
2250
|
+
createOperationGroup(options) {
|
|
2251
|
+
return new OAOperationGroup(this, options);
|
|
758
2252
|
}
|
|
759
2253
|
/**
|
|
760
2254
|
* Build.
|
|
@@ -775,10 +2269,10 @@ var OADocumentBuilder = class extends import_js_service.Service {
|
|
|
775
2269
|
}
|
|
776
2270
|
};
|
|
777
2271
|
|
|
778
|
-
// src/oa-
|
|
779
|
-
var
|
|
2272
|
+
// src/oa-operation-group.js
|
|
2273
|
+
var OAOperationGroup = class _OAOperationGroup {
|
|
780
2274
|
static {
|
|
781
|
-
__name(this, "
|
|
2275
|
+
__name(this, "OAOperationGroup");
|
|
782
2276
|
}
|
|
783
2277
|
/**
|
|
784
2278
|
* Builder.
|
|
@@ -804,36 +2298,42 @@ var OADocumentScope = class _OADocumentScope {
|
|
|
804
2298
|
*/
|
|
805
2299
|
constructor(builder, options = {}) {
|
|
806
2300
|
if (!(builder instanceof OADocumentBuilder)) {
|
|
807
|
-
throw new
|
|
2301
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
808
2302
|
'Parameter "builder" must be an instance of OADocumentBuilder, but %v was given.',
|
|
809
2303
|
builder
|
|
810
2304
|
);
|
|
811
2305
|
}
|
|
812
2306
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
813
|
-
throw new
|
|
2307
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
814
2308
|
'Parameter "options" must be an Object, but %v was given.',
|
|
815
2309
|
options
|
|
816
2310
|
);
|
|
817
2311
|
}
|
|
818
2312
|
if (options.pathPrefix !== void 0) {
|
|
819
|
-
if (
|
|
820
|
-
throw new
|
|
821
|
-
'
|
|
2313
|
+
if (typeof options.pathPrefix !== "string") {
|
|
2314
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2315
|
+
'Option "pathPrefix" must be a String, but %v was given.',
|
|
2316
|
+
options.pathPrefix
|
|
2317
|
+
);
|
|
2318
|
+
}
|
|
2319
|
+
if (!options.pathPrefix.startsWith("/")) {
|
|
2320
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2321
|
+
'Option "pathPrefix" must start with "/", but %v was given.',
|
|
822
2322
|
options.pathPrefix
|
|
823
2323
|
);
|
|
824
2324
|
}
|
|
825
2325
|
}
|
|
826
2326
|
if (options.tags !== void 0) {
|
|
827
2327
|
if (!Array.isArray(options.tags)) {
|
|
828
|
-
throw new
|
|
829
|
-
'
|
|
2328
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2329
|
+
'Option "tags" must be an Array, but %v was given.',
|
|
830
2330
|
options.tags
|
|
831
2331
|
);
|
|
832
2332
|
}
|
|
833
2333
|
options.tags.forEach((tag, index) => {
|
|
834
2334
|
if (!tag || typeof tag !== "string") {
|
|
835
|
-
throw new
|
|
836
|
-
'Element "tags
|
|
2335
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2336
|
+
'Element %v in the option "tags" must be a non-empty String, but %v was given.',
|
|
837
2337
|
index,
|
|
838
2338
|
tag
|
|
839
2339
|
);
|
|
@@ -841,8 +2341,8 @@ var OADocumentScope = class _OADocumentScope {
|
|
|
841
2341
|
});
|
|
842
2342
|
}
|
|
843
2343
|
this._builder = builder;
|
|
844
|
-
this._pathPrefix =
|
|
845
|
-
this._tags = options.tags || [];
|
|
2344
|
+
this._pathPrefix = options.pathPrefix || "/";
|
|
2345
|
+
this._tags = [...new Set(options.tags || [])];
|
|
846
2346
|
}
|
|
847
2347
|
/**
|
|
848
2348
|
* Get builder.
|
|
@@ -871,43 +2371,52 @@ var OADocumentScope = class _OADocumentScope {
|
|
|
871
2371
|
/**
|
|
872
2372
|
* Define operation.
|
|
873
2373
|
*
|
|
874
|
-
* @param {
|
|
2374
|
+
* @param {import('./oa-document-builder.js').OAOperationDefinition} operationDef
|
|
875
2375
|
* @returns {this}
|
|
876
2376
|
*/
|
|
877
2377
|
defineOperation(operationDef) {
|
|
878
2378
|
if (!operationDef || typeof operationDef !== "object" || Array.isArray(operationDef)) {
|
|
879
|
-
throw new
|
|
2379
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
880
2380
|
"Operation Definition must be an Object, but %v was given.",
|
|
881
2381
|
operationDef
|
|
882
2382
|
);
|
|
883
2383
|
}
|
|
884
|
-
if (
|
|
885
|
-
throw new
|
|
886
|
-
'
|
|
2384
|
+
if (typeof operationDef.path !== "string") {
|
|
2385
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2386
|
+
'Keyword "path" must be a String, but %v was given.',
|
|
887
2387
|
operationDef.path
|
|
888
2388
|
);
|
|
889
2389
|
}
|
|
890
|
-
if (!operationDef.
|
|
891
|
-
throw new
|
|
892
|
-
'
|
|
893
|
-
operationDef.
|
|
2390
|
+
if (!operationDef.path.startsWith("/")) {
|
|
2391
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2392
|
+
'Keyword "path" must start with "/", but %v was given.',
|
|
2393
|
+
operationDef.path
|
|
894
2394
|
);
|
|
895
2395
|
}
|
|
896
2396
|
if (!Object.values(OAOperationMethod).includes(operationDef.method)) {
|
|
897
|
-
throw new
|
|
898
|
-
'
|
|
899
|
-
|
|
2397
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2398
|
+
'Keyword "method" must be one of the allowed values, but %v was given.',
|
|
2399
|
+
operationDef.method
|
|
900
2400
|
);
|
|
901
2401
|
}
|
|
902
|
-
if (
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
2402
|
+
if (operationDef.operation !== void 0) {
|
|
2403
|
+
if (!operationDef.operation || typeof operationDef.operation !== "object" || Array.isArray(operationDef.operation)) {
|
|
2404
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2405
|
+
'Keyword "operation" must be an Object, but %v was given.',
|
|
2406
|
+
operationDef.operation
|
|
2407
|
+
);
|
|
2408
|
+
}
|
|
907
2409
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
2410
|
+
let fullPath = this._pathPrefix;
|
|
2411
|
+
if (operationDef.path !== "/") {
|
|
2412
|
+
if (fullPath === "/") {
|
|
2413
|
+
fullPath = operationDef.path;
|
|
2414
|
+
} else {
|
|
2415
|
+
fullPath += operationDef.path;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
const operation = { ...operationDef.operation };
|
|
2419
|
+
if (this._tags.length > 0) {
|
|
911
2420
|
operation.tags = [...this._tags, ...operation.tags || []];
|
|
912
2421
|
operation.tags = [...new Set(operation.tags)];
|
|
913
2422
|
}
|
|
@@ -919,251 +2428,79 @@ var OADocumentScope = class _OADocumentScope {
|
|
|
919
2428
|
return this;
|
|
920
2429
|
}
|
|
921
2430
|
/**
|
|
922
|
-
* Create
|
|
2431
|
+
* Create operation group.
|
|
923
2432
|
*
|
|
924
2433
|
* @param {object} [options]
|
|
925
|
-
* @returns {
|
|
2434
|
+
* @returns {OAOperationGroup}
|
|
926
2435
|
*/
|
|
927
|
-
|
|
2436
|
+
createOperationGroup(options = {}) {
|
|
928
2437
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
929
|
-
throw new
|
|
2438
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
930
2439
|
'Parameter "options" must be an Object, but %v was given.',
|
|
931
2440
|
options
|
|
932
2441
|
);
|
|
933
2442
|
}
|
|
934
2443
|
if (options.pathPrefix !== void 0) {
|
|
935
|
-
if (
|
|
936
|
-
throw new
|
|
937
|
-
'
|
|
2444
|
+
if (typeof options.pathPrefix !== "string") {
|
|
2445
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2446
|
+
'Option "pathPrefix" must be a String, but %v was given.',
|
|
2447
|
+
options.pathPrefix
|
|
2448
|
+
);
|
|
2449
|
+
}
|
|
2450
|
+
if (!options.pathPrefix.startsWith("/")) {
|
|
2451
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2452
|
+
'Option "pathPrefix" must start with "/", but %v was given.',
|
|
938
2453
|
options.pathPrefix
|
|
939
2454
|
);
|
|
940
2455
|
}
|
|
941
2456
|
}
|
|
942
2457
|
if (options.tags !== void 0) {
|
|
943
2458
|
if (!Array.isArray(options.tags)) {
|
|
944
|
-
throw new
|
|
945
|
-
'
|
|
2459
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2460
|
+
'Option "tags" must be an Array, but %v was given.',
|
|
946
2461
|
options.tags
|
|
947
2462
|
);
|
|
948
2463
|
}
|
|
949
2464
|
options.tags.forEach((tag, index) => {
|
|
950
2465
|
if (!tag || typeof tag !== "string") {
|
|
951
|
-
throw new
|
|
952
|
-
'Element "tags
|
|
2466
|
+
throw new import_js_format7.InvalidArgumentError(
|
|
2467
|
+
'Element %v in the option "tags" must be a non-empty String, but %v was given.',
|
|
953
2468
|
index,
|
|
954
2469
|
tag
|
|
955
2470
|
);
|
|
956
2471
|
}
|
|
957
2472
|
});
|
|
958
2473
|
}
|
|
959
|
-
|
|
960
|
-
|
|
2474
|
+
let fullPathPrefix = this._pathPrefix;
|
|
2475
|
+
if (options.pathPrefix && options.pathPrefix !== "/") {
|
|
2476
|
+
if (fullPathPrefix === "/") {
|
|
2477
|
+
fullPathPrefix = options.pathPrefix;
|
|
2478
|
+
} else {
|
|
2479
|
+
fullPathPrefix += options.pathPrefix;
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
return new _OAOperationGroup(this._builder, {
|
|
2483
|
+
pathPrefix: fullPathPrefix,
|
|
961
2484
|
tags: [...this._tags, ...options.tags || []]
|
|
962
2485
|
});
|
|
963
2486
|
}
|
|
964
2487
|
};
|
|
965
2488
|
|
|
966
|
-
// src/json-pointer/escape-json-pointer.js
|
|
967
|
-
var import_js_format6 = require("@e22m4u/js-format");
|
|
968
|
-
function escapeJsonPointer(jsonPointer) {
|
|
969
|
-
if (typeof jsonPointer !== "string") {
|
|
970
|
-
throw new import_js_format6.InvalidArgumentError(
|
|
971
|
-
'Parameter "jsonPointer" must be a String, but %v was given.',
|
|
972
|
-
jsonPointer
|
|
973
|
-
);
|
|
974
|
-
}
|
|
975
|
-
return jsonPointer.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
976
|
-
}
|
|
977
|
-
__name(escapeJsonPointer, "escapeJsonPointer");
|
|
978
|
-
|
|
979
|
-
// src/json-pointer/resolve-json-pointer.js
|
|
980
|
-
var import_js_format7 = require("@e22m4u/js-format");
|
|
981
|
-
var ARRAY_INDEX_PATTERN = /^(0|[1-9][0-9]*)$/;
|
|
982
|
-
function resolveJsonPointer(document, pointer) {
|
|
983
|
-
if (!document || typeof document !== "object") {
|
|
984
|
-
throw new import_js_format7.InvalidArgumentError(
|
|
985
|
-
'Parameter "document" must be an Object or an Array, but %v was given.',
|
|
986
|
-
document
|
|
987
|
-
);
|
|
988
|
-
}
|
|
989
|
-
if (typeof pointer !== "string") {
|
|
990
|
-
throw new import_js_format7.InvalidArgumentError(
|
|
991
|
-
"JSON pointer must be a String, but %v was given.",
|
|
992
|
-
pointer
|
|
993
|
-
);
|
|
994
|
-
}
|
|
995
|
-
if (pointer === "") {
|
|
996
|
-
return document;
|
|
997
|
-
}
|
|
998
|
-
if (!pointer.startsWith("/")) {
|
|
999
|
-
throw new import_js_format7.InvalidArgumentError(
|
|
1000
|
-
'JSON pointer must start with a forward slash "/", but %v was given.',
|
|
1001
|
-
pointer
|
|
1002
|
-
);
|
|
1003
|
-
}
|
|
1004
|
-
const pathParts = pointer.substring(1).split("/");
|
|
1005
|
-
let current = document;
|
|
1006
|
-
for (let i = 0, l = pathParts.length; i < l; i++) {
|
|
1007
|
-
const part = pathParts[i];
|
|
1008
|
-
const segment = unescapeJsonPointer(part);
|
|
1009
|
-
if (current && typeof current === "object" && !Array.isArray(current) && Object.hasOwn(current, segment) && current[segment] !== void 0) {
|
|
1010
|
-
current = current[segment];
|
|
1011
|
-
} else if (Array.isArray(current) && ARRAY_INDEX_PATTERN.test(segment) && current[segment] !== void 0) {
|
|
1012
|
-
current = current[segment];
|
|
1013
|
-
} else {
|
|
1014
|
-
const currentPointer = "/" + pathParts.slice(0, i + 1).join("/");
|
|
1015
|
-
throw new import_js_format7.InvalidArgumentError(
|
|
1016
|
-
"Unable to resolve %v in the given document.",
|
|
1017
|
-
currentPointer
|
|
1018
|
-
);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
return current;
|
|
1022
|
-
}
|
|
1023
|
-
__name(resolveJsonPointer, "resolveJsonPointer");
|
|
1024
|
-
|
|
1025
|
-
// src/json-pointer/unescape-json-pointer.js
|
|
1026
|
-
var import_js_format8 = require("@e22m4u/js-format");
|
|
1027
|
-
function unescapeJsonPointer(jsonPointer) {
|
|
1028
|
-
if (typeof jsonPointer !== "string") {
|
|
1029
|
-
throw new import_js_format8.InvalidArgumentError(
|
|
1030
|
-
'Parameter "jsonPointer" must be a String, but %v was given.',
|
|
1031
|
-
jsonPointer
|
|
1032
|
-
);
|
|
1033
|
-
}
|
|
1034
|
-
return jsonPointer.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1035
|
-
}
|
|
1036
|
-
__name(unescapeJsonPointer, "unescapeJsonPointer");
|
|
1037
|
-
|
|
1038
|
-
// src/data-validation/data-format-validators.js
|
|
1039
|
-
var RX_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
1040
|
-
var RX_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
1041
|
-
var RX_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|([+-]\d{2}:?\d{2}))$/i;
|
|
1042
|
-
var RX_IPV4 = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
1043
|
-
var RX_IPV6 = /^((([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])))$/;
|
|
1044
|
-
var RX_HOSTNAME = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/;
|
|
1045
|
-
var RX_EMAIL = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
1046
|
-
var RX_BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
1047
|
-
var validateInt32Format = /* @__PURE__ */ __name((v) => {
|
|
1048
|
-
if (typeof v !== "number") {
|
|
1049
|
-
return true;
|
|
1050
|
-
}
|
|
1051
|
-
return Number.isInteger(v) && v >= -2147483648 && v <= 2147483647;
|
|
1052
|
-
}, "validateInt32Format");
|
|
1053
|
-
var validateInt64Format = /* @__PURE__ */ __name((v) => {
|
|
1054
|
-
if (typeof v !== "number") {
|
|
1055
|
-
return true;
|
|
1056
|
-
}
|
|
1057
|
-
return Number.isSafeInteger(v);
|
|
1058
|
-
}, "validateInt64Format");
|
|
1059
|
-
var validateFloatFormat = /* @__PURE__ */ __name((v) => {
|
|
1060
|
-
if (typeof v !== "number") {
|
|
1061
|
-
return true;
|
|
1062
|
-
}
|
|
1063
|
-
return !Number.isNaN(v) && Number.isFinite(v) && // Math.fround приводит число к 32-битному float,
|
|
1064
|
-
// если результат бесконечен, значит число не влазит в float
|
|
1065
|
-
Number.isFinite(Math.fround(v));
|
|
1066
|
-
}, "validateFloatFormat");
|
|
1067
|
-
var validateDoubleFormat = /* @__PURE__ */ __name((v) => {
|
|
1068
|
-
if (typeof v !== "number") {
|
|
1069
|
-
return true;
|
|
1070
|
-
}
|
|
1071
|
-
return !Number.isNaN(v) && Number.isFinite(v);
|
|
1072
|
-
}, "validateDoubleFormat");
|
|
1073
|
-
var validateByteFormat = /* @__PURE__ */ __name((v) => {
|
|
1074
|
-
if (typeof v !== "string") {
|
|
1075
|
-
return true;
|
|
1076
|
-
}
|
|
1077
|
-
return v.length % 4 === 0 && RX_BASE64.test(v);
|
|
1078
|
-
}, "validateByteFormat");
|
|
1079
|
-
var validateDateFormat = /* @__PURE__ */ __name((v) => {
|
|
1080
|
-
if (typeof v !== "string") {
|
|
1081
|
-
return true;
|
|
1082
|
-
}
|
|
1083
|
-
if (!RX_DATE.test(v)) {
|
|
1084
|
-
return false;
|
|
1085
|
-
}
|
|
1086
|
-
const [y, m, d] = v.split("-").map(Number);
|
|
1087
|
-
const date = new Date(Date.UTC(y, m - 1, d));
|
|
1088
|
-
return date.getUTCFullYear() === y && date.getUTCMonth() === m - 1 && date.getUTCDate() === d;
|
|
1089
|
-
}, "validateDateFormat");
|
|
1090
|
-
var validateDateTimeFormat = /* @__PURE__ */ __name((v) => {
|
|
1091
|
-
if (typeof v !== "string") {
|
|
1092
|
-
return true;
|
|
1093
|
-
}
|
|
1094
|
-
return RX_DATE_TIME.test(v) && !isNaN(Date.parse(v));
|
|
1095
|
-
}, "validateDateTimeFormat");
|
|
1096
|
-
var validateEmailFormat = /* @__PURE__ */ __name((v) => {
|
|
1097
|
-
if (typeof v !== "string") {
|
|
1098
|
-
return true;
|
|
1099
|
-
}
|
|
1100
|
-
return RX_EMAIL.test(v);
|
|
1101
|
-
}, "validateEmailFormat");
|
|
1102
|
-
var validateUuidFormat = /* @__PURE__ */ __name((v) => {
|
|
1103
|
-
if (typeof v !== "string") {
|
|
1104
|
-
return true;
|
|
1105
|
-
}
|
|
1106
|
-
return RX_UUID.test(v);
|
|
1107
|
-
}, "validateUuidFormat");
|
|
1108
|
-
var validateIpv4Format = /* @__PURE__ */ __name((v) => {
|
|
1109
|
-
if (typeof v !== "string") {
|
|
1110
|
-
return true;
|
|
1111
|
-
}
|
|
1112
|
-
return RX_IPV4.test(v);
|
|
1113
|
-
}, "validateIpv4Format");
|
|
1114
|
-
var validateIpv6Format = /* @__PURE__ */ __name((v) => {
|
|
1115
|
-
if (typeof v !== "string") {
|
|
1116
|
-
return true;
|
|
1117
|
-
}
|
|
1118
|
-
return RX_IPV6.test(v);
|
|
1119
|
-
}, "validateIpv6Format");
|
|
1120
|
-
var validateHostnameFormat = /* @__PURE__ */ __name((v) => {
|
|
1121
|
-
if (typeof v !== "string") {
|
|
1122
|
-
return true;
|
|
1123
|
-
}
|
|
1124
|
-
return v.length <= 255 && RX_HOSTNAME.test(v);
|
|
1125
|
-
}, "validateHostnameFormat");
|
|
1126
|
-
var validateUriFormat = /* @__PURE__ */ __name((v) => {
|
|
1127
|
-
if (typeof v !== "string") {
|
|
1128
|
-
return true;
|
|
1129
|
-
}
|
|
1130
|
-
try {
|
|
1131
|
-
new URL(v);
|
|
1132
|
-
return true;
|
|
1133
|
-
} catch {
|
|
1134
|
-
return false;
|
|
1135
|
-
}
|
|
1136
|
-
}, "validateUriFormat");
|
|
1137
|
-
|
|
1138
|
-
// src/data-validation/data-format-validator-map.js
|
|
1139
|
-
var OA_BUILT_IN_DATA_FORMAT_VALIDATOR_MAP = {
|
|
1140
|
-
[OADataFormat.INT32]: validateInt32Format,
|
|
1141
|
-
[OADataFormat.INT64]: validateInt64Format,
|
|
1142
|
-
[OADataFormat.FLOAT]: validateFloatFormat,
|
|
1143
|
-
[OADataFormat.DOUBLE]: validateDoubleFormat,
|
|
1144
|
-
[OADataFormat.DATE]: validateDateFormat,
|
|
1145
|
-
[OADataFormat.DATE_TIME]: validateDateTimeFormat,
|
|
1146
|
-
[OADataFormat.BYTE]: validateByteFormat,
|
|
1147
|
-
[OADataFormat.EMAIL]: validateEmailFormat,
|
|
1148
|
-
[OADataFormat.UUID]: validateUuidFormat,
|
|
1149
|
-
[OADataFormat.HOSTNAME]: validateHostnameFormat,
|
|
1150
|
-
[OADataFormat.IPV4]: validateIpv4Format,
|
|
1151
|
-
[OADataFormat.IPV6]: validateIpv6Format,
|
|
1152
|
-
[OADataFormat.URI]: validateUriFormat
|
|
1153
|
-
};
|
|
1154
|
-
|
|
1155
|
-
// src/data-validation/validate-data-with-openapi-schema.js
|
|
1156
|
-
var import_js_format11 = require("@e22m4u/js-format");
|
|
1157
|
-
|
|
1158
2489
|
// src/oa-reference-object/oa-ref.js
|
|
1159
|
-
var
|
|
2490
|
+
var import_js_format8 = require("@e22m4u/js-format");
|
|
1160
2491
|
function oaRef(name, segment) {
|
|
1161
2492
|
if (!name || typeof name !== "string") {
|
|
1162
|
-
throw new
|
|
2493
|
+
throw new import_js_format8.InvalidArgumentError(
|
|
1163
2494
|
'Parameter "name" must be a non-empty String, but %v was given.',
|
|
1164
2495
|
name
|
|
1165
2496
|
);
|
|
1166
2497
|
}
|
|
2498
|
+
if (!OA_COMPONENT_NAME_REGEX.test(name)) {
|
|
2499
|
+
throw new import_js_format8.InvalidArgumentError(
|
|
2500
|
+
"Component name %v contains invalid characters.",
|
|
2501
|
+
name
|
|
2502
|
+
);
|
|
2503
|
+
}
|
|
1167
2504
|
const escapedName = escapeJsonPointer(name);
|
|
1168
2505
|
return { $ref: `#/components/${segment}/${escapedName}` };
|
|
1169
2506
|
}
|
|
@@ -1181,7 +2518,7 @@ var oaPathItemRef = /* @__PURE__ */ __name((name) => oaRef(name, "pathItems"), "
|
|
|
1181
2518
|
// src/oa-reference-object/is-oa-reference-object.js
|
|
1182
2519
|
function isOAReferenceObject(value) {
|
|
1183
2520
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1184
|
-
if (value.$ref !== void 0
|
|
2521
|
+
if (value.$ref !== void 0) {
|
|
1185
2522
|
return true;
|
|
1186
2523
|
}
|
|
1187
2524
|
}
|
|
@@ -1190,23 +2527,23 @@ function isOAReferenceObject(value) {
|
|
|
1190
2527
|
__name(isOAReferenceObject, "isOAReferenceObject");
|
|
1191
2528
|
|
|
1192
2529
|
// src/oa-reference-object/resolve-oa-reference-object.js
|
|
1193
|
-
var
|
|
2530
|
+
var import_js_format9 = require("@e22m4u/js-format");
|
|
1194
2531
|
function resolveOAReferenceObject(referenceObj, options = {}) {
|
|
1195
2532
|
if (!referenceObj || typeof referenceObj !== "object" || Array.isArray(referenceObj)) {
|
|
1196
|
-
throw new
|
|
2533
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1197
2534
|
'Parameter "referenceObj" must be an Object, but %v was given.',
|
|
1198
2535
|
referenceObj
|
|
1199
2536
|
);
|
|
1200
2537
|
}
|
|
1201
2538
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
1202
|
-
throw new
|
|
2539
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1203
2540
|
'Parameter "options" must be an Object, but %v was given.',
|
|
1204
2541
|
options
|
|
1205
2542
|
);
|
|
1206
2543
|
}
|
|
1207
2544
|
if (options.rootDocument !== void 0) {
|
|
1208
2545
|
if (!options.rootDocument || typeof options.rootDocument !== "object") {
|
|
1209
|
-
throw new
|
|
2546
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1210
2547
|
'Option "rootDocument" must be an Object or an Array, but %v was given.',
|
|
1211
2548
|
options.rootDocument
|
|
1212
2549
|
);
|
|
@@ -1214,7 +2551,7 @@ function resolveOAReferenceObject(referenceObj, options = {}) {
|
|
|
1214
2551
|
}
|
|
1215
2552
|
if (referenceObj.$ref !== void 0) {
|
|
1216
2553
|
if (!referenceObj.$ref || typeof referenceObj.$ref !== "string") {
|
|
1217
|
-
throw new
|
|
2554
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1218
2555
|
'Schema keyword "$ref" must be a non-empty String, but %v was given.',
|
|
1219
2556
|
referenceObj.$ref
|
|
1220
2557
|
);
|
|
@@ -1222,7 +2559,7 @@ function resolveOAReferenceObject(referenceObj, options = {}) {
|
|
|
1222
2559
|
const refUri = referenceObj.$ref;
|
|
1223
2560
|
if (refUri.startsWith("#")) {
|
|
1224
2561
|
if (!options.rootDocument) {
|
|
1225
|
-
throw new
|
|
2562
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1226
2563
|
'Option "rootDocument" is required to resolve the same-document reference (URI starts with "#").'
|
|
1227
2564
|
);
|
|
1228
2565
|
}
|
|
@@ -1231,1439 +2568,48 @@ function resolveOAReferenceObject(referenceObj, options = {}) {
|
|
|
1231
2568
|
} else if (refUri.startsWith("#/")) {
|
|
1232
2569
|
return resolveJsonPointer(options.rootDocument, refUri.substring(1));
|
|
1233
2570
|
}
|
|
1234
|
-
throw new
|
|
2571
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1235
2572
|
"Anchor reference is not supported, but %v was given.",
|
|
1236
2573
|
refUri
|
|
1237
2574
|
);
|
|
1238
2575
|
}
|
|
1239
2576
|
if (refUri.startsWith("http://") || refUri.startsWith("https://")) {
|
|
1240
|
-
throw new
|
|
2577
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1241
2578
|
"External resource is not supported, but %v was given.",
|
|
1242
2579
|
refUri
|
|
1243
2580
|
);
|
|
1244
2581
|
}
|
|
1245
|
-
throw new
|
|
2582
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1246
2583
|
"Relative reference is not supported, but %v was given.",
|
|
1247
2584
|
refUri
|
|
1248
2585
|
);
|
|
1249
2586
|
}
|
|
1250
|
-
|
|
1251
|
-
throw new import_js_format10.InvalidArgumentError(
|
|
1252
|
-
'Schema keyword "$dynamicRef" is not supported.'
|
|
1253
|
-
);
|
|
1254
|
-
}
|
|
1255
|
-
throw new import_js_format10.InvalidArgumentError(
|
|
2587
|
+
throw new import_js_format9.InvalidArgumentError(
|
|
1256
2588
|
"Reference object does not have reference properties."
|
|
1257
2589
|
);
|
|
1258
2590
|
}
|
|
1259
2591
|
__name(resolveOAReferenceObject, "resolveOAReferenceObject");
|
|
1260
|
-
|
|
1261
|
-
// src/data-validation/validate-data-with-openapi-schema.js
|
|
1262
|
-
var JSON_INTEGER_REGEXP = /^-?\d+$/;
|
|
1263
|
-
var JSON_NUMBER_REGEXP = /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;
|
|
1264
|
-
var UNSUPPORTED_SCHEMA_KEYWORDS = [
|
|
1265
|
-
"nullable",
|
|
1266
|
-
// удалено в 3.1.0
|
|
1267
|
-
"contentEncoding",
|
|
1268
|
-
"contentMediaType",
|
|
1269
|
-
"contentSchema",
|
|
1270
|
-
"discriminator"
|
|
1271
|
-
];
|
|
1272
|
-
function validateDataWithOpenApiSchema(data, schema, options = {}) {
|
|
1273
|
-
if (schema === null || typeof schema !== "boolean" && typeof schema !== "object" || Array.isArray(schema)) {
|
|
1274
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1275
|
-
'Parameter "schema" must be a Boolean or an Object, but %v was given.',
|
|
1276
|
-
schema
|
|
1277
|
-
);
|
|
1278
|
-
}
|
|
1279
|
-
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
1280
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1281
|
-
'Parameter "options" must be an Object, but %v was given.',
|
|
1282
|
-
options
|
|
1283
|
-
);
|
|
1284
|
-
}
|
|
1285
|
-
if (options.rootDocument !== void 0) {
|
|
1286
|
-
if (!options.rootDocument || typeof options.rootDocument !== "object" || Array.isArray(options.rootDocument)) {
|
|
1287
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1288
|
-
'Option "rootDocument" must be an Object, but %v was given.',
|
|
1289
|
-
options.rootDocument
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
if (options.required !== void 0) {
|
|
1294
|
-
if (typeof options.required !== "boolean") {
|
|
1295
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1296
|
-
'Option "required" must be a Boolean, but %v was given.',
|
|
1297
|
-
options.required
|
|
1298
|
-
);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
if (options.coerceTypes !== void 0) {
|
|
1302
|
-
if (typeof options.coerceTypes !== "boolean") {
|
|
1303
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1304
|
-
'Option "coerceTypes" must be a Boolean, but %v was given.',
|
|
1305
|
-
options.coerceTypes
|
|
1306
|
-
);
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
if (options.applyDefaults !== void 0) {
|
|
1310
|
-
if (typeof options.applyDefaults !== "boolean") {
|
|
1311
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1312
|
-
'Option "applyDefaults" must be a Boolean, but %v was given.',
|
|
1313
|
-
options.applyDefaults
|
|
1314
|
-
);
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
if (options.stripUnknown !== void 0) {
|
|
1318
|
-
if (typeof options.stripUnknown !== "boolean") {
|
|
1319
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1320
|
-
'Option "stripUnknown" must be a Boolean, but %v was given.',
|
|
1321
|
-
options.stripUnknown
|
|
1322
|
-
);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
if (options.dataSourceUri !== void 0) {
|
|
1326
|
-
if (!options.dataSourceUri || typeof options.dataSourceUri !== "string") {
|
|
1327
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1328
|
-
'Option "dataSourceUri" must be a non-empty String, but %v was given.',
|
|
1329
|
-
options.dataSourceUri
|
|
1330
|
-
);
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
if (options.schemaSourceUri !== void 0) {
|
|
1334
|
-
if (!options.schemaSourceUri || typeof options.schemaSourceUri !== "string") {
|
|
1335
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1336
|
-
'Option "schemaSourceUri" must be a non-empty String, but %v was given.',
|
|
1337
|
-
options.schemaSourceUri
|
|
1338
|
-
);
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
if (options.silent !== void 0) {
|
|
1342
|
-
if (typeof options.silent !== "boolean") {
|
|
1343
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1344
|
-
'Option "silent" must be a Boolean, but %v was given.',
|
|
1345
|
-
options.silent
|
|
1346
|
-
);
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
if (options.accessMode !== void 0) {
|
|
1350
|
-
if (!ACCESS_MODE_LIST.includes(options.accessMode)) {
|
|
1351
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1352
|
-
"Access mode %v is not supported.",
|
|
1353
|
-
options.accessMode
|
|
1354
|
-
);
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
if (options.formatValidators !== void 0) {
|
|
1358
|
-
if (!options.formatValidators || typeof options.formatValidators !== "object" || Array.isArray(options.formatValidators)) {
|
|
1359
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1360
|
-
'Option "formatValidators" must be an Object, but %v was given.',
|
|
1361
|
-
options.formatValidators
|
|
1362
|
-
);
|
|
1363
|
-
}
|
|
1364
|
-
Object.keys(options.formatValidators).forEach((formatName) => {
|
|
1365
|
-
const formatValidator = options.formatValidators[formatName];
|
|
1366
|
-
if (formatValidator !== void 0 && typeof formatValidator !== "function") {
|
|
1367
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1368
|
-
"Format validator %v must be a Function, but %v was given.",
|
|
1369
|
-
formatName,
|
|
1370
|
-
formatValidator
|
|
1371
|
-
);
|
|
1372
|
-
}
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
if (options.parseJson !== void 0) {
|
|
1376
|
-
if (typeof options.parseJson !== "boolean") {
|
|
1377
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1378
|
-
'Option "parseJson" must be a Boolean, but %v was given.',
|
|
1379
|
-
options.parseJson
|
|
1380
|
-
);
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
if (options.required === true && data === void 0) {
|
|
1384
|
-
const result2 = {
|
|
1385
|
-
isValid: false,
|
|
1386
|
-
value: data,
|
|
1387
|
-
valueUri: options.dataSourceUri || "",
|
|
1388
|
-
schemaUri: options.schemaSourceUri || "",
|
|
1389
|
-
reason: (0, import_js_format11.format)(
|
|
1390
|
-
"Value at %v is required, but %v was given.",
|
|
1391
|
-
options.dataSourceUri || "",
|
|
1392
|
-
data
|
|
1393
|
-
)
|
|
1394
|
-
};
|
|
1395
|
-
if (!options.silent) {
|
|
1396
|
-
throw new OADataValidationError(result2.reason);
|
|
1397
|
-
} else {
|
|
1398
|
-
return result2;
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
const subResult = _validate(data, schema, {
|
|
1402
|
-
...options,
|
|
1403
|
-
dataSourceUri: options.dataSourceUri || "",
|
|
1404
|
-
schemaSourceUri: options.schemaSourceUri || ""
|
|
1405
|
-
});
|
|
1406
|
-
if (!subResult.isValid && !options.silent) {
|
|
1407
|
-
throw new OADataValidationError(subResult.reason);
|
|
1408
|
-
}
|
|
1409
|
-
const result = {
|
|
1410
|
-
isValid: subResult.isValid,
|
|
1411
|
-
reason: subResult.reason,
|
|
1412
|
-
value: subResult.value,
|
|
1413
|
-
valueUri: subResult.valueUri,
|
|
1414
|
-
schemaUri: subResult.schemaUri
|
|
1415
|
-
};
|
|
1416
|
-
if (result.isValid) {
|
|
1417
|
-
delete result.reason;
|
|
1418
|
-
}
|
|
1419
|
-
return result;
|
|
1420
|
-
}
|
|
1421
|
-
__name(validateDataWithOpenApiSchema, "validateDataWithOpenApiSchema");
|
|
1422
|
-
function _validate(data, schema, options) {
|
|
1423
|
-
if (schema === null || typeof schema !== "boolean" && typeof schema !== "object" || Array.isArray(schema)) {
|
|
1424
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1425
|
-
"Schema at %v must be a Boolean or an Object, but %v was given.",
|
|
1426
|
-
options.schemaSourceUri,
|
|
1427
|
-
schema
|
|
1428
|
-
);
|
|
1429
|
-
}
|
|
1430
|
-
if (typeof schema === "boolean") {
|
|
1431
|
-
if (schema === true) {
|
|
1432
|
-
return {
|
|
1433
|
-
isValid: true,
|
|
1434
|
-
value: data,
|
|
1435
|
-
valueUri: options.dataSourceUri,
|
|
1436
|
-
schemaUri: options.schemaSourceUri
|
|
1437
|
-
};
|
|
1438
|
-
} else if (data !== void 0) {
|
|
1439
|
-
return {
|
|
1440
|
-
isValid: false,
|
|
1441
|
-
value: data,
|
|
1442
|
-
valueUri: options.dataSourceUri,
|
|
1443
|
-
schemaUri: options.schemaSourceUri,
|
|
1444
|
-
reason: (0, import_js_format11.format)(
|
|
1445
|
-
"Value at %v is rejected by the boolean schema at %v.",
|
|
1446
|
-
options.dataSourceUri,
|
|
1447
|
-
options.schemaSourceUri
|
|
1448
|
-
)
|
|
1449
|
-
};
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
let evaluatedIndexes = /* @__PURE__ */ new Set();
|
|
1453
|
-
let evaluatedProperties = /* @__PURE__ */ new Set();
|
|
1454
|
-
if (schema.default !== void 0 && data === void 0 && options.applyDefaults === true) {
|
|
1455
|
-
data = schema.default;
|
|
1456
|
-
}
|
|
1457
|
-
if (options.parseJson === true && schema.type !== void 0 && typeof data === "string") {
|
|
1458
|
-
data = _parseJson(data, schema.type);
|
|
1459
|
-
}
|
|
1460
|
-
if (options.coerceTypes === true && schema.type !== void 0 && data !== void 0) {
|
|
1461
|
-
data = _coerceType(data, schema.type);
|
|
1462
|
-
}
|
|
1463
|
-
if (schema.$ref !== void 0 || schema.$dynamicRef !== void 0) {
|
|
1464
|
-
const resSchema = resolveOAReferenceObject(schema, {
|
|
1465
|
-
rootDocument: options.rootDocument
|
|
1466
|
-
});
|
|
1467
|
-
const result = _validate(data, resSchema, {
|
|
1468
|
-
...options,
|
|
1469
|
-
schemaSourceUri: schema.$ref || schema.$dynamicRef
|
|
1470
|
-
});
|
|
1471
|
-
if (!result.isValid) {
|
|
1472
|
-
return result;
|
|
1473
|
-
}
|
|
1474
|
-
data = result.value;
|
|
1475
|
-
if (result.evaluatedIndexes) {
|
|
1476
|
-
evaluatedIndexes = /* @__PURE__ */ new Set([
|
|
1477
|
-
...evaluatedIndexes,
|
|
1478
|
-
...result.evaluatedIndexes
|
|
1479
|
-
]);
|
|
1480
|
-
}
|
|
1481
|
-
if (result.evaluatedProperties) {
|
|
1482
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
1483
|
-
...evaluatedProperties,
|
|
1484
|
-
...result.evaluatedProperties
|
|
1485
|
-
]);
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
UNSUPPORTED_SCHEMA_KEYWORDS.forEach((keyword) => {
|
|
1489
|
-
if (schema[keyword] !== void 0) {
|
|
1490
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
1491
|
-
"Schema keyword %v is not supported.",
|
|
1492
|
-
keyword
|
|
1493
|
-
);
|
|
1494
|
-
}
|
|
1495
|
-
});
|
|
1496
|
-
if (options.accessMode === OAAccessMode.WRITE && schema.readOnly === true && data !== void 0) {
|
|
1497
|
-
return {
|
|
1498
|
-
isValid: false,
|
|
1499
|
-
value: data,
|
|
1500
|
-
valueUri: options.dataSourceUri,
|
|
1501
|
-
schemaUri: options.schemaSourceUri,
|
|
1502
|
-
reason: (0, import_js_format11.format)(
|
|
1503
|
-
"Value at %v is read-only and cannot be sent in a write context.",
|
|
1504
|
-
options.dataSourceUri
|
|
1505
|
-
)
|
|
1506
|
-
};
|
|
1507
|
-
}
|
|
1508
|
-
if (options.accessMode === OAAccessMode.READ && schema.writeOnly === true && data !== void 0) {
|
|
1509
|
-
return {
|
|
1510
|
-
isValid: false,
|
|
1511
|
-
value: data,
|
|
1512
|
-
valueUri: options.dataSourceUri,
|
|
1513
|
-
schemaUri: options.schemaSourceUri,
|
|
1514
|
-
reason: (0, import_js_format11.format)(
|
|
1515
|
-
"Value at %v is write-only and cannot be present in a read context.",
|
|
1516
|
-
options.dataSourceUri
|
|
1517
|
-
)
|
|
1518
|
-
};
|
|
1519
|
-
}
|
|
1520
|
-
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
1521
|
-
for (const index in schema.allOf) {
|
|
1522
|
-
const subSchema = schema.allOf[index];
|
|
1523
|
-
const result = _validate(data, subSchema, {
|
|
1524
|
-
...options,
|
|
1525
|
-
schemaSourceUri: options.schemaSourceUri + "/allOf/" + index
|
|
1526
|
-
});
|
|
1527
|
-
if (!result.isValid) {
|
|
1528
|
-
return result;
|
|
1529
|
-
}
|
|
1530
|
-
data = result.value;
|
|
1531
|
-
if (result.evaluatedIndexes) {
|
|
1532
|
-
evaluatedIndexes = /* @__PURE__ */ new Set([
|
|
1533
|
-
...evaluatedIndexes,
|
|
1534
|
-
...result.evaluatedIndexes
|
|
1535
|
-
]);
|
|
1536
|
-
}
|
|
1537
|
-
if (result.evaluatedProperties) {
|
|
1538
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
1539
|
-
...evaluatedProperties,
|
|
1540
|
-
...result.evaluatedProperties
|
|
1541
|
-
]);
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
1546
|
-
let matches = 0;
|
|
1547
|
-
let matchedResultValue = data;
|
|
1548
|
-
let matchedEvaluatedIndexes = void 0;
|
|
1549
|
-
let matchedEvaluatedProperties = void 0;
|
|
1550
|
-
for (const index in schema.oneOf) {
|
|
1551
|
-
const subSchema = schema.oneOf[index];
|
|
1552
|
-
const result = _validate(data, subSchema, {
|
|
1553
|
-
...options,
|
|
1554
|
-
schemaSourceUri: options.schemaSourceUri + "/oneOf/" + index
|
|
1555
|
-
});
|
|
1556
|
-
if (result.isValid) {
|
|
1557
|
-
matches++;
|
|
1558
|
-
matchedResultValue = result.value;
|
|
1559
|
-
matchedEvaluatedIndexes = result.evaluatedIndexes;
|
|
1560
|
-
matchedEvaluatedProperties = result.evaluatedProperties;
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
if (matches !== 1) {
|
|
1564
|
-
const schemaUri = options.schemaSourceUri + "/oneOf";
|
|
1565
|
-
return {
|
|
1566
|
-
isValid: false,
|
|
1567
|
-
value: data,
|
|
1568
|
-
valueUri: options.dataSourceUri,
|
|
1569
|
-
schemaUri,
|
|
1570
|
-
reason: (0, import_js_format11.format)(
|
|
1571
|
-
"Value at %v must match exactly one of schemas at %v, but %d matched.",
|
|
1572
|
-
options.dataSourceUri,
|
|
1573
|
-
schemaUri,
|
|
1574
|
-
matches
|
|
1575
|
-
)
|
|
1576
|
-
};
|
|
1577
|
-
}
|
|
1578
|
-
data = matchedResultValue;
|
|
1579
|
-
if (matchedEvaluatedIndexes) {
|
|
1580
|
-
evaluatedIndexes = /* @__PURE__ */ new Set([
|
|
1581
|
-
...evaluatedIndexes,
|
|
1582
|
-
...matchedEvaluatedIndexes
|
|
1583
|
-
]);
|
|
1584
|
-
}
|
|
1585
|
-
if (matchedEvaluatedProperties) {
|
|
1586
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
1587
|
-
...evaluatedProperties,
|
|
1588
|
-
...matchedEvaluatedProperties
|
|
1589
|
-
]);
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
1593
|
-
let matchFound = false;
|
|
1594
|
-
for (const index in schema.anyOf) {
|
|
1595
|
-
const subSchema = schema.anyOf[index];
|
|
1596
|
-
const result = _validate(data, subSchema, {
|
|
1597
|
-
...options,
|
|
1598
|
-
schemaSourceUri: options.schemaSourceUri + "/anyOf/" + index
|
|
1599
|
-
});
|
|
1600
|
-
if (result.isValid) {
|
|
1601
|
-
if (!matchFound) {
|
|
1602
|
-
data = result.value;
|
|
1603
|
-
}
|
|
1604
|
-
if (result.evaluatedIndexes) {
|
|
1605
|
-
evaluatedIndexes = /* @__PURE__ */ new Set([
|
|
1606
|
-
...evaluatedIndexes,
|
|
1607
|
-
...result.evaluatedIndexes
|
|
1608
|
-
]);
|
|
1609
|
-
}
|
|
1610
|
-
if (result.evaluatedProperties) {
|
|
1611
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
1612
|
-
...evaluatedProperties,
|
|
1613
|
-
...result.evaluatedProperties
|
|
1614
|
-
]);
|
|
1615
|
-
}
|
|
1616
|
-
matchFound = true;
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
if (!matchFound) {
|
|
1620
|
-
const schemaUri = options.schemaSourceUri + "/anyOf";
|
|
1621
|
-
return {
|
|
1622
|
-
isValid: false,
|
|
1623
|
-
value: data,
|
|
1624
|
-
valueUri: options.dataSourceUri,
|
|
1625
|
-
schemaUri,
|
|
1626
|
-
reason: (0, import_js_format11.format)(
|
|
1627
|
-
"Value at %v must match at least one of schemas at %v, but 0 matched.",
|
|
1628
|
-
options.dataSourceUri,
|
|
1629
|
-
schemaUri
|
|
1630
|
-
)
|
|
1631
|
-
};
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
if (schema.not) {
|
|
1635
|
-
const { isValid } = _validate(data, schema.not, {
|
|
1636
|
-
...options,
|
|
1637
|
-
schemaSourceUri: options.schemaSourceUri + "/not"
|
|
1638
|
-
});
|
|
1639
|
-
if (isValid) {
|
|
1640
|
-
return {
|
|
1641
|
-
isValid: false,
|
|
1642
|
-
value: data,
|
|
1643
|
-
valueUri: options.dataSourceUri,
|
|
1644
|
-
schemaUri: options.schemaSourceUri + "/not",
|
|
1645
|
-
reason: (0, import_js_format11.format)(
|
|
1646
|
-
'Value at %v must not match the "not" schema.',
|
|
1647
|
-
options.dataSourceUri
|
|
1648
|
-
)
|
|
1649
|
-
};
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
if (schema.if) {
|
|
1653
|
-
const ifResult = _validate(data, schema.if, {
|
|
1654
|
-
...options,
|
|
1655
|
-
schemaSourceUri: options.schemaSourceUri + "/if"
|
|
1656
|
-
});
|
|
1657
|
-
if (ifResult.isValid) {
|
|
1658
|
-
data = ifResult.value;
|
|
1659
|
-
if (ifResult.evaluatedIndexes) {
|
|
1660
|
-
evaluatedIndexes = /* @__PURE__ */ new Set([
|
|
1661
|
-
...evaluatedIndexes,
|
|
1662
|
-
...ifResult.evaluatedIndexes
|
|
1663
|
-
]);
|
|
1664
|
-
}
|
|
1665
|
-
if (ifResult.evaluatedProperties) {
|
|
1666
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
1667
|
-
...evaluatedProperties,
|
|
1668
|
-
...ifResult.evaluatedProperties
|
|
1669
|
-
]);
|
|
1670
|
-
}
|
|
1671
|
-
if (schema.then) {
|
|
1672
|
-
const result = _validate(data, schema.then, {
|
|
1673
|
-
...options,
|
|
1674
|
-
schemaSourceUri: options.schemaSourceUri + "/then"
|
|
1675
|
-
});
|
|
1676
|
-
if (!result.isValid) {
|
|
1677
|
-
return result;
|
|
1678
|
-
}
|
|
1679
|
-
data = result.value;
|
|
1680
|
-
if (result.evaluatedIndexes) {
|
|
1681
|
-
evaluatedIndexes = /* @__PURE__ */ new Set([
|
|
1682
|
-
...evaluatedIndexes,
|
|
1683
|
-
...result.evaluatedIndexes
|
|
1684
|
-
]);
|
|
1685
|
-
}
|
|
1686
|
-
if (result.evaluatedProperties) {
|
|
1687
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
1688
|
-
...evaluatedProperties,
|
|
1689
|
-
...result.evaluatedProperties
|
|
1690
|
-
]);
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
} else {
|
|
1694
|
-
if (schema.else) {
|
|
1695
|
-
const result = _validate(data, schema.else, {
|
|
1696
|
-
...options,
|
|
1697
|
-
schemaSourceUri: options.schemaSourceUri + "/else"
|
|
1698
|
-
});
|
|
1699
|
-
if (!result.isValid) {
|
|
1700
|
-
return result;
|
|
1701
|
-
}
|
|
1702
|
-
data = result.value;
|
|
1703
|
-
if (result.evaluatedIndexes) {
|
|
1704
|
-
evaluatedIndexes = /* @__PURE__ */ new Set([
|
|
1705
|
-
...evaluatedIndexes,
|
|
1706
|
-
...result.evaluatedIndexes
|
|
1707
|
-
]);
|
|
1708
|
-
}
|
|
1709
|
-
if (result.evaluatedProperties) {
|
|
1710
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
1711
|
-
...evaluatedProperties,
|
|
1712
|
-
...result.evaluatedProperties
|
|
1713
|
-
]);
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
if (schema.type !== void 0 && data !== void 0) {
|
|
1719
|
-
const result = _validateType(data, schema.type, options);
|
|
1720
|
-
if (!result.isValid) {
|
|
1721
|
-
return result;
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
if (schema.format) {
|
|
1725
|
-
const result = _validateFormat(
|
|
1726
|
-
data,
|
|
1727
|
-
schema.format,
|
|
1728
|
-
{ ...OA_BUILT_IN_DATA_FORMAT_VALIDATOR_MAP, ...options.formatValidators },
|
|
1729
|
-
options
|
|
1730
|
-
);
|
|
1731
|
-
if (!result.isValid) {
|
|
1732
|
-
return result;
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
if (schema.const !== void 0) {
|
|
1736
|
-
if (!_areValuesEqual(schema.const, data)) {
|
|
1737
|
-
return {
|
|
1738
|
-
isValid: false,
|
|
1739
|
-
value: data,
|
|
1740
|
-
valueUri: options.dataSourceUri,
|
|
1741
|
-
schemaUri: options.schemaSourceUri,
|
|
1742
|
-
reason: (0, import_js_format11.format)(
|
|
1743
|
-
"Value at %v must be equal to constant %s, but %s was given.",
|
|
1744
|
-
options.dataSourceUri,
|
|
1745
|
-
toSpacedJson(schema.const, { truncate: 50 }),
|
|
1746
|
-
toSpacedJson(data, { truncate: 50 })
|
|
1747
|
-
)
|
|
1748
|
-
};
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
if (schema.enum && Array.isArray(schema.enum)) {
|
|
1752
|
-
const isFoundInEnum = schema.enum.some((el) => _areValuesEqual(el, data));
|
|
1753
|
-
if (!isFoundInEnum) {
|
|
1754
|
-
return {
|
|
1755
|
-
isValid: false,
|
|
1756
|
-
value: data,
|
|
1757
|
-
valueUri: options.dataSourceUri,
|
|
1758
|
-
schemaUri: options.schemaSourceUri,
|
|
1759
|
-
reason: (0, import_js_format11.format)(
|
|
1760
|
-
"Value at %v must be one of %s, but %s was given.",
|
|
1761
|
-
options.dataSourceUri,
|
|
1762
|
-
toSpacedJson(schema.enum, { truncate: 50 }),
|
|
1763
|
-
toSpacedJson(data, { truncate: 50 })
|
|
1764
|
-
)
|
|
1765
|
-
};
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
const currentType = inferOpenApiDataType(data, true);
|
|
1769
|
-
if (currentType === OADataType.STRING) {
|
|
1770
|
-
const result = _validateString(data, schema, options);
|
|
1771
|
-
if (!result.isValid) {
|
|
1772
|
-
return result;
|
|
1773
|
-
}
|
|
1774
|
-
} else if (currentType === OADataType.NUMBER || currentType === OADataType.INTEGER) {
|
|
1775
|
-
const result = _validateNumber(data, schema, options);
|
|
1776
|
-
if (!result.isValid) {
|
|
1777
|
-
return result;
|
|
1778
|
-
}
|
|
1779
|
-
} else if (currentType === OADataType.ARRAY) {
|
|
1780
|
-
const result = _validateArray(data, schema, evaluatedIndexes, options);
|
|
1781
|
-
if (!result.isValid) {
|
|
1782
|
-
return result;
|
|
1783
|
-
}
|
|
1784
|
-
data = result.value;
|
|
1785
|
-
if (result.evaluatedIndexes) {
|
|
1786
|
-
evaluatedIndexes = /* @__PURE__ */ new Set([
|
|
1787
|
-
...evaluatedIndexes,
|
|
1788
|
-
...result.evaluatedIndexes
|
|
1789
|
-
]);
|
|
1790
|
-
}
|
|
1791
|
-
} else if (currentType === OADataType.OBJECT) {
|
|
1792
|
-
const result = _validateObject(data, schema, evaluatedProperties, options);
|
|
1793
|
-
if (!result.isValid) {
|
|
1794
|
-
return result;
|
|
1795
|
-
}
|
|
1796
|
-
data = result.value;
|
|
1797
|
-
if (result.evaluatedProperties) {
|
|
1798
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
1799
|
-
...evaluatedProperties,
|
|
1800
|
-
...result.evaluatedProperties
|
|
1801
|
-
]);
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
return {
|
|
1805
|
-
isValid: true,
|
|
1806
|
-
value: data,
|
|
1807
|
-
valueUri: options.dataSourceUri,
|
|
1808
|
-
schemaUri: options.schemaSourceUri,
|
|
1809
|
-
evaluatedIndexes,
|
|
1810
|
-
evaluatedProperties
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
__name(_validate, "_validate");
|
|
1814
|
-
function _parseJson(data, expectedType) {
|
|
1815
|
-
if (typeof data !== "string") {
|
|
1816
|
-
return data;
|
|
1817
|
-
}
|
|
1818
|
-
const types = Array.isArray(expectedType) ? expectedType : [expectedType];
|
|
1819
|
-
const trimmedData = data.trim();
|
|
1820
|
-
if (types.includes(OADataType.ARRAY) && trimmedData[0] === "[" || types.includes(OADataType.OBJECT) && trimmedData[0] === "{" || types.includes(OADataType.INTEGER) && JSON_INTEGER_REGEXP.test(trimmedData) || types.includes(OADataType.NUMBER) && JSON_NUMBER_REGEXP.test(trimmedData) || types.includes(OADataType.BOOLEAN) && (trimmedData === "true" || trimmedData === "false") || types.includes(OADataType.NULL) && trimmedData === "null") {
|
|
1821
|
-
try {
|
|
1822
|
-
return JSON.parse(trimmedData);
|
|
1823
|
-
} catch {
|
|
1824
|
-
return data;
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
return data;
|
|
1828
|
-
}
|
|
1829
|
-
__name(_parseJson, "_parseJson");
|
|
1830
|
-
function _coerceType(data, expectedType) {
|
|
1831
|
-
const types = Array.isArray(expectedType) ? expectedType : [expectedType];
|
|
1832
|
-
const actualType = inferOpenApiDataType(data, true);
|
|
1833
|
-
if (types.includes(actualType)) {
|
|
1834
|
-
return data;
|
|
1835
|
-
}
|
|
1836
|
-
if (actualType === OADataType.INTEGER && types.includes(OADataType.NUMBER)) {
|
|
1837
|
-
return data;
|
|
1838
|
-
}
|
|
1839
|
-
for (const type of types) {
|
|
1840
|
-
switch (type) {
|
|
1841
|
-
case OADataType.STRING: {
|
|
1842
|
-
if (typeof data === "number" || typeof data === "boolean") {
|
|
1843
|
-
return String(data);
|
|
1844
|
-
}
|
|
1845
|
-
break;
|
|
1846
|
-
}
|
|
1847
|
-
case OADataType.NUMBER:
|
|
1848
|
-
case OADataType.INTEGER: {
|
|
1849
|
-
if (typeof data === "string" && data.trim() !== "") {
|
|
1850
|
-
const num = Number(data);
|
|
1851
|
-
if (!Number.isNaN(num)) {
|
|
1852
|
-
if (type === OADataType.INTEGER && Number.isInteger(num)) {
|
|
1853
|
-
return num;
|
|
1854
|
-
}
|
|
1855
|
-
if (type === OADataType.NUMBER) {
|
|
1856
|
-
return num;
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
break;
|
|
1861
|
-
}
|
|
1862
|
-
case OADataType.BOOLEAN: {
|
|
1863
|
-
if (data === "true") {
|
|
1864
|
-
return true;
|
|
1865
|
-
}
|
|
1866
|
-
if (data === "false") {
|
|
1867
|
-
return false;
|
|
1868
|
-
}
|
|
1869
|
-
break;
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
return data;
|
|
1874
|
-
}
|
|
1875
|
-
__name(_coerceType, "_coerceType");
|
|
1876
|
-
function _validateType(data, expectedType, options) {
|
|
1877
|
-
const allowedTypes = [expectedType].flat();
|
|
1878
|
-
const actualType = inferOpenApiDataType(data, true);
|
|
1879
|
-
const isMatch = allowedTypes.some((allowedType) => {
|
|
1880
|
-
if (allowedType === actualType) {
|
|
1881
|
-
return true;
|
|
1882
|
-
}
|
|
1883
|
-
if (allowedType === OADataType.NUMBER && actualType === OADataType.INTEGER) {
|
|
1884
|
-
return true;
|
|
1885
|
-
}
|
|
1886
|
-
return false;
|
|
1887
|
-
});
|
|
1888
|
-
if (allowedTypes.length && !isMatch) {
|
|
1889
|
-
return {
|
|
1890
|
-
isValid: false,
|
|
1891
|
-
value: data,
|
|
1892
|
-
valueUri: options.dataSourceUri,
|
|
1893
|
-
schemaUri: options.schemaSourceUri,
|
|
1894
|
-
reason: (0, import_js_format11.format)(
|
|
1895
|
-
"Value at %v must be %s, but %s was given.",
|
|
1896
|
-
options.dataSourceUri,
|
|
1897
|
-
allowedTypes.map((v) => toPascalCase(v)).join(" or "),
|
|
1898
|
-
toPascalCase(actualType)
|
|
1899
|
-
)
|
|
1900
|
-
};
|
|
1901
|
-
}
|
|
1902
|
-
return {
|
|
1903
|
-
isValid: true,
|
|
1904
|
-
value: data,
|
|
1905
|
-
valueUri: options.dataSourceUri,
|
|
1906
|
-
schemaUri: options.schemaSourceUri
|
|
1907
|
-
};
|
|
1908
|
-
}
|
|
1909
|
-
__name(_validateType, "_validateType");
|
|
1910
|
-
function _validateFormat(data, expectedFormat, validatorsMap, options) {
|
|
1911
|
-
const validator = validatorsMap[expectedFormat];
|
|
1912
|
-
if (validator) {
|
|
1913
|
-
const isValid = validator(data);
|
|
1914
|
-
if (!isValid) {
|
|
1915
|
-
return {
|
|
1916
|
-
isValid: false,
|
|
1917
|
-
value: data,
|
|
1918
|
-
valueUri: options.dataSourceUri,
|
|
1919
|
-
schemaUri: options.schemaSourceUri,
|
|
1920
|
-
reason: (0, import_js_format11.format)(
|
|
1921
|
-
"Value at %v must match format %v, but %s was given.",
|
|
1922
|
-
options.dataSourceUri,
|
|
1923
|
-
expectedFormat,
|
|
1924
|
-
toSpacedJson(data, { truncate: 50 })
|
|
1925
|
-
)
|
|
1926
|
-
};
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
1929
|
-
return {
|
|
1930
|
-
isValid: true,
|
|
1931
|
-
value: data,
|
|
1932
|
-
valueUri: options.dataSourceUri,
|
|
1933
|
-
schemaUri: options.schemaSourceUri
|
|
1934
|
-
};
|
|
1935
|
-
}
|
|
1936
|
-
__name(_validateFormat, "_validateFormat");
|
|
1937
|
-
function _areValuesEqual(a, b) {
|
|
1938
|
-
if (a === b) {
|
|
1939
|
-
return true;
|
|
1940
|
-
}
|
|
1941
|
-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
1942
|
-
return false;
|
|
1943
|
-
}
|
|
1944
|
-
if (a instanceof Date && b instanceof Date) {
|
|
1945
|
-
return a.getTime() === b.getTime();
|
|
1946
|
-
}
|
|
1947
|
-
if (a instanceof RegExp && b instanceof RegExp) {
|
|
1948
|
-
return a.toString() === b.toString();
|
|
1949
|
-
}
|
|
1950
|
-
if (Array.isArray(a) !== Array.isArray(b)) {
|
|
1951
|
-
return false;
|
|
1952
|
-
}
|
|
1953
|
-
if (Array.isArray(a)) {
|
|
1954
|
-
if (a.length !== b.length) {
|
|
1955
|
-
return false;
|
|
1956
|
-
}
|
|
1957
|
-
for (let i = 0; i < a.length; i++) {
|
|
1958
|
-
if (!_areValuesEqual(a[i], b[i])) {
|
|
1959
|
-
return false;
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
return true;
|
|
1963
|
-
}
|
|
1964
|
-
const keysA = Object.keys(a);
|
|
1965
|
-
const keysB = Object.keys(b);
|
|
1966
|
-
if (keysA.length !== keysB.length) {
|
|
1967
|
-
return false;
|
|
1968
|
-
}
|
|
1969
|
-
for (const key of keysA) {
|
|
1970
|
-
if (!Object.prototype.hasOwnProperty.call(b, key)) {
|
|
1971
|
-
return false;
|
|
1972
|
-
}
|
|
1973
|
-
if (!_areValuesEqual(a[key], b[key])) {
|
|
1974
|
-
return false;
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
return true;
|
|
1978
|
-
}
|
|
1979
|
-
__name(_areValuesEqual, "_areValuesEqual");
|
|
1980
|
-
function _validateString(data, schema, options) {
|
|
1981
|
-
if (typeof schema.minLength === "number") {
|
|
1982
|
-
const dataLength = countUnicode(data);
|
|
1983
|
-
if (dataLength < schema.minLength) {
|
|
1984
|
-
return {
|
|
1985
|
-
isValid: false,
|
|
1986
|
-
value: data,
|
|
1987
|
-
valueUri: options.dataSourceUri,
|
|
1988
|
-
schemaUri: options.schemaSourceUri,
|
|
1989
|
-
reason: (0, import_js_format11.format)(
|
|
1990
|
-
"String at %v must be at least %d characters long, but %d was given.",
|
|
1991
|
-
options.dataSourceUri,
|
|
1992
|
-
schema.minLength,
|
|
1993
|
-
dataLength
|
|
1994
|
-
)
|
|
1995
|
-
};
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
if (typeof schema.maxLength === "number") {
|
|
1999
|
-
const dataLength = countUnicode(data);
|
|
2000
|
-
if (dataLength > schema.maxLength) {
|
|
2001
|
-
return {
|
|
2002
|
-
isValid: false,
|
|
2003
|
-
value: data,
|
|
2004
|
-
valueUri: options.dataSourceUri,
|
|
2005
|
-
schemaUri: options.schemaSourceUri,
|
|
2006
|
-
reason: (0, import_js_format11.format)(
|
|
2007
|
-
"String at %v must be at most %d characters long, but %d was given.",
|
|
2008
|
-
options.dataSourceUri,
|
|
2009
|
-
schema.maxLength,
|
|
2010
|
-
dataLength
|
|
2011
|
-
)
|
|
2012
|
-
};
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
if (schema.pattern) {
|
|
2016
|
-
let regex;
|
|
2017
|
-
try {
|
|
2018
|
-
regex = new RegExp(schema.pattern, "u");
|
|
2019
|
-
} catch {
|
|
2020
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
2021
|
-
"Schema pattern %v at %v has an invalid expression.",
|
|
2022
|
-
schema.pattern,
|
|
2023
|
-
options.schemaSourceUri
|
|
2024
|
-
);
|
|
2025
|
-
}
|
|
2026
|
-
if (!regex.test(data)) {
|
|
2027
|
-
const reString = schema.pattern instanceof RegExp ? String(schema.pattern) : schema.pattern;
|
|
2028
|
-
return {
|
|
2029
|
-
isValid: false,
|
|
2030
|
-
value: data,
|
|
2031
|
-
valueUri: options.dataSourceUri,
|
|
2032
|
-
schemaUri: options.schemaSourceUri,
|
|
2033
|
-
reason: (0, import_js_format11.format)(
|
|
2034
|
-
"String at %v must match pattern %v, but %s was given.",
|
|
2035
|
-
options.dataSourceUri,
|
|
2036
|
-
reString,
|
|
2037
|
-
toSpacedJson(data, { truncate: 50 })
|
|
2038
|
-
)
|
|
2039
|
-
};
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
return {
|
|
2043
|
-
isValid: true,
|
|
2044
|
-
value: data,
|
|
2045
|
-
valueUri: options.dataSourceUri,
|
|
2046
|
-
schemaUri: options.schemaSourceUri
|
|
2047
|
-
};
|
|
2048
|
-
}
|
|
2049
|
-
__name(_validateString, "_validateString");
|
|
2050
|
-
function _validateNumber(data, schema, options) {
|
|
2051
|
-
if (typeof schema.minimum === "number") {
|
|
2052
|
-
if (data < schema.minimum) {
|
|
2053
|
-
return {
|
|
2054
|
-
isValid: false,
|
|
2055
|
-
value: data,
|
|
2056
|
-
valueUri: options.dataSourceUri,
|
|
2057
|
-
schemaUri: options.schemaSourceUri,
|
|
2058
|
-
reason: (0, import_js_format11.format)(
|
|
2059
|
-
"Value at %v must be greater than or equal to %d, but %v was given.",
|
|
2060
|
-
options.dataSourceUri,
|
|
2061
|
-
schema.minimum,
|
|
2062
|
-
data
|
|
2063
|
-
)
|
|
2064
|
-
};
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
if (typeof schema.maximum === "number") {
|
|
2068
|
-
if (data > schema.maximum) {
|
|
2069
|
-
return {
|
|
2070
|
-
isValid: false,
|
|
2071
|
-
value: data,
|
|
2072
|
-
valueUri: options.dataSourceUri,
|
|
2073
|
-
schemaUri: options.schemaSourceUri,
|
|
2074
|
-
reason: (0, import_js_format11.format)(
|
|
2075
|
-
"Value at %v must be less than or equal to %d, but %v was given.",
|
|
2076
|
-
options.dataSourceUri,
|
|
2077
|
-
schema.maximum,
|
|
2078
|
-
data
|
|
2079
|
-
)
|
|
2080
|
-
};
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
if (typeof schema.exclusiveMinimum === "number") {
|
|
2084
|
-
if (data <= schema.exclusiveMinimum) {
|
|
2085
|
-
return {
|
|
2086
|
-
isValid: false,
|
|
2087
|
-
value: data,
|
|
2088
|
-
valueUri: options.dataSourceUri,
|
|
2089
|
-
schemaUri: options.schemaSourceUri,
|
|
2090
|
-
reason: (0, import_js_format11.format)(
|
|
2091
|
-
"Value at %v must be greater than %d, but %v was given.",
|
|
2092
|
-
options.dataSourceUri,
|
|
2093
|
-
schema.exclusiveMinimum,
|
|
2094
|
-
data
|
|
2095
|
-
)
|
|
2096
|
-
};
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
if (typeof schema.exclusiveMaximum === "number") {
|
|
2100
|
-
if (data >= schema.exclusiveMaximum) {
|
|
2101
|
-
return {
|
|
2102
|
-
isValid: false,
|
|
2103
|
-
value: data,
|
|
2104
|
-
valueUri: options.dataSourceUri,
|
|
2105
|
-
schemaUri: options.schemaSourceUri,
|
|
2106
|
-
reason: (0, import_js_format11.format)(
|
|
2107
|
-
"Value at %v must be less than %d, but %v was given.",
|
|
2108
|
-
options.dataSourceUri,
|
|
2109
|
-
schema.exclusiveMaximum,
|
|
2110
|
-
data
|
|
2111
|
-
)
|
|
2112
|
-
};
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
if (typeof schema.multipleOf === "number") {
|
|
2116
|
-
if (schema.multipleOf <= 0) {
|
|
2117
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
2118
|
-
'Schema keyword "multipleOf" must be a Number strictly greater than 0, but %v was given.',
|
|
2119
|
-
schema.multipleOf
|
|
2120
|
-
);
|
|
2121
|
-
}
|
|
2122
|
-
const quotient = data / schema.multipleOf;
|
|
2123
|
-
const isInteger = Math.abs(quotient - Math.round(quotient)) < 1e-9;
|
|
2124
|
-
if (!isInteger) {
|
|
2125
|
-
return {
|
|
2126
|
-
isValid: false,
|
|
2127
|
-
value: data,
|
|
2128
|
-
valueUri: options.dataSourceUri,
|
|
2129
|
-
schemaUri: options.schemaSourceUri,
|
|
2130
|
-
reason: (0, import_js_format11.format)(
|
|
2131
|
-
"Value at %v must be a multiple of %v, but %v was given.",
|
|
2132
|
-
options.dataSourceUri,
|
|
2133
|
-
schema.multipleOf,
|
|
2134
|
-
data
|
|
2135
|
-
)
|
|
2136
|
-
};
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
return {
|
|
2140
|
-
isValid: true,
|
|
2141
|
-
value: data,
|
|
2142
|
-
valueUri: options.dataSourceUri,
|
|
2143
|
-
schemaUri: options.schemaSourceUri
|
|
2144
|
-
};
|
|
2145
|
-
}
|
|
2146
|
-
__name(_validateNumber, "_validateNumber");
|
|
2147
|
-
function _validateArray(data, schema, evaluatedIndexes, options) {
|
|
2148
|
-
evaluatedIndexes = new Set(evaluatedIndexes);
|
|
2149
|
-
const originalData = data;
|
|
2150
|
-
let validationStartIndex = 0;
|
|
2151
|
-
if (Array.isArray(schema.prefixItems)) {
|
|
2152
|
-
const loopLimit = Math.min(schema.prefixItems.length, data.length);
|
|
2153
|
-
for (let i = 0; i < loopLimit; i++) {
|
|
2154
|
-
const item = data[i];
|
|
2155
|
-
const subSchema = schema.prefixItems[i];
|
|
2156
|
-
const result = _validate(item, subSchema, {
|
|
2157
|
-
...options,
|
|
2158
|
-
dataSourceUri: `${options.dataSourceUri}/${i}`,
|
|
2159
|
-
schemaSourceUri: `${options.schemaSourceUri}/prefixItems/${i}`
|
|
2160
|
-
});
|
|
2161
|
-
if (!result.isValid) {
|
|
2162
|
-
return result;
|
|
2163
|
-
}
|
|
2164
|
-
if (item !== result.value) {
|
|
2165
|
-
if (data === originalData) {
|
|
2166
|
-
data = [...originalData];
|
|
2167
|
-
}
|
|
2168
|
-
data[i] = result.value;
|
|
2169
|
-
}
|
|
2170
|
-
evaluatedIndexes.add(i);
|
|
2171
|
-
}
|
|
2172
|
-
validationStartIndex = schema.prefixItems.length;
|
|
2173
|
-
}
|
|
2174
|
-
if (schema.items !== void 0) {
|
|
2175
|
-
for (let i = validationStartIndex; i < data.length; i++) {
|
|
2176
|
-
const item = data[i];
|
|
2177
|
-
const result = _validate(item, schema.items, {
|
|
2178
|
-
...options,
|
|
2179
|
-
dataSourceUri: `${options.dataSourceUri}/${i}`,
|
|
2180
|
-
schemaSourceUri: `${options.schemaSourceUri}/items`
|
|
2181
|
-
});
|
|
2182
|
-
if (!result.isValid) {
|
|
2183
|
-
return result;
|
|
2184
|
-
}
|
|
2185
|
-
if (item !== result.value) {
|
|
2186
|
-
if (data === originalData) {
|
|
2187
|
-
data = [...originalData];
|
|
2188
|
-
}
|
|
2189
|
-
data[i] = result.value;
|
|
2190
|
-
}
|
|
2191
|
-
evaluatedIndexes.add(i);
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
if (typeof schema.minItems === "number") {
|
|
2195
|
-
if (data.length < schema.minItems) {
|
|
2196
|
-
return {
|
|
2197
|
-
isValid: false,
|
|
2198
|
-
value: data,
|
|
2199
|
-
valueUri: options.dataSourceUri,
|
|
2200
|
-
schemaUri: options.schemaSourceUri,
|
|
2201
|
-
reason: (0, import_js_format11.format)(
|
|
2202
|
-
"Array at %v must contain at least %d items, but %d was given.",
|
|
2203
|
-
options.dataSourceUri,
|
|
2204
|
-
schema.minItems,
|
|
2205
|
-
data.length
|
|
2206
|
-
)
|
|
2207
|
-
};
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
if (typeof schema.maxItems === "number") {
|
|
2211
|
-
if (data.length > schema.maxItems) {
|
|
2212
|
-
return {
|
|
2213
|
-
isValid: false,
|
|
2214
|
-
value: data,
|
|
2215
|
-
valueUri: options.dataSourceUri,
|
|
2216
|
-
schemaUri: options.schemaSourceUri,
|
|
2217
|
-
reason: (0, import_js_format11.format)(
|
|
2218
|
-
"Array at %v must contain at most %d items, but %d was given.",
|
|
2219
|
-
options.dataSourceUri,
|
|
2220
|
-
schema.maxItems,
|
|
2221
|
-
data.length
|
|
2222
|
-
)
|
|
2223
|
-
};
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
if (schema.uniqueItems === true) {
|
|
2227
|
-
for (let i = 0; i < data.length; i++) {
|
|
2228
|
-
for (let j = i + 1; j < data.length; j++) {
|
|
2229
|
-
if (_areValuesEqual(data[i], data[j])) {
|
|
2230
|
-
return {
|
|
2231
|
-
isValid: false,
|
|
2232
|
-
value: data,
|
|
2233
|
-
valueUri: options.dataSourceUri,
|
|
2234
|
-
schemaUri: options.schemaSourceUri,
|
|
2235
|
-
reason: (0, import_js_format11.format)(
|
|
2236
|
-
"Array at %v must contain unique items, but items at index %d and %d are identical.",
|
|
2237
|
-
options.dataSourceUri,
|
|
2238
|
-
i,
|
|
2239
|
-
j
|
|
2240
|
-
)
|
|
2241
|
-
};
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
if (schema.contains) {
|
|
2247
|
-
let matches = 0;
|
|
2248
|
-
for (let i = 0, l = data.length; i < l; i++) {
|
|
2249
|
-
const item = data[i];
|
|
2250
|
-
const { isValid } = _validate(item, schema.contains, {
|
|
2251
|
-
...options,
|
|
2252
|
-
silent: true,
|
|
2253
|
-
schemaSourceUri: options.schemaSourceUri + "/contains"
|
|
2254
|
-
});
|
|
2255
|
-
if (isValid) {
|
|
2256
|
-
matches++;
|
|
2257
|
-
evaluatedIndexes.add(i);
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
const minContains = typeof schema.minContains === "number" ? schema.minContains : 1;
|
|
2261
|
-
if (matches < minContains) {
|
|
2262
|
-
return {
|
|
2263
|
-
isValid: false,
|
|
2264
|
-
value: data,
|
|
2265
|
-
valueUri: options.dataSourceUri,
|
|
2266
|
-
schemaUri: options.schemaSourceUri + "/contains",
|
|
2267
|
-
reason: (0, import_js_format11.format)(
|
|
2268
|
-
'Array at %v must contain at least %d item(s) matching the "contains" schema, but %d was found.',
|
|
2269
|
-
options.dataSourceUri,
|
|
2270
|
-
minContains,
|
|
2271
|
-
matches
|
|
2272
|
-
)
|
|
2273
|
-
};
|
|
2274
|
-
}
|
|
2275
|
-
if (typeof schema.maxContains === "number") {
|
|
2276
|
-
if (matches > schema.maxContains) {
|
|
2277
|
-
return {
|
|
2278
|
-
isValid: false,
|
|
2279
|
-
value: data,
|
|
2280
|
-
valueUri: options.dataSourceUri,
|
|
2281
|
-
schemaUri: options.schemaSourceUri + "/contains",
|
|
2282
|
-
reason: (0, import_js_format11.format)(
|
|
2283
|
-
'Array at %v must contain at most %d item(s) matching the "contains" schema, but %d was found.',
|
|
2284
|
-
options.dataSourceUri,
|
|
2285
|
-
schema.maxContains,
|
|
2286
|
-
matches
|
|
2287
|
-
)
|
|
2288
|
-
};
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
if (schema.unevaluatedItems !== void 0) {
|
|
2293
|
-
for (let i = 0, l = data.length; i < l; i++) {
|
|
2294
|
-
if (evaluatedIndexes.has(i)) {
|
|
2295
|
-
continue;
|
|
2296
|
-
}
|
|
2297
|
-
const result = _validate(data[i], schema.unevaluatedItems, {
|
|
2298
|
-
...options,
|
|
2299
|
-
dataSourceUri: `${options.dataSourceUri}/${i}`,
|
|
2300
|
-
schemaSourceUri: `${options.schemaSourceUri}/unevaluatedItems`
|
|
2301
|
-
});
|
|
2302
|
-
if (!result.isValid) {
|
|
2303
|
-
if (schema.unevaluatedItems === false) {
|
|
2304
|
-
return {
|
|
2305
|
-
isValid: false,
|
|
2306
|
-
value: data[i],
|
|
2307
|
-
valueUri: `${options.dataSourceUri}/${i}`,
|
|
2308
|
-
schemaUri: `${options.schemaSourceUri}/unevaluatedItems`,
|
|
2309
|
-
reason: (0, import_js_format11.format)(
|
|
2310
|
-
"Array at %v has unevaluated item at index %d, which is not allowed.",
|
|
2311
|
-
options.dataSourceUri,
|
|
2312
|
-
i
|
|
2313
|
-
)
|
|
2314
|
-
};
|
|
2315
|
-
}
|
|
2316
|
-
return result;
|
|
2317
|
-
}
|
|
2318
|
-
if (data[i] !== result.value) {
|
|
2319
|
-
if (data === originalData) {
|
|
2320
|
-
data = [...originalData];
|
|
2321
|
-
}
|
|
2322
|
-
data[i] = result.value;
|
|
2323
|
-
}
|
|
2324
|
-
evaluatedIndexes.add(i);
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
if (options.stripUnknown === true) {
|
|
2328
|
-
if (evaluatedIndexes.size > 0) {
|
|
2329
|
-
for (let i = 0, l = data.length; i < l; i++) {
|
|
2330
|
-
if (evaluatedIndexes.has(i)) {
|
|
2331
|
-
continue;
|
|
2332
|
-
}
|
|
2333
|
-
if (data === originalData) {
|
|
2334
|
-
data = [...originalData];
|
|
2335
|
-
}
|
|
2336
|
-
data.splice(i, 1);
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
return {
|
|
2341
|
-
isValid: true,
|
|
2342
|
-
value: data,
|
|
2343
|
-
valueUri: options.dataSourceUri,
|
|
2344
|
-
schemaUri: options.schemaSourceUri,
|
|
2345
|
-
evaluatedIndexes
|
|
2346
|
-
};
|
|
2347
|
-
}
|
|
2348
|
-
__name(_validateArray, "_validateArray");
|
|
2349
|
-
function _validateObject(data, schema, evaluatedProperties, options) {
|
|
2350
|
-
evaluatedProperties = new Set(evaluatedProperties);
|
|
2351
|
-
const originalData = data;
|
|
2352
|
-
if (typeof schema.maxProperties === "number") {
|
|
2353
|
-
const propsNumber = Object.keys(data).length;
|
|
2354
|
-
if (propsNumber > schema.maxProperties) {
|
|
2355
|
-
return {
|
|
2356
|
-
isValid: false,
|
|
2357
|
-
value: data,
|
|
2358
|
-
valueUri: options.dataSourceUri,
|
|
2359
|
-
schemaUri: options.schemaSourceUri,
|
|
2360
|
-
reason: (0, import_js_format11.format)(
|
|
2361
|
-
"Object at %v must contain at most %d properties, but %d was given.",
|
|
2362
|
-
options.dataSourceUri,
|
|
2363
|
-
schema.maxProperties,
|
|
2364
|
-
propsNumber
|
|
2365
|
-
)
|
|
2366
|
-
};
|
|
2367
|
-
}
|
|
2368
|
-
}
|
|
2369
|
-
if (typeof schema.minProperties === "number") {
|
|
2370
|
-
const propsNumber = Object.keys(data).length;
|
|
2371
|
-
if (propsNumber < schema.minProperties) {
|
|
2372
|
-
return {
|
|
2373
|
-
isValid: false,
|
|
2374
|
-
value: data,
|
|
2375
|
-
valueUri: options.dataSourceUri,
|
|
2376
|
-
schemaUri: options.schemaSourceUri,
|
|
2377
|
-
reason: (0, import_js_format11.format)(
|
|
2378
|
-
"Object at %v must contain at least %d properties, but %d was given.",
|
|
2379
|
-
options.dataSourceUri,
|
|
2380
|
-
schema.minProperties,
|
|
2381
|
-
propsNumber
|
|
2382
|
-
)
|
|
2383
|
-
};
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
if (Array.isArray(schema.required)) {
|
|
2387
|
-
for (const propName of schema.required) {
|
|
2388
|
-
if (data[propName] === void 0) {
|
|
2389
|
-
if (options.accessMode) {
|
|
2390
|
-
const propSchema = schema.properties !== null && typeof schema.properties === "object" && schema.properties[propName] !== null && typeof schema.properties[propName] === "object" && schema.properties[propName];
|
|
2391
|
-
if (propSchema) {
|
|
2392
|
-
if (options.accessMode === OAAccessMode.WRITE && propSchema.readOnly === true || options.accessMode === OAAccessMode.READ && propSchema.writeOnly === true) {
|
|
2393
|
-
continue;
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
const propValue = data[propName];
|
|
2398
|
-
return {
|
|
2399
|
-
isValid: false,
|
|
2400
|
-
value: propValue,
|
|
2401
|
-
valueUri: `${options.dataSourceUri}/${propName}`,
|
|
2402
|
-
schemaUri: options.schemaSourceUri,
|
|
2403
|
-
reason: (0, import_js_format11.format)(
|
|
2404
|
-
"Property %v at %v is required, but %v was given.",
|
|
2405
|
-
propName,
|
|
2406
|
-
options.dataSourceUri,
|
|
2407
|
-
propValue
|
|
2408
|
-
)
|
|
2409
|
-
};
|
|
2410
|
-
}
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
if (schema.dependentRequired && typeof schema.dependentRequired === "object" && !Array.isArray(schema.dependentRequired)) {
|
|
2414
|
-
for (const triggerProp of Object.keys(schema.dependentRequired)) {
|
|
2415
|
-
const requiredProps = schema.dependentRequired[triggerProp];
|
|
2416
|
-
if (data[triggerProp] !== void 0) {
|
|
2417
|
-
if (Array.isArray(requiredProps)) {
|
|
2418
|
-
for (const requiredProp of requiredProps) {
|
|
2419
|
-
if (data[requiredProp] === void 0) {
|
|
2420
|
-
if (options.accessMode) {
|
|
2421
|
-
const requiredPropSchema = schema.properties !== null && typeof schema.properties === "object" && schema.properties[requiredProp] !== null && typeof schema.properties[requiredProp] === "object" && schema.properties[requiredProp];
|
|
2422
|
-
if (requiredPropSchema) {
|
|
2423
|
-
if (options.accessMode === OAAccessMode.WRITE && requiredPropSchema.readOnly === true || options.accessMode === OAAccessMode.READ && requiredPropSchema.writeOnly === true) {
|
|
2424
|
-
continue;
|
|
2425
|
-
}
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
return {
|
|
2429
|
-
isValid: false,
|
|
2430
|
-
value: data[requiredProp],
|
|
2431
|
-
valueUri: `${options.dataSourceUri}/${requiredProp}`,
|
|
2432
|
-
schemaUri: options.schemaSourceUri,
|
|
2433
|
-
reason: (0, import_js_format11.format)(
|
|
2434
|
-
"Property %v at %v is required because the property %v is present.",
|
|
2435
|
-
requiredProp,
|
|
2436
|
-
options.dataSourceUri,
|
|
2437
|
-
triggerProp
|
|
2438
|
-
)
|
|
2439
|
-
};
|
|
2440
|
-
}
|
|
2441
|
-
}
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
if (schema.dependentSchemas && typeof schema.dependentSchemas === "object" && !Array.isArray(schema.dependentSchemas)) {
|
|
2447
|
-
for (const triggerProp of Object.keys(schema.dependentSchemas)) {
|
|
2448
|
-
const subSchema = schema.dependentSchemas[triggerProp];
|
|
2449
|
-
if (data[triggerProp] !== void 0) {
|
|
2450
|
-
const result = _validate(data, subSchema, {
|
|
2451
|
-
...options,
|
|
2452
|
-
schemaSourceUri: `${options.schemaSourceUri}/dependentSchemas/${triggerProp}`
|
|
2453
|
-
});
|
|
2454
|
-
if (!result.isValid) {
|
|
2455
|
-
return result;
|
|
2456
|
-
}
|
|
2457
|
-
data = result.value;
|
|
2458
|
-
if (result.evaluatedProperties) {
|
|
2459
|
-
evaluatedProperties = /* @__PURE__ */ new Set([
|
|
2460
|
-
...evaluatedProperties,
|
|
2461
|
-
...result.evaluatedProperties
|
|
2462
|
-
]);
|
|
2463
|
-
}
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
}
|
|
2467
|
-
if (schema.propertyNames && typeof schema.propertyNames === "object" && !Array.isArray(schema.propertyNames)) {
|
|
2468
|
-
for (const propName of Object.keys(data)) {
|
|
2469
|
-
const result = _validate(propName, schema.propertyNames, {
|
|
2470
|
-
...options,
|
|
2471
|
-
dataSourceUri: `${options.dataSourceUri}`,
|
|
2472
|
-
schemaSourceUri: `${options.schemaSourceUri}/propertyNames`
|
|
2473
|
-
});
|
|
2474
|
-
if (!result.isValid) {
|
|
2475
|
-
return result;
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
}
|
|
2479
|
-
if (schema.properties && typeof schema.properties === "object") {
|
|
2480
|
-
for (const propName of Object.keys(schema.properties)) {
|
|
2481
|
-
const propSchema = schema.properties[propName];
|
|
2482
|
-
const isPropValuePresent = data[propName] !== void 0;
|
|
2483
|
-
const shouldApplyDefault = options.applyDefaults === true && propSchema !== null && typeof propSchema === "object" && propSchema.default !== void 0;
|
|
2484
|
-
if (isPropValuePresent || shouldApplyDefault) {
|
|
2485
|
-
const propValue = data[propName];
|
|
2486
|
-
const result = _validate(propValue, propSchema, {
|
|
2487
|
-
...options,
|
|
2488
|
-
dataSourceUri: `${options.dataSourceUri}/${propName}`,
|
|
2489
|
-
schemaSourceUri: `${options.schemaSourceUri}/properties/${propName}`
|
|
2490
|
-
});
|
|
2491
|
-
if (!result.isValid) {
|
|
2492
|
-
return result;
|
|
2493
|
-
}
|
|
2494
|
-
if (data[propName] !== result.value) {
|
|
2495
|
-
if (data === originalData) {
|
|
2496
|
-
data = { ...originalData };
|
|
2497
|
-
}
|
|
2498
|
-
data[propName] = result.value;
|
|
2499
|
-
}
|
|
2500
|
-
evaluatedProperties.add(propName);
|
|
2501
|
-
}
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2504
|
-
const passedPatternProperties = [];
|
|
2505
|
-
if (schema.patternProperties && typeof schema.patternProperties === "object") {
|
|
2506
|
-
for (const pattern of Object.keys(schema.patternProperties)) {
|
|
2507
|
-
const patternSchema = schema.patternProperties[pattern];
|
|
2508
|
-
let regex;
|
|
2509
|
-
try {
|
|
2510
|
-
regex = new RegExp(pattern, "u");
|
|
2511
|
-
} catch {
|
|
2512
|
-
throw new import_js_format11.InvalidArgumentError(
|
|
2513
|
-
"Property pattern %v at %v has an invalid expression.",
|
|
2514
|
-
pattern,
|
|
2515
|
-
options.schemaSourceUri
|
|
2516
|
-
);
|
|
2517
|
-
}
|
|
2518
|
-
for (const propName of Object.keys(data)) {
|
|
2519
|
-
if (regex.test(propName)) {
|
|
2520
|
-
const propValue = data[propName];
|
|
2521
|
-
const result = _validate(propValue, patternSchema, {
|
|
2522
|
-
...options,
|
|
2523
|
-
dataSourceUri: `${options.dataSourceUri}/${propName}`,
|
|
2524
|
-
schemaSourceUri: `${options.schemaSourceUri}/patternProperties/${pattern}`
|
|
2525
|
-
});
|
|
2526
|
-
if (!result.isValid) {
|
|
2527
|
-
return result;
|
|
2528
|
-
}
|
|
2529
|
-
if (data[propName] !== result.value) {
|
|
2530
|
-
if (data === originalData) {
|
|
2531
|
-
data = { ...originalData };
|
|
2532
|
-
}
|
|
2533
|
-
data[propName] = result.value;
|
|
2534
|
-
}
|
|
2535
|
-
evaluatedProperties.add(propName);
|
|
2536
|
-
passedPatternProperties.push(propName);
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2540
|
-
}
|
|
2541
|
-
if (schema.additionalProperties !== void 0) {
|
|
2542
|
-
const definedProps = schema.properties ? Object.keys(schema.properties) : [];
|
|
2543
|
-
for (const propName of Object.keys(data)) {
|
|
2544
|
-
if (definedProps.includes(propName)) {
|
|
2545
|
-
continue;
|
|
2546
|
-
}
|
|
2547
|
-
if (passedPatternProperties.includes(propName)) {
|
|
2548
|
-
continue;
|
|
2549
|
-
}
|
|
2550
|
-
if (schema.additionalProperties === false) {
|
|
2551
|
-
return {
|
|
2552
|
-
isValid: false,
|
|
2553
|
-
value: data[propName],
|
|
2554
|
-
valueUri: `${options.dataSourceUri}/${propName}`,
|
|
2555
|
-
schemaUri: `${options.schemaSourceUri}/additionalProperties`,
|
|
2556
|
-
reason: (0, import_js_format11.format)(
|
|
2557
|
-
"Property %v at %v is not allowed.",
|
|
2558
|
-
propName,
|
|
2559
|
-
options.dataSourceUri
|
|
2560
|
-
)
|
|
2561
|
-
};
|
|
2562
|
-
}
|
|
2563
|
-
if (schema.additionalProperties !== null && typeof schema.additionalProperties === "object" && !Array.isArray(schema.additionalProperties)) {
|
|
2564
|
-
const propValue = data[propName];
|
|
2565
|
-
const result = _validate(propValue, schema.additionalProperties, {
|
|
2566
|
-
...options,
|
|
2567
|
-
dataSourceUri: `${options.dataSourceUri}/${propName}`,
|
|
2568
|
-
schemaSourceUri: `${options.schemaSourceUri}/additionalProperties`
|
|
2569
|
-
});
|
|
2570
|
-
if (!result.isValid) {
|
|
2571
|
-
return result;
|
|
2572
|
-
}
|
|
2573
|
-
if (data[propName] !== result.value) {
|
|
2574
|
-
if (data === originalData) {
|
|
2575
|
-
data = { ...originalData };
|
|
2576
|
-
}
|
|
2577
|
-
data[propName] = result.value;
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
evaluatedProperties.add(propName);
|
|
2581
|
-
}
|
|
2582
|
-
}
|
|
2583
|
-
if (schema.unevaluatedProperties !== void 0) {
|
|
2584
|
-
for (const propName of Object.keys(data)) {
|
|
2585
|
-
if (evaluatedProperties.has(propName)) {
|
|
2586
|
-
continue;
|
|
2587
|
-
}
|
|
2588
|
-
if (schema.unevaluatedProperties === false) {
|
|
2589
|
-
return {
|
|
2590
|
-
isValid: false,
|
|
2591
|
-
value: data[propName],
|
|
2592
|
-
valueUri: `${options.dataSourceUri}/${propName}`,
|
|
2593
|
-
schemaUri: `${options.schemaSourceUri}/unevaluatedProperties`,
|
|
2594
|
-
reason: (0, import_js_format11.format)(
|
|
2595
|
-
"Property %v at %v is not evaluated and not allowed.",
|
|
2596
|
-
propName,
|
|
2597
|
-
options.dataSourceUri
|
|
2598
|
-
)
|
|
2599
|
-
};
|
|
2600
|
-
} else if (schema.unevaluatedProperties && typeof schema.unevaluatedProperties === "object" && !Array.isArray(schema.unevaluatedProperties)) {
|
|
2601
|
-
const propValue = data[propName];
|
|
2602
|
-
const result = _validate(propValue, schema.unevaluatedProperties, {
|
|
2603
|
-
...options,
|
|
2604
|
-
dataSourceUri: `${options.dataSourceUri}/${propName}`,
|
|
2605
|
-
schemaSourceUri: `${options.schemaSourceUri}/unevaluatedProperties`
|
|
2606
|
-
});
|
|
2607
|
-
if (!result.isValid) {
|
|
2608
|
-
return result;
|
|
2609
|
-
}
|
|
2610
|
-
if (data[propName] !== result.value) {
|
|
2611
|
-
if (data === originalData) {
|
|
2612
|
-
data = { ...originalData };
|
|
2613
|
-
}
|
|
2614
|
-
data[propName] = result.value;
|
|
2615
|
-
}
|
|
2616
|
-
evaluatedProperties.add(propName);
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
}
|
|
2620
|
-
if (options.stripUnknown === true) {
|
|
2621
|
-
if (evaluatedProperties.size > 0) {
|
|
2622
|
-
for (const propName of Object.keys(data)) {
|
|
2623
|
-
if (evaluatedProperties.has(propName)) {
|
|
2624
|
-
continue;
|
|
2625
|
-
}
|
|
2626
|
-
if (data === originalData) {
|
|
2627
|
-
data = { ...originalData };
|
|
2628
|
-
}
|
|
2629
|
-
delete data[propName];
|
|
2630
|
-
}
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
return {
|
|
2634
|
-
isValid: true,
|
|
2635
|
-
value: data,
|
|
2636
|
-
valueUri: options.dataSourceUri,
|
|
2637
|
-
schemaUri: options.schemaSourceUri,
|
|
2638
|
-
evaluatedProperties
|
|
2639
|
-
};
|
|
2640
|
-
}
|
|
2641
|
-
__name(_validateObject, "_validateObject");
|
|
2642
2592
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2643
2593
|
0 && (module.exports = {
|
|
2644
|
-
ACCESS_MODE_LIST,
|
|
2645
|
-
JSON_INTEGER_REGEXP,
|
|
2646
|
-
JSON_NUMBER_REGEXP,
|
|
2647
2594
|
OAAccessMode,
|
|
2648
2595
|
OAApiKeyLocation,
|
|
2649
2596
|
OAComponentType,
|
|
2650
2597
|
OADataFormat,
|
|
2651
2598
|
OADataType,
|
|
2652
|
-
OADataValidationError,
|
|
2653
2599
|
OADocumentBuilder,
|
|
2654
|
-
|
|
2600
|
+
OADocumentObjectValidationError,
|
|
2655
2601
|
OAMediaType,
|
|
2602
|
+
OAOperationGroup,
|
|
2656
2603
|
OAOperationMethod,
|
|
2657
2604
|
OAParameterLocation,
|
|
2658
2605
|
OAParameterStyle,
|
|
2659
2606
|
OASecuritySchemeType,
|
|
2660
|
-
|
|
2607
|
+
OA_COMPONENT_NAME_REGEX,
|
|
2661
2608
|
OA_COMPONENT_TYPES,
|
|
2662
2609
|
OA_COMPONENT_TYPE_TO_COMPONENTS_KEY_MAP,
|
|
2663
|
-
|
|
2610
|
+
OA_COMPONENT_TYPE_TO_DEFINITION_NAME_MAP,
|
|
2664
2611
|
OPENAPI_VERSION,
|
|
2665
2612
|
escapeJsonPointer,
|
|
2666
|
-
inferOpenApiDataType,
|
|
2667
2613
|
isOAReferenceObject,
|
|
2668
2614
|
oaCallbackRef,
|
|
2669
2615
|
oaExampleRef,
|
|
@@ -2677,19 +2623,5 @@ __name(_validateObject, "_validateObject");
|
|
|
2677
2623
|
resolveJsonPointer,
|
|
2678
2624
|
resolveOAReferenceObject,
|
|
2679
2625
|
unescapeJsonPointer,
|
|
2680
|
-
|
|
2681
|
-
validateDataWithOpenApiSchema,
|
|
2682
|
-
validateDateFormat,
|
|
2683
|
-
validateDateTimeFormat,
|
|
2684
|
-
validateDoubleFormat,
|
|
2685
|
-
validateEmailFormat,
|
|
2686
|
-
validateFloatFormat,
|
|
2687
|
-
validateHostnameFormat,
|
|
2688
|
-
validateInt32Format,
|
|
2689
|
-
validateInt64Format,
|
|
2690
|
-
validateIpv4Format,
|
|
2691
|
-
validateIpv6Format,
|
|
2692
|
-
validateShallowOADocument,
|
|
2693
|
-
validateUriFormat,
|
|
2694
|
-
validateUuidFormat
|
|
2626
|
+
validateOADocumentObject
|
|
2695
2627
|
});
|