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