oas 34.0.2 → 36.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/index.cjs +6 -6
- package/dist/analyzer/index.cjs.map +1 -1
- package/dist/analyzer/index.js +4 -4
- package/dist/{chunk-GQ6E7DXK.js → chunk-ECH3NU2W.js} +8 -2
- package/dist/chunk-ECH3NU2W.js.map +1 -0
- package/dist/{chunk-HZ7LCMAM.cjs → chunk-ERUPYVMW.cjs} +132 -132
- package/dist/{chunk-HZ7LCMAM.cjs.map → chunk-ERUPYVMW.cjs.map} +1 -1
- package/dist/{chunk-KYSWFHUO.js → chunk-IJD7DGHE.js} +3 -3
- package/dist/{chunk-66Z3SYJH.js → chunk-MRBZAD3N.js} +8 -5
- package/dist/{chunk-66Z3SYJH.js.map → chunk-MRBZAD3N.js.map} +1 -1
- package/dist/{chunk-PSNTODZL.js → chunk-NM3QL4AB.js} +1 -1
- package/dist/{chunk-PSNTODZL.js.map → chunk-NM3QL4AB.js.map} +1 -1
- package/dist/{chunk-3MTU2ESP.cjs → chunk-NR45NABA.cjs} +1 -1
- package/dist/{chunk-3MTU2ESP.cjs.map → chunk-NR45NABA.cjs.map} +1 -1
- package/dist/{chunk-GXLENSTM.cjs → chunk-SARUCDNU.cjs} +32 -29
- package/dist/chunk-SARUCDNU.cjs.map +1 -0
- package/dist/{chunk-V4IQC5XF.cjs → chunk-YSYK5CMA.cjs} +43 -37
- package/dist/{chunk-V4IQC5XF.cjs.map → chunk-YSYK5CMA.cjs.map} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.js +4 -4
- package/dist/operation/index.cjs +4 -4
- package/dist/operation/index.js +3 -3
- package/dist/reducer/index.cjs +13 -13
- package/dist/reducer/index.js +2 -2
- package/dist/types.cjs +2 -2
- package/dist/types.d.cts +4 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.js +1 -1
- package/dist/utils.cjs +3 -3
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-GQ6E7DXK.js.map +0 -1
- package/dist/chunk-GXLENSTM.cjs.map +0 -1
- /package/dist/{chunk-KYSWFHUO.js.map → chunk-IJD7DGHE.js.map} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkERUPYVMWcjs = require('./chunk-ERUPYVMW.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkYSYK5CMAcjs = require('./chunk-YSYK5CMA.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ var _chunkAYA3UT4Lcjs = require('./chunk-AYA3UT4L.cjs');
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkNR45NABAcjs = require('./chunk-NR45NABA.cjs');
|
|
27
27
|
|
|
28
28
|
// src/index.ts
|
|
29
29
|
var _openapiparser = require('@readme/openapi-parser');
|
|
@@ -36,7 +36,10 @@ function getKey(user, scheme) {
|
|
|
36
36
|
return user[scheme._key] || user.apiKey || scheme["x-default"] || null;
|
|
37
37
|
case "http":
|
|
38
38
|
if (scheme.scheme === "basic") {
|
|
39
|
-
return user[scheme._key] || { user: user.user || null, pass: user.pass || null }
|
|
39
|
+
return user[scheme._key] || (user.user || user.pass ? { user: user.user || null, pass: user.pass || null } : scheme["x-default"]) || {
|
|
40
|
+
user: null,
|
|
41
|
+
pass: null
|
|
42
|
+
};
|
|
40
43
|
}
|
|
41
44
|
if (scheme.scheme === "bearer") {
|
|
42
45
|
return user[scheme._key] || user.apiKey || scheme["x-default"] || null;
|
|
@@ -61,8 +64,8 @@ function getByScheme(user, scheme = {}, selectedApp) {
|
|
|
61
64
|
}
|
|
62
65
|
function getAuth(api, user, selectedApp) {
|
|
63
66
|
return Object.keys(_optionalChain([api, 'optionalAccess', _3 => _3.components, 'optionalAccess', _4 => _4.securitySchemes]) || {}).map((scheme) => {
|
|
64
|
-
const securityScheme =
|
|
65
|
-
if (!securityScheme ||
|
|
67
|
+
const securityScheme = _chunkYSYK5CMAcjs.dereferenceRef.call(void 0, _optionalChain([api, 'access', _5 => _5.components, 'optionalAccess', _6 => _6.securitySchemes, 'optionalAccess', _7 => _7[scheme]]), api);
|
|
68
|
+
if (!securityScheme || _chunkNR45NABAcjs.isRef.call(void 0, securityScheme)) {
|
|
66
69
|
return false;
|
|
67
70
|
}
|
|
68
71
|
return {
|
|
@@ -126,7 +129,7 @@ function normalizedURL(api, selected) {
|
|
|
126
129
|
return ensureProtocol(url);
|
|
127
130
|
}
|
|
128
131
|
function transformURLIntoRegex(url) {
|
|
129
|
-
return stripTrailingSlash(url.replace(
|
|
132
|
+
return stripTrailingSlash(url.replace(_chunkYSYK5CMAcjs.SERVER_VARIABLE_REGEX, "([-_a-zA-Z0-9:.[\\]]+)"));
|
|
130
133
|
}
|
|
131
134
|
function normalizePath(path) {
|
|
132
135
|
return path.replace(/({?){(.*?)}(}?)/g, (str, ...args) => {
|
|
@@ -331,7 +334,7 @@ var Oas = (_class = class _Oas {
|
|
|
331
334
|
return false;
|
|
332
335
|
}
|
|
333
336
|
const variables = {};
|
|
334
|
-
Array.from(server.url.matchAll(
|
|
337
|
+
Array.from(server.url.matchAll(_chunkYSYK5CMAcjs.SERVER_VARIABLE_REGEX)).forEach((variable, y) => {
|
|
335
338
|
variables[variable[1]] = found[y + 1];
|
|
336
339
|
});
|
|
337
340
|
return {
|
|
@@ -362,7 +365,7 @@ var Oas = (_class = class _Oas {
|
|
|
362
365
|
*/
|
|
363
366
|
replaceUrl(url, variables = {}) {
|
|
364
367
|
return stripTrailingSlash(
|
|
365
|
-
url.replace(
|
|
368
|
+
url.replace(_chunkYSYK5CMAcjs.SERVER_VARIABLE_REGEX, (original, key) => {
|
|
366
369
|
if (key in variables) {
|
|
367
370
|
const data = variables[key];
|
|
368
371
|
if (typeof data === "object") {
|
|
@@ -392,23 +395,23 @@ var Oas = (_class = class _Oas {
|
|
|
392
395
|
parameters: []
|
|
393
396
|
};
|
|
394
397
|
if (opts.isWebhook) {
|
|
395
|
-
if (
|
|
396
|
-
const webhookPath =
|
|
397
|
-
if (webhookPath && !
|
|
398
|
+
if (_chunkNR45NABAcjs.isOpenAPI31.call(void 0, this.api)) {
|
|
399
|
+
const webhookPath = _chunkYSYK5CMAcjs.dereferenceRef.call(void 0, _optionalChain([this, 'access', _19 => _19.api, 'optionalAccess', _20 => _20.webhooks, 'optionalAccess', _21 => _21[path]]), this.api);
|
|
400
|
+
if (webhookPath && !_chunkNR45NABAcjs.isRef.call(void 0, webhookPath)) {
|
|
398
401
|
if (_optionalChain([webhookPath, 'optionalAccess', _22 => _22[method]])) {
|
|
399
402
|
operation = webhookPath[method];
|
|
400
|
-
return new (0,
|
|
403
|
+
return new (0, _chunkERUPYVMWcjs.Webhook)(this, path, method, operation);
|
|
401
404
|
}
|
|
402
405
|
}
|
|
403
406
|
}
|
|
404
407
|
}
|
|
405
408
|
if (_optionalChain([this, 'optionalAccess', _23 => _23.api, 'optionalAccess', _24 => _24.paths, 'optionalAccess', _25 => _25[path]])) {
|
|
406
|
-
const pathItem =
|
|
409
|
+
const pathItem = _chunkYSYK5CMAcjs.dereferenceRef.call(void 0, this.api.paths[path], this.api);
|
|
407
410
|
if (_optionalChain([pathItem, 'optionalAccess', _26 => _26[method]])) {
|
|
408
|
-
operation =
|
|
411
|
+
operation = _chunkYSYK5CMAcjs.dereferenceRef.call(void 0, pathItem[method], this.api);
|
|
409
412
|
}
|
|
410
413
|
}
|
|
411
|
-
return new (0,
|
|
414
|
+
return new (0, _chunkERUPYVMWcjs.Operation)(this, path, method, operation);
|
|
412
415
|
}
|
|
413
416
|
findOperationMatches(url) {
|
|
414
417
|
const { origin, hostname } = new URL(url);
|
|
@@ -575,9 +578,9 @@ var Oas = (_class = class _Oas {
|
|
|
575
578
|
}
|
|
576
579
|
let scheme = _optionalChain([this, 'access', _34 => _34.api, 'optionalAccess', _35 => _35.components, 'optionalAccess', _36 => _36.securitySchemes, 'optionalAccess', _37 => _37[name]]);
|
|
577
580
|
if (!scheme) return void 0;
|
|
578
|
-
if (
|
|
579
|
-
scheme =
|
|
580
|
-
if (!scheme ||
|
|
581
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, scheme)) {
|
|
582
|
+
scheme = _chunkYSYK5CMAcjs.dereferenceRef.call(void 0, scheme, this.api);
|
|
583
|
+
if (!scheme || _chunkNR45NABAcjs.isRef.call(void 0, scheme)) return void 0;
|
|
581
584
|
}
|
|
582
585
|
return scheme;
|
|
583
586
|
}
|
|
@@ -601,15 +604,15 @@ var Oas = (_class = class _Oas {
|
|
|
601
604
|
let pathItem = this.api.paths[path];
|
|
602
605
|
if (!pathItem) {
|
|
603
606
|
return;
|
|
604
|
-
} else if (
|
|
605
|
-
this.api.paths[path] =
|
|
607
|
+
} else if (_chunkNR45NABAcjs.isRef.call(void 0, pathItem)) {
|
|
608
|
+
this.api.paths[path] = _chunkYSYK5CMAcjs.dereferenceRef.call(void 0, pathItem, this.api);
|
|
606
609
|
pathItem = this.api.paths[path];
|
|
607
|
-
if (!pathItem ||
|
|
610
|
+
if (!pathItem || _chunkNR45NABAcjs.isRef.call(void 0, pathItem)) {
|
|
608
611
|
return;
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
614
|
Object.keys(pathItem).forEach((method) => {
|
|
612
|
-
if (!
|
|
615
|
+
if (!_chunkYSYK5CMAcjs.supportedMethods.includes(method)) {
|
|
613
616
|
return;
|
|
614
617
|
}
|
|
615
618
|
paths[path][method] = this.operation(path, method);
|
|
@@ -626,15 +629,15 @@ var Oas = (_class = class _Oas {
|
|
|
626
629
|
*/
|
|
627
630
|
getWebhooks() {
|
|
628
631
|
const webhooks = {};
|
|
629
|
-
if (!
|
|
632
|
+
if (!_chunkNR45NABAcjs.isOpenAPI31.call(void 0, this.api) || !this.api.webhooks) {
|
|
630
633
|
return webhooks;
|
|
631
634
|
}
|
|
632
635
|
Object.keys(this.api.webhooks).forEach((id) => {
|
|
633
636
|
webhooks[id] = {};
|
|
634
|
-
const webhookPath =
|
|
637
|
+
const webhookPath = _chunkYSYK5CMAcjs.dereferenceRef.call(void 0, _optionalChain([this, 'access', _38 => _38.api, 'access', _39 => _39.webhooks, 'optionalAccess', _40 => _40[id]]), this.api);
|
|
635
638
|
if (webhookPath) {
|
|
636
639
|
Object.keys(webhookPath).forEach((method) => {
|
|
637
|
-
if (!
|
|
640
|
+
if (!_chunkYSYK5CMAcjs.supportedMethods.includes(method)) {
|
|
638
641
|
return;
|
|
639
642
|
}
|
|
640
643
|
webhooks[id][method] = this.operation(id, method, {
|
|
@@ -804,12 +807,12 @@ var Oas = (_class = class _Oas {
|
|
|
804
807
|
}
|
|
805
808
|
this.dereferencing.processing = true;
|
|
806
809
|
if (!this.schemasDecorated) {
|
|
807
|
-
|
|
810
|
+
_chunkYSYK5CMAcjs.decorateComponentSchemasWithRefName.call(void 0, this.api);
|
|
808
811
|
this.schemasDecorated = true;
|
|
809
812
|
}
|
|
810
813
|
const { api, promises } = this;
|
|
811
814
|
const circularRefs = /* @__PURE__ */ new Set();
|
|
812
|
-
const dereferencingOptions =
|
|
815
|
+
const dereferencingOptions = _chunkYSYK5CMAcjs.getDereferencingOptions.call(void 0, circularRefs);
|
|
813
816
|
return _openapiparser.dereference.call(void 0, api, dereferencingOptions).then((dereferenced) => {
|
|
814
817
|
this.api = dereferenced;
|
|
815
818
|
this.promises = promises;
|
|
@@ -856,4 +859,4 @@ var Oas = (_class = class _Oas {
|
|
|
856
859
|
|
|
857
860
|
|
|
858
861
|
exports.Oas = Oas;
|
|
859
|
-
//# sourceMappingURL=chunk-
|
|
862
|
+
//# sourceMappingURL=chunk-SARUCDNU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/chunk-SARUCDNU.cjs","../src/index.ts","../src/lib/get-auth.ts","../src/lib/get-user-variable.ts","../src/lib/urls.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACXA,uDAA4B;ADa5B;AACA;AElBA,SAAS,MAAA,CAAO,IAAA,EAAY,MAAA,EAA4C;AACtE,EAAA,OAAA,CAAQ,MAAA,CAAO,IAAA,EAAM;AAAA,IACnB,KAAK,QAAA;AAAA,IACL,KAAK,QAAA;AACH,MAAA,OAAO,IAAA,CAAK,MAAA,CAAO,IAAI,EAAA,GAAK,IAAA,CAAK,OAAA,GAAU,MAAA,CAAO,WAAW,EAAA,GAAK,IAAA;AAAA,IAEpE,KAAK,MAAA;AACH,MAAA,GAAA,CAAI,MAAA,CAAO,OAAA,IAAW,OAAA,EAAS;AAC7B,QAAA,OACE,IAAA,CAAK,MAAA,CAAO,IAAI,EAAA,GAAA,CACf,IAAA,CAAK,KAAA,GAAQ,IAAA,CAAK,KAAA,EAAO,EAAE,IAAA,EAAM,IAAA,CAAK,KAAA,GAAQ,IAAA,EAAM,IAAA,EAAM,IAAA,CAAK,KAAA,GAAQ,KAAK,EAAA,EAAI,MAAA,CAAO,WAAW,CAAA,EAAA,GAAM;AAAA,U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AACF,QAAA;AAAA;AAEK,QAAA;AACjB,MAAA;AAGc,MAAA;AACH,wBAAA;AACX,MAAA;AAEU,IAAA;AACE,MAAA;AAEA,IAAA;AACP,MAAA;AACa,MAAA;AACZ,MAAA;AACP,IAAA;AACL,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO0B,EAAA;AACZ,IAAA;AACd,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,EAAA;AACY,IAAA;AACQ,MAAA;AAClB,IAAA;AAEY,IAAA;AACd,EAAA;AACF;ADnEwB;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas/dist/chunk-SARUCDNU.cjs","sourcesContent":[null,"import type { Extensions } from './extensions.js';\nimport type { PathMatch, PathMatches } from './lib/urls.js';\nimport type {\n AuthForHAR,\n HttpMethods,\n OASDocument,\n OperationObject,\n SecuritySchemeObject,\n ServerObject,\n Servers,\n ServerVariable,\n ServerVariablesObject,\n User,\n} from './types.js';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport { dereference } from '@readme/openapi-parser';\n\nimport {\n CODE_SAMPLES,\n extensionDefaults,\n getExtension,\n HEADERS,\n hasRootExtension,\n OAUTH_OPTIONS,\n PARAMETER_ORDERING,\n SAMPLES_LANGUAGES,\n validateParameterOrdering,\n} from './extensions.js';\nimport { getAuth } from './lib/get-auth.js';\nimport getUserVariable from './lib/get-user-variable.js';\nimport { decorateComponentSchemasWithRefName, dereferenceRef, getDereferencingOptions } from './lib/refs.js';\nimport {\n filterPathMethods,\n findTargetPath,\n generatePathMatches,\n normalizedURL,\n stripTrailingSlash,\n transformURLIntoRegex,\n} from './lib/urls.js';\nimport { Operation, Webhook } from './operation/index.js';\nimport { isOpenAPI31, isRef } from './types.js';\nimport { SERVER_VARIABLE_REGEX, supportedMethods } from './utils.js';\n\nexport default class Oas {\n /**\n * The current OpenAPI definition.\n */\n api: OASDocument;\n\n /**\n * The current user that we should use when pulling auth tokens from security schemes.\n */\n user: User;\n\n /**\n * Internal storage array that the library utilizes to keep track of the times the\n * {@see Oas.dereference} has been called so that if you initiate multiple promises they'll all\n * end up returning the same data set once the initial dereference call completed.\n */\n protected promises: {\n reject: any;\n resolve: any;\n }[];\n\n /**\n * Internal storage array that the library utilizes to keep track of its `dereferencing` state so\n * it doesn't initiate multiple dereferencing processes.\n */\n protected dereferencing: {\n circularRefs: string[];\n complete: boolean;\n processing: boolean;\n };\n\n /**\n * Have the component schemas within this API definition been decorated with our\n * `x-readme-ref-name` extension?\n *\n * @see {@link decorateComponentSchemas}\n */\n protected schemasDecorated: boolean = false;\n\n /**\n * @param oas An OpenAPI definition.\n * @param user The information about a user that we should use when pulling auth tokens from\n * security schemes.\n */\n constructor(oas: OASDocument | string, user?: User) {\n if (typeof oas === 'string') {\n // oxlint-disable-next-line readme/json-parse-try-catch -- If this fails we should fail.\n this.api = (JSON.parse(oas) || {}) as OASDocument;\n } else {\n this.api = oas || ({} as OASDocument);\n }\n\n this.user = user || {};\n\n this.promises = [];\n this.dereferencing = {\n processing: false,\n complete: false,\n circularRefs: [],\n };\n }\n\n /**\n * This will initialize a new instance of the `Oas` class. This method is useful if you're using\n * Typescript and are attempting to supply an untyped JSON object into `Oas` as it will force-type\n * that object to an `OASDocument` for you.\n *\n * @param oas An OpenAPI definition.\n * @param user The information about a user that we should use when pulling auth tokens from\n * security schemes.\n */\n static init(oas: OASDocument | Record<string, unknown>, user?: User): Oas {\n return new Oas(oas as OASDocument, user);\n }\n\n /**\n * Retrieve the OpenAPI version that this API definition is targeted for.\n */\n getVersion(): string {\n if (this.api.openapi) {\n return this.api.openapi;\n }\n\n throw new Error('Unable to recognize what specification version this API definition conforms to.');\n }\n\n /**\n * Retrieve the current OpenAPI API Definition.\n *\n */\n getDefinition(): OASDocument {\n return this.api;\n }\n\n url(selected = 0, variables?: ServerVariable): string {\n const url = normalizedURL(this.api, selected);\n return this.replaceUrl(url, variables || this.defaultVariables(selected)).trim();\n }\n\n variables(selected = 0): ServerVariablesObject {\n return this.api.servers?.[selected]?.variables || {};\n }\n\n defaultVariables(selected = 0): ServerVariable {\n const variables = this.variables(selected);\n const defaults: ServerVariable = {};\n\n Object.keys(variables).forEach(key => {\n defaults[key] = getUserVariable(this.user, key) || variables[key].default || '';\n });\n\n return defaults;\n }\n\n splitUrl(selected = 0): (\n | {\n /**\n * A unique key, where the `value` is concatenated to its index\n */\n key: string;\n type: 'text';\n value: string;\n }\n | {\n /**\n * An optional description for the server variable.\n *\n * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-4}\n */\n description?: string;\n\n /**\n * An enumeration of string values to be used if the substitution options are from a limited set.\n *\n * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-4}\n */\n enum?: string[];\n\n /**\n * A unique key, where the `value` is concatenated to its index\n */\n key: string;\n type: 'variable';\n value: string;\n }\n )[] {\n const url = normalizedURL(this.api, selected);\n const variables = this.variables(selected);\n\n return url\n .split(/({.+?})/)\n .filter(Boolean)\n .map((part, i) => {\n const isVariable = part.match(/[{}]/);\n const value = part.replace(/[{}]/g, '');\n // To ensure unique keys, we're going to create a key\n // with the value concatenated to its index.\n const key = `${value}-${i}`;\n\n if (!isVariable) {\n return {\n type: 'text',\n value,\n key,\n };\n }\n\n const variable = variables?.[value];\n\n return {\n type: 'variable',\n value,\n key,\n description: variable?.description,\n enum: variable?.enum,\n };\n });\n }\n\n /**\n * With a fully composed server URL, run through our list of known OAS servers and return back\n * which server URL was selected along with any contained server variables split out.\n *\n * For example, if you have an OAS server URL of `https://{name}.example.com:{port}/{basePath}`,\n * and pass in `https://buster.example.com:3000/pet` to this function, you'll get back the\n * following:\n *\n * { selected: 0, variables: { name: 'buster', port: 3000, basePath: 'pet' } }\n *\n * Re-supplying this data to `oas.url()` should return the same URL you passed into this method.\n *\n * @param baseUrl A given URL to extract server variables out of.\n */\n splitVariables(baseUrl: string): Servers | false {\n const matchedServer = (this.api.servers || [])\n .map((server, i) => {\n const rgx = transformURLIntoRegex(server.url);\n const found = new RegExp(rgx).exec(baseUrl);\n if (!found) {\n return false;\n }\n\n // While it'd be nice to use named regex groups to extract path parameters from the URL and\n // match them up with the variables that we have present in it, JS unfortunately doesn't\n // support having the groups duplicated. So instead of doing that we need to re-regex the\n // server URL, this time splitting on the path parameters -- this way we'll be able to\n // extract the parameter names and match them up with the matched server that we obtained\n // above.\n const variables: Record<string, number | string> = {};\n Array.from(server.url.matchAll(SERVER_VARIABLE_REGEX)).forEach((variable, y) => {\n variables[variable[1]] = found[y + 1];\n });\n\n return {\n selected: i,\n variables,\n };\n })\n .filter(item => item !== false);\n\n return matchedServer.length ? matchedServer[0] : false;\n }\n\n /**\n * Replace templated variables with supplied data in a given URL.\n *\n * There are a couple ways that this will utilize variable data:\n *\n * - Supplying a `variables` object. If this is supplied, this data will always take priority.\n * This incoming `variables` object can be two formats:\n * `{ variableName: { default: 'value' } }` and `{ variableName: 'value' }`. If the former is\n * present, that will take precedence over the latter.\n * - If the supplied `variables` object is empty or does not match the current template name,\n * we fallback to the data stored in `this.user` and attempt to match against that.\n * See `getUserVariable` for some more information on how this data is pulled from `this.user`.\n *\n * If no variables supplied match up with the template name, the template name will instead be\n * used as the variable data.\n *\n * @param url A URL to swap variables into.\n * @param variables An object containing variables to swap into the URL.\n */\n replaceUrl(url: string, variables: ServerVariable = {}): string {\n // When we're constructing URLs, server URLs with trailing slashes cause problems with doing\n // lookups, so if we have one here on, slice it off.\n return stripTrailingSlash(\n url.replace(SERVER_VARIABLE_REGEX, (original: string, key: string) => {\n if (key in variables) {\n const data = variables[key];\n if (typeof data === 'object') {\n if (!Array.isArray(data) && data !== null && 'default' in data) {\n return String(data.default);\n }\n } else {\n return String(data);\n }\n }\n\n const userVariable = getUserVariable(this.user, key);\n if (userVariable) {\n return String(userVariable);\n }\n\n return original;\n }),\n );\n }\n\n /**\n * Retrieve an Operation of Webhook class instance for a given path and method.\n *\n * @param path Path to lookup and retrieve.\n * @param method HTTP Method to retrieve on the path.\n */\n operation(\n path: string,\n method: HttpMethods,\n opts: {\n /**\n * If you prefer to first look for a webhook with this path and method.\n */\n isWebhook?: boolean;\n } = {},\n ): Operation {\n // If we're unable to locate an operation for this path+method combination within the API\n // definition, we should still set an empty schema on the operation in the `Operation` class\n // because if we don't trying to use any of the accessors on that class are going to fail as\n // `schema` will be `undefined`.\n let operation: OperationObject = {\n parameters: [],\n };\n\n if (opts.isWebhook) {\n if (isOpenAPI31(this.api)) {\n const webhookPath = dereferenceRef(this.api?.webhooks?.[path], this.api);\n if (webhookPath && !isRef(webhookPath)) {\n if (webhookPath?.[method]) {\n operation = webhookPath[method];\n return new Webhook(this, path, method, operation);\n }\n }\n }\n }\n\n if (this?.api?.paths?.[path]) {\n const pathItem = dereferenceRef(this.api.paths[path], this.api);\n if (pathItem?.[method]) {\n operation = dereferenceRef(pathItem[method], this.api);\n }\n }\n\n return new Operation(this, path, method, operation);\n }\n\n findOperationMatches(url: string): PathMatches | undefined {\n const { origin, hostname } = new URL(url);\n const originRegExp = new RegExp(origin, 'i');\n const { servers, paths } = this.api;\n\n let pathName: string | undefined;\n let targetServer: ServerObject | undefined;\n let matchedServer: ServerObject | undefined;\n\n if (!servers || !servers.length) {\n // If this API definition doesn't have any servers set up let's treat it as if it were\n // https://example.com because that's the default origin we add in `normalizedUrl` under the\n // same circumstances. Without this we won't be able to match paths within what is otherwise\n // a valid OpenAPI definition.\n matchedServer = {\n url: 'https://example.com',\n };\n } else {\n matchedServer = servers.find(s => originRegExp.exec(this.replaceUrl(s.url, s.variables || {})));\n if (!matchedServer) {\n const hostnameRegExp = new RegExp(hostname);\n matchedServer = servers.find(s => hostnameRegExp.exec(this.replaceUrl(s.url, s.variables || {})));\n }\n }\n\n if (matchedServer) {\n // Instead of setting `url` directly against `matchedServer` we need to set it to an\n // intermediary object as directly modifying `matchedServer.url` will in turn update\n // `this.servers[idx].url` which we absolutely do not want to happen.\n targetServer = {\n ...matchedServer,\n url: this.replaceUrl(matchedServer.url, matchedServer.variables || {}),\n };\n\n [, pathName] = url.split(new RegExp(targetServer.url, 'i'));\n }\n\n // If we **still** haven't found a matching server, then the OAS server URL might have server\n // variables and we should loosen it up with regex to try to discover a matching path.\n //\n // For example if an OAS has `https://{region}.node.example.com/v14` set as its server URL, and\n // the `this.user` object has a `region` value of `us`, if we're trying to locate an operation\n // for https://eu.node.example.com/v14/api/esm we won't be able to because normally the users\n // `region` of `us` will be transposed in and we'll be trying to locate `eu.node.example.com`\n // in `us.node.example.com` -- which won't work.\n //\n // So what this does is transform `https://{region}.node.example.com/v14` into\n // `https://([-_a-zA-Z0-9[\\\\]]+).node.example.com/v14`, and from there we'll be able to match\n // https://eu.node.example.com/v14/api/esm and ultimately find the operation matches for\n // `/api/esm`.\n if (!matchedServer || !pathName) {\n const matchedServerAndPath = (servers || [])\n .map(server => {\n const rgx = transformURLIntoRegex(server.url);\n const found = new RegExp(rgx).exec(url);\n if (!found) {\n return;\n }\n\n return {\n matchedServer: server,\n pathName: url.split(new RegExp(rgx)).slice(-1).pop(),\n };\n })\n .filter((item): item is { matchedServer: ServerObject; pathName: string | undefined } => item !== undefined);\n\n if (!matchedServerAndPath.length) {\n return undefined;\n }\n\n pathName = matchedServerAndPath[0].pathName;\n targetServer = {\n ...matchedServerAndPath[0].matchedServer,\n };\n }\n\n if (pathName === undefined) return undefined;\n if (pathName === '') pathName = '/';\n if (!paths || !targetServer) return undefined;\n const annotatedPaths = generatePathMatches(paths, pathName, targetServer.url);\n if (!annotatedPaths.length) return undefined;\n\n return annotatedPaths;\n }\n\n /**\n * Discover an operation in an OAS from a fully-formed URL and HTTP method. Will return an object\n * containing a `url` object and another one for `operation`. This differs from `getOperation()`\n * in that it does not return an instance of the `Operation` class.\n *\n * @param url A full URL to look up.\n * @param method The cooresponding HTTP method to look up.\n */\n findOperation(url: string, method: HttpMethods): PathMatch | undefined {\n const annotatedPaths = this.findOperationMatches(url);\n if (!annotatedPaths) {\n return undefined;\n }\n\n const matches = filterPathMethods(annotatedPaths, method);\n if (!matches.length) return undefined;\n return findTargetPath(matches);\n }\n\n /**\n * Discover an operation in an OAS from a fully-formed URL without an HTTP method. Will return an\n * object containing a `url` object and another one for `operation`.\n *\n * @param url A full URL to look up.\n */\n findOperationWithoutMethod(url: string): PathMatch | undefined {\n const annotatedPaths = this.findOperationMatches(url);\n if (!annotatedPaths) {\n return undefined;\n }\n\n return findTargetPath(annotatedPaths);\n }\n\n /**\n * Retrieve an operation in an OAS from a fully-formed URL and HTTP method. Differs from\n * `findOperation` in that while this method will return an `Operation` instance,\n * `findOperation()` does not.\n *\n * @param url A full URL to look up.\n * @param method The cooresponding HTTP method to look up.\n */\n getOperation(url: string, method: HttpMethods): Operation | undefined {\n const op = this.findOperation(url, method);\n if (op === undefined) {\n return undefined;\n }\n\n return this.operation(op.url.nonNormalizedPath, method);\n }\n\n /**\n * Retrieve an operation in an OAS by an `operationId`.\n *\n * If an operation does not have an `operationId` one will be generated in place, using the\n * default behavior of `Operation.getOperationId()`, and then asserted against your query.\n *\n * Note that because `operationId`s are unique that uniqueness does include casing so the ID\n * you are looking for will be asserted as an exact match.\n *\n * @see {Operation.getOperationId()}\n * @param id The `operationId` to look up.\n */\n getOperationById(id: string): Operation | Webhook | undefined {\n let found: Operation | Webhook | undefined;\n\n Object.values(this.getPaths()).forEach(operations => {\n if (found) return;\n found = Object.values(operations).find(operation => operation.getOperationId() === id);\n });\n\n if (found) {\n return found;\n }\n\n Object.entries(this.getWebhooks()).forEach(([, webhooks]) => {\n if (found) return;\n found = Object.values(webhooks).find(webhook => webhook.getOperationId() === id);\n });\n\n return found;\n }\n\n /**\n * With an object of user information, retrieve the appropriate API auth keys from the current\n * OAS definition.\n *\n * @see {@link https://docs.readme.com/docs/passing-data-to-jwt}\n * @param user User\n * @param selectedApp The user app to retrieve an auth key for.\n */\n getAuth(user: User, selectedApp?: number | string): AuthForHAR {\n if (!this.api?.components?.securitySchemes) {\n return {};\n }\n\n return getAuth(this.api, user, selectedApp);\n }\n\n /**\n * Determine if a security scheme exists within the API definition.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#security-scheme-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-scheme-object}\n * @param name The name of the security scheme to check for.\n */\n hasSecurityScheme(name: string): boolean {\n return Boolean(this.api?.components?.securitySchemes?.[name]);\n }\n\n /**\n * Retrieve a security scheme from the API definition.\n *\n * If the found security scheme is a `$ref` pointer it will be lazily dereferenced; if the scheme\n * cannot be resolved after that process (eg. it's circular or is an invalid `$ref`) then\n * `undefined` will be returned.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#security-scheme-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-scheme-object}\n * @param name The name of the security scheme to retrieve.\n */\n getSecurityScheme(name: string): SecuritySchemeObject | undefined {\n if (!this.hasSecurityScheme(name)) {\n return undefined;\n }\n\n let scheme = this.api?.components?.securitySchemes?.[name];\n if (!scheme) return undefined;\n if (isRef(scheme)) {\n scheme = dereferenceRef(scheme, this.api);\n if (!scheme || isRef(scheme)) return undefined;\n }\n\n return scheme;\n }\n\n /**\n * Returns the `paths` object that exists in this API definition but with every `method` mapped\n * to an instance of the `Operation` class.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#openapi-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}\n */\n getPaths(): Record<string, Record<HttpMethods, Operation | Webhook>> {\n const paths: Record<string, Record<HttpMethods, Operation | Webhook>> = {};\n if (!this.api.paths) {\n return paths;\n }\n\n Object.keys(this.api.paths).forEach(path => {\n // If this is a specification extension then we should ignore it.\n if (path.startsWith('x-')) {\n return;\n }\n\n paths[path] = {} as Record<HttpMethods, Operation | Webhook>;\n\n let pathItem = this.api.paths![path];\n if (!pathItem) {\n return;\n } else if (isRef(pathItem)) {\n // Though this library is generally unaware of `$ref` pointers we're making a singular\n // exception with this accessor out of convenience.\n this.api.paths![path] = dereferenceRef(pathItem, this.api);\n pathItem = this.api.paths![path];\n if (!pathItem || isRef(pathItem)) {\n return;\n }\n }\n\n Object.keys(pathItem).forEach(method => {\n /**\n * Because a path doesn't need to contain a keyed-object of HTTP methods, we should exclude\n * anything from within the paths object that isn't a known HTTP method.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#fixed-fields-7}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-7}\n */\n if (!supportedMethods.includes(method as HttpMethods)) {\n return;\n }\n\n paths[path][method as HttpMethods] = this.operation(path, method as HttpMethods);\n });\n });\n\n return paths;\n }\n\n /**\n * Returns the `webhooks` object that exists in this API definition but with every `method`\n * mapped to an instance of the `Webhook` class.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#openapi-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}\n */\n getWebhooks(): Record<string, Record<HttpMethods, Webhook>> {\n const webhooks: Record<string, Record<HttpMethods, Webhook>> = {};\n if (!isOpenAPI31(this.api) || !this.api.webhooks) {\n return webhooks;\n }\n\n Object.keys(this.api.webhooks).forEach(id => {\n webhooks[id] = {} as Record<HttpMethods, Webhook>;\n\n const webhookPath = dereferenceRef((this.api as OpenAPIV3_1.Document).webhooks?.[id], this.api);\n if (webhookPath) {\n Object.keys(webhookPath).forEach(method => {\n if (!supportedMethods.includes(method as HttpMethods)) {\n return;\n }\n\n webhooks[id][method as HttpMethods] = this.operation(id, method as HttpMethods, {\n isWebhook: true,\n }) as Webhook;\n });\n }\n });\n\n return webhooks;\n }\n\n /**\n * Return an array of all tag names that exist on this API definition.\n *\n * If the API definition uses the `x-disable-tag-sorting` extension then tags will be returned in\n * the order they're defined.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#openapi-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}\n * @param setIfMissing If a tag is not present on an operation that operations path will be added\n * into the list of tags returned.\n */\n getTags(setIfMissing = false): string[] {\n const allTags = new Set<string>();\n\n const oasTags = this.api.tags?.map(tag => tag.name) || [];\n\n const disableTagSorting = getExtension('disable-tag-sorting', this.api);\n\n Object.entries(this.getPaths()).forEach(([path, operations]) => {\n Object.values(operations).forEach(operation => {\n const tags = operation.getTags();\n if (setIfMissing && !tags.length) {\n allTags.add(path);\n return;\n }\n\n tags.forEach(tag => {\n allTags.add(tag.name);\n });\n });\n });\n\n Object.entries(this.getWebhooks()).forEach(([path, webhooks]) => {\n Object.values(webhooks).forEach(webhook => {\n const tags = webhook.getTags();\n if (setIfMissing && !tags.length) {\n allTags.add(path);\n return;\n }\n\n tags.forEach(tag => {\n allTags.add(tag.name);\n });\n });\n });\n\n // Tags that exist only on the endpoint\n const endpointTags: string[] = [];\n // Tags that the user has defined in the `tags` array\n const tagsArray: string[] = [];\n\n // Distinguish between which tags exist in the `tags` array and which tags\n // exist only at the endpoint level. For tags that exist only at the\n // endpoint level, we'll just tack that on to the end of the sorted tags.\n if (disableTagSorting) {\n return Array.from(allTags);\n }\n\n Array.from(allTags).forEach(tag => {\n if (oasTags.includes(tag)) {\n tagsArray.push(tag);\n } else {\n endpointTags.push(tag);\n }\n });\n\n let sortedTags = tagsArray.toSorted((a, b) => {\n return oasTags.indexOf(a) - oasTags.indexOf(b);\n });\n\n sortedTags = sortedTags.concat(endpointTags);\n\n return sortedTags;\n }\n\n /**\n * Determine if a given a custom specification extension exists within the API definition.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions}\n * @param extension Specification extension to lookup.\n */\n hasExtension(extension: string): boolean {\n return hasRootExtension(extension, this.api);\n }\n\n /**\n * Retrieve a custom specification extension off of the API definition.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions}\n * @param extension Specification extension to lookup.\n */\n getExtension(extension: string | keyof Extensions, operation?: Operation): any {\n return getExtension(extension, this.api, operation);\n }\n\n /**\n * Determine if a given OpenAPI custom extension is valid or not.\n *\n * @see {@link https://docs.readme.com/docs/openapi-extensions}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions}\n * @param extension Specification extension to validate.\n * @throws\n */\n validateExtension(extension: keyof Extensions): void {\n if (this.hasExtension('x-readme')) {\n const data = this.getExtension('x-readme') satisfies Extensions;\n if (typeof data !== 'object' || Array.isArray(data) || data === null) {\n throw new TypeError('\"x-readme\" must be of type \"Object\"');\n }\n\n if (extension in data) {\n if ([CODE_SAMPLES, HEADERS, PARAMETER_ORDERING, SAMPLES_LANGUAGES].includes(extension)) {\n if (data[extension] !== undefined) {\n if (!Array.isArray(data[extension])) {\n throw new TypeError(`\"x-readme.${extension}\" must be of type \"Array\"`);\n }\n\n if (extension === PARAMETER_ORDERING) {\n validateParameterOrdering(data[extension], `x-readme.${extension}`);\n }\n }\n } else if (extension === OAUTH_OPTIONS) {\n if (typeof data[extension] !== 'object') {\n throw new TypeError(`\"x-readme.${extension}\" must be of type \"Object\"`);\n }\n } else if (typeof data[extension] !== 'boolean') {\n throw new TypeError(`\"x-readme.${extension}\" must be of type \"Boolean\"`);\n }\n }\n }\n\n // If the extension isn't grouped under `x-readme`, we need to look for them with `x-` prefixes.\n if (this.hasExtension(`x-${extension}`)) {\n const data = this.getExtension(`x-${extension}`);\n if ([CODE_SAMPLES, HEADERS, PARAMETER_ORDERING, SAMPLES_LANGUAGES].includes(extension)) {\n if (!Array.isArray(data)) {\n throw new TypeError(`\"x-${extension}\" must be of type \"Array\"`);\n }\n\n if (extension === PARAMETER_ORDERING) {\n validateParameterOrdering(data, `x-${extension}`);\n }\n } else if (extension === OAUTH_OPTIONS) {\n if (typeof data !== 'object') {\n throw new TypeError(`\"x-${extension}\" must be of type \"Object\"`);\n }\n } else if (typeof data !== 'boolean') {\n throw new TypeError(`\"x-${extension}\" must be of type \"Boolean\"`);\n }\n }\n }\n\n /**\n * Validate all of our custom or known OpenAPI extensions, throwing exceptions when necessary.\n *\n * @see {@link https://docs.readme.com/docs/openapi-extensions}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions}\n */\n validateExtensions(): void {\n Object.keys(extensionDefaults).forEach(extension => {\n this.validateExtension(extension as keyof Extensions);\n });\n }\n\n /**\n * Dereference the current API definition so it can be parsed free from the hassle of resolving\n * `$ref` schemas and circular structures.\n *\n */\n async dereference(opts?: {\n /**\n * A callback method can be supplied to be called when dereferencing is complete. Used for\n * debugging that the multi-promise handling within this method works.\n *\n * @private\n */\n cb?: () => void;\n }): Promise<(typeof this.promises)[] | boolean> {\n if (this.dereferencing.complete) {\n return new Promise(resolve => {\n resolve(true);\n });\n }\n\n if (this.dereferencing.processing) {\n return new Promise((resolve, reject) => {\n this.promises.push({ resolve, reject });\n });\n }\n\n this.dereferencing.processing = true;\n\n // Because referencing will eliminate any lineage back to the original `$ref`, information that\n // we might need at some point, we should run through all available component schemas and denote\n // what their name is so that when dereferencing happens below those names will be preserved.\n if (!this.schemasDecorated) {\n decorateComponentSchemasWithRefName(this.api);\n this.schemasDecorated = true;\n }\n\n const { api, promises } = this;\n\n const circularRefs: Set<string> = new Set();\n const dereferencingOptions = getDereferencingOptions(circularRefs);\n\n return dereference<OASDocument>(api, dereferencingOptions)\n .then((dereferenced: OASDocument) => {\n this.api = dereferenced;\n\n this.promises = promises;\n this.dereferencing = {\n processing: false,\n complete: true,\n // We need to convert our `Set` to an array in order to match the typings.\n circularRefs: [...circularRefs],\n };\n\n // Used for debugging that dereferencing promise awaiting works.\n if (opts?.cb) {\n opts?.cb();\n }\n })\n .then(() => {\n return this.promises.map(deferred => deferred.resolve());\n })\n .catch(err => {\n this.dereferencing.processing = false;\n this.promises.map(deferred => deferred.reject(err));\n throw err;\n });\n }\n\n /**\n * Determine if the current API definition has been dereferenced or not.\n *\n * @see Oas.dereference\n */\n isDereferenced(): boolean {\n return this.dereferencing.processing || this.dereferencing.complete;\n }\n\n /**\n * Retrieve any circular `$ref` pointers that maybe present within the API definition.\n *\n * This method requires that you first dereference the definition.\n *\n * @see Oas.dereference\n */\n getCircularReferences(): string[] {\n if (!this.dereferencing.complete) {\n throw new Error('.dereference() must be called first in order for this method to obtain circular references.');\n }\n\n return this.dereferencing.circularRefs;\n }\n}\n","import type { AuthForHAR, KeyedSecuritySchemeObject, OASDocument, User } from '../types.js';\n\nimport { isRef } from '../types.js';\n\nimport { dereferenceRef } from './refs.js';\n\ntype authKey = unknown | { password: number | string; user: number | string } | null;\n\n/**\n * @param user User to retrieve retrieve an auth key for.\n * @param scheme The type of security scheme that we want a key for.\n */\nfunction getKey(user: User, scheme: KeyedSecuritySchemeObject): authKey {\n switch (scheme.type) {\n case 'oauth2':\n case 'apiKey':\n return user[scheme._key] || user.apiKey || scheme['x-default'] || null;\n\n case 'http':\n if (scheme.scheme === 'basic') {\n return (\n user[scheme._key] ||\n (user.user || user.pass ? { user: user.user || null, pass: user.pass || null } : scheme['x-default']) || {\n user: null,\n pass: null,\n }\n );\n }\n\n if (scheme.scheme === 'bearer') {\n return user[scheme._key] || user.apiKey || scheme['x-default'] || null;\n }\n return null;\n\n default:\n return null;\n }\n}\n\n/**\n * Retrieve auth keys for a specific security scheme for a given user for a specific \"app\" that\n * they have configured.\n *\n * For `scheme` we're typing it to a union of `SecurityScheme` and `any` because we have handling\n * and tests for an unknown or unrecognized `type` and though it's not possible with the\n * `SecurityScheme.type` to be unrecognized it may still be possible to get an unrecognized scheme\n * with this method in the wild as we have API definitions in our database that were ingested\n * before we had good validation in place.\n *\n * @param user User\n * @param scheme Security scheme to get auth keys for.\n * @param selectedApp The user app to retrieve an auth key for.\n */\nexport function getByScheme(\n user: User,\n scheme = {} as KeyedSecuritySchemeObject,\n selectedApp?: number | string,\n): authKey {\n if (user?.keys?.length) {\n if (selectedApp) {\n const userKey = user.keys.find(k => k.name === selectedApp);\n if (!userKey) {\n return null;\n }\n\n return getKey(userKey, scheme);\n }\n\n return getKey(user.keys[0], scheme);\n }\n\n return getKey(user, scheme);\n}\n\n/**\n * Retrieve auth keys for an API definition from a given user for a specific \"app\" that they have\n * configured.\n *\n * @param api API definition\n * @param user User\n * @param selectedApp The user app to retrieve an auth key for.\n */\nexport function getAuth(api: OASDocument, user: User, selectedApp?: number | string): AuthForHAR {\n return Object.keys(api?.components?.securitySchemes || {})\n .map(scheme => {\n const securityScheme = dereferenceRef(api.components?.securitySchemes?.[scheme], api);\n if (!securityScheme || isRef(securityScheme)) {\n // If this security scheme is invalid or an unresolvable `$ref` pointer then we should skip\n // it.\n return false;\n }\n\n return {\n [scheme]: getByScheme(\n user,\n {\n ...securityScheme,\n _key: scheme,\n },\n selectedApp,\n ),\n };\n })\n .filter((item): item is AuthForHAR => item !== undefined)\n .reduce((prev, next) => Object.assign(prev, next), {});\n}\n","import type { User } from '../types.js';\n\n/**\n * Retrieve a user variable off of a given user.\n *\n * @see {@link https://docs.readme.com/docs/passing-data-to-jwt}\n * @param user The user to get a user variable for.\n * @param property The name of the variable to retrieve.\n * @param selectedApp The user app to retrieve an auth key for.\n */\nexport default function getUserVariable(user: User, property: string, selectedApp?: number | string): unknown {\n let key: User | undefined = user;\n\n if ('keys' in user && Array.isArray(user.keys) && user.keys.length) {\n if (selectedApp) {\n key = user.keys.find(k => k.name === selectedApp);\n } else {\n key = user.keys[0];\n }\n }\n\n return key?.[property] || user[property] || null;\n}\n","import type { HttpMethods, OASDocument, PathsObject } from '../types';\nimport type { Match, ParamData } from 'path-to-regexp';\n\nimport { match, pathToRegexp } from 'path-to-regexp';\n\nimport { SERVER_VARIABLE_REGEX } from '../utils';\n\nexport interface PathMatch {\n match?: Match<ParamData>;\n operation: PathsObject;\n url: {\n method?: HttpMethods;\n nonNormalizedPath: string;\n origin: string;\n path: string;\n slugs: Record<string, string>;\n };\n}\n\nexport type PathMatches = PathMatch[];\n\nexport function stripTrailingSlash(url: string): string {\n if (url[url.length - 1] === '/') {\n return url.slice(0, -1);\n }\n\n return url;\n}\n\nfunction ensureProtocol(url: string) {\n // Add protocol to urls starting with // e.g. //example.com\n // This is because httpsnippet throws a HARError when it doesnt have a protocol\n if (url.match(/^\\/\\//)) {\n return `https:${url}`;\n }\n\n // Add protocol to urls with no // within them\n // This is because httpsnippet throws a HARError when it doesnt have a protocol\n if (!url.match(/\\/\\//)) {\n return `https://${url}`;\n }\n\n return url;\n}\n\n/**\n * Normalize a OpenAPI server URL by ensuring that it has a proper HTTP protocol and doesn't have a\n * trailing slash.\n *\n * @param api The API definition that we're processing.\n * @param selected The index of the `servers` array in the API definition that we want to normalize.\n */\nexport function normalizedURL(api: OASDocument, selected: number): string {\n const exampleDotCom = 'https://example.com';\n let url: string | undefined;\n try {\n url = api.servers?.[selected].url;\n // This is to catch the case where servers = [{}]\n if (!url) throw new Error('no url');\n\n // Stripping the '/' off the end\n url = stripTrailingSlash(url);\n\n // Check if the URL is just a path a missing an origin, for example `/api/v3`. If so, then make\n // `example.com` the origin to avoid it becoming something invalid like `https:///api/v3`.\n // RM-1044\n if (url.startsWith('/') && !url.startsWith('//')) {\n const urlWithOrigin = new URL(exampleDotCom);\n urlWithOrigin.pathname = url;\n url = urlWithOrigin.href;\n }\n } catch {\n url = exampleDotCom;\n }\n\n return ensureProtocol(url);\n}\n\n/**\n * With a URL that may contain server variables, transform those server variables into regex that\n * we can query against.\n *\n * For example, when given `https://{region}.node.example.com/v14` this will return back:\n *\n * https://([-_a-zA-Z0-9:.[\\\\]]+).node.example.com/v14\n *\n * @param url URL to transform\n */\nexport function transformURLIntoRegex(url: string): string {\n return stripTrailingSlash(url.replace(SERVER_VARIABLE_REGEX, '([-_a-zA-Z0-9:.[\\\\]]+)'));\n}\n\n/**\n * Normalize a path so that we can use it with `path-to-regexp` to do operation lookups.\n *\n * @param path Path to normalize.\n */\nfunction normalizePath(path: string) {\n return (\n path\n // This regex transforms `{pathParam}` into `:pathParam` so we can regex against it. We're\n // also handling quirks here like if there's an optional proceeding or trailing curly bracket\n // (`{{pathParam}` or `{pathParam}}`) as any unescaped curlys, which would be present in\n // `:pathParam}`, will throw a regex exception.\n // oxlint-disable-next-line no-unused-vars\n .replace(/({?){(.*?)}(}?)/g, (str, ...args) => {\n // If a path contains a path parameter with hyphens, like `:dlc-release`, when it's regexd\n // with `path-to-regexp` it match against the `:dlc` portion of the parameter, breaking all\n // matching against the full path.\n //\n // For example on `/games/:game/dlc/:dlc-release` the regex that's actually used to search\n // against a path like `/games/destiny-2/dlc/witch-queen` is the following:\n // /^\\/games(?:\\/([^\\/#\\?]+?))\\/dlc(?:\\/([^\\/#\\?]+?))-release[\\/#\\?]?$/i\n //\n // However if `:dlc-release` is rewritten to `:dlcrelease` we end up with a functional\n // regex: /^\\/games(?:\\/([^\\/#\\?]+?))\\/dlc(?:\\/([^\\/#\\?]+?))[\\/#\\?]?$/i.\n return `:${args[1].replace('-', '')}`;\n })\n\n // In addition to transforming `{pathParam}` into `:pathParam` we also need to escape cases\n // where a non-variabled colon is next to a variabled-colon because if we don't then\n // `path-to-regexp` won't be able to correct identify where the variable starts.\n //\n // For example if the URL is `/post/:param1::param2` we'll be escaping it to\n // `/post/:param1\\::param2`.\n .replace(/::/, '\\\\::')\n\n // We also need to escape question marks too because they're treated as regex modifiers.\n .split('?')[0]\n );\n}\n\n/**\n * Generate path matches for a given path and origin on a set of OpenAPI path objects.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#paths-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#paths-object}\n * @param paths The OpenAPI Paths Object to process.\n * @param pathName Path to look for a match.\n * @param origin The origin that we're matching against.\n */\nexport function generatePathMatches(paths: PathsObject, pathName: string, origin: string): PathMatches {\n const prunedPathName = pathName.split('?')[0];\n const matches: PathMatches = Object.keys(paths)\n .map(path => {\n const cleanedPath = normalizePath(path);\n\n let matchResult: PathMatch['match'];\n try {\n const matchStatement = match(cleanedPath, { decode: decodeURIComponent });\n matchResult = matchStatement(prunedPathName);\n } catch {\n // If path matching fails for whatever reason (maybe they have a malformed path parameter)\n // then we shouldn't also fail.\n return false;\n }\n\n const slugs: Record<string, string> = {};\n\n if (matchResult && Object.keys(matchResult.params).length) {\n Object.keys(matchResult.params).forEach(param => {\n slugs[`:${param}`] = (matchResult.params as Record<string, string>)[param];\n });\n }\n\n return {\n url: {\n origin,\n path: cleanedPath.replace(/\\\\::/, '::'),\n nonNormalizedPath: path,\n slugs,\n },\n operation: paths[path] as PathsObject,\n match: matchResult,\n } satisfies PathMatch;\n })\n .filter(item => item !== false);\n\n return matches.filter(p => p.match);\n}\n\n/**\n * @param pathMatches Array of path matches to filter down.\n * @param targetMethod HTTP method to look for.\n * @returns Filtered down path matches.\n */\nexport function filterPathMethods(pathMatches: PathMatches, targetMethod: HttpMethods): PathMatch[] {\n const regExp = pathToRegexp(targetMethod);\n return pathMatches\n .map(p => {\n const captures = Object.keys(p.operation).filter(r => regExp.regexp.exec(r));\n\n if (captures.length) {\n const method = captures[0];\n p.url.method = method.toUpperCase() as HttpMethods;\n\n return {\n url: p.url,\n operation: p.operation[method],\n };\n }\n\n return false;\n })\n .filter((item): item is PathMatch => Boolean(item));\n}\n\n/**\n * @param pathMatches URL and PathsObject matches to narrow down to find a target path.\n * @returns An object containing matches that were discovered in the API definition.\n */\nexport function findTargetPath(pathMatches: PathMatch[]): PathMatch | undefined {\n if (!pathMatches.length) {\n return undefined;\n }\n\n let minCount = Object.keys(pathMatches[0].url.slugs).length;\n let found: PathMatch | undefined;\n\n for (let m = 0; m < pathMatches.length; m += 1) {\n const selection = pathMatches[m];\n const paramCount = Object.keys(selection.url.slugs).length;\n if (paramCount <= minCount) {\n minCount = paramCount;\n found = selection;\n }\n }\n\n return found;\n}\n"]}
|
|
@@ -6,7 +6,7 @@ var _chunkAYA3UT4Lcjs = require('./chunk-AYA3UT4L.cjs');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkNR45NABAcjs = require('./chunk-NR45NABA.cjs');
|
|
10
10
|
|
|
11
11
|
// src/lib/matches-mimetype.ts
|
|
12
12
|
function matchesMediaType(types2, mediaType) {
|
|
@@ -118,7 +118,7 @@ function dereferenceRef(value, definition, seenRefs = /* @__PURE__ */ new Set())
|
|
|
118
118
|
if (value === void 0) {
|
|
119
119
|
return void 0;
|
|
120
120
|
}
|
|
121
|
-
if (
|
|
121
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, value)) {
|
|
122
122
|
if (!definition) {
|
|
123
123
|
return value;
|
|
124
124
|
}
|
|
@@ -129,7 +129,7 @@ function dereferenceRef(value, definition, seenRefs = /* @__PURE__ */ new Set())
|
|
|
129
129
|
seenRefs.add(ref);
|
|
130
130
|
try {
|
|
131
131
|
const dereferenced = findRef(ref, definition);
|
|
132
|
-
if (
|
|
132
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, dereferenced)) {
|
|
133
133
|
return dereferenceRef(dereferenced, definition, seenRefs);
|
|
134
134
|
}
|
|
135
135
|
return {
|
|
@@ -144,10 +144,10 @@ function dereferenceRef(value, definition, seenRefs = /* @__PURE__ */ new Set())
|
|
|
144
144
|
function dereferenceRefDeep(value, definition, seenRefs = /* @__PURE__ */ new Set()) {
|
|
145
145
|
if (value === null || value === void 0) return value;
|
|
146
146
|
if (typeof value !== "object") return value;
|
|
147
|
-
if (
|
|
147
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, value)) {
|
|
148
148
|
if (!definition) return value;
|
|
149
149
|
const resolved = dereferenceRef(value, definition, seenRefs);
|
|
150
|
-
if (
|
|
150
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, resolved)) return resolved;
|
|
151
151
|
return dereferenceRefDeep(resolved, definition, seenRefs);
|
|
152
152
|
}
|
|
153
153
|
if (Array.isArray(value)) {
|
|
@@ -180,7 +180,7 @@ function collectRefsInSchema(schema) {
|
|
|
180
180
|
const refs = /* @__PURE__ */ new Set();
|
|
181
181
|
if (!schema || typeof schema !== "object") return refs;
|
|
182
182
|
const obj = schema;
|
|
183
|
-
if (
|
|
183
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, obj)) {
|
|
184
184
|
refs.add(obj.$ref);
|
|
185
185
|
}
|
|
186
186
|
for (const value of Object.values(obj)) {
|
|
@@ -321,7 +321,7 @@ function allOfReferencesSchema(schema, targetSchemaName) {
|
|
|
321
321
|
if (!schema || typeof schema !== "object") return false;
|
|
322
322
|
if (!("allOf" in schema) || !Array.isArray(schema.allOf)) return false;
|
|
323
323
|
return schema.allOf.some((item) => {
|
|
324
|
-
if (
|
|
324
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, item)) {
|
|
325
325
|
const refParts = item.$ref.split("/");
|
|
326
326
|
const refSchemaName = refParts[refParts.length - 1];
|
|
327
327
|
return refSchemaName === targetSchemaName;
|
|
@@ -458,7 +458,7 @@ function isPendingSchema(s) {
|
|
|
458
458
|
return isObject(s) && "__pending" in s && s.__pending === true;
|
|
459
459
|
}
|
|
460
460
|
function getSchemaVersionString(schema, api) {
|
|
461
|
-
if (
|
|
461
|
+
if (_chunkNR45NABAcjs.isOpenAPI30.call(void 0, api)) {
|
|
462
462
|
return "http://json-schema.org/draft-04/schema#";
|
|
463
463
|
}
|
|
464
464
|
if (schema.$schema) {
|
|
@@ -474,7 +474,7 @@ function isPolymorphicSchema(schema) {
|
|
|
474
474
|
}
|
|
475
475
|
function shouldFoldParentItemsIntoPolymorphBranch(item) {
|
|
476
476
|
if (!isObject(item)) return false;
|
|
477
|
-
if (
|
|
477
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, item)) return true;
|
|
478
478
|
const branch = item;
|
|
479
479
|
if (!("type" in branch) || branch.type === void 0) return true;
|
|
480
480
|
if (!hasSchemaType(branch, "array")) return false;
|
|
@@ -497,7 +497,7 @@ function inlinePropertyRefsForMerge(schema, usedSchemas, refLogger, conflictPath
|
|
|
497
497
|
for (const key of Object.keys(out.properties)) {
|
|
498
498
|
const path = currentPath ? `${currentPath}.${key}` : key;
|
|
499
499
|
const val = out.properties[key];
|
|
500
|
-
if (
|
|
500
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, val)) {
|
|
501
501
|
if (val.$ref.startsWith("#/paths/")) {
|
|
502
502
|
refLogger(val.$ref, "ref");
|
|
503
503
|
continue;
|
|
@@ -577,12 +577,12 @@ function inlineAllOfRefsDeep(schema, usedSchemas) {
|
|
|
577
577
|
for (let i = 0; i < schema[keyword].length; i++) {
|
|
578
578
|
const option = schema[keyword][i];
|
|
579
579
|
if (!option || typeof option !== "object") continue;
|
|
580
|
-
if (
|
|
580
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, option) && option.$ref.includes(allOfKey)) {
|
|
581
581
|
const resolved = usedSchemas.get(option.$ref);
|
|
582
582
|
if (resolved !== void 0 && !isPendingSchema(resolved)) {
|
|
583
583
|
schema[keyword][i] = structuredClone(resolved);
|
|
584
584
|
}
|
|
585
|
-
} else if (!
|
|
585
|
+
} else if (!_chunkNR45NABAcjs.isRef.call(void 0, option)) {
|
|
586
586
|
inlineAllOfRefsDeep(option, usedSchemas);
|
|
587
587
|
}
|
|
588
588
|
}
|
|
@@ -590,12 +590,12 @@ function inlineAllOfRefsDeep(schema, usedSchemas) {
|
|
|
590
590
|
if ("properties" in schema && typeof schema.properties === "object" && schema.properties !== null) {
|
|
591
591
|
for (const key of Object.keys(schema.properties)) {
|
|
592
592
|
const val = schema.properties[key];
|
|
593
|
-
if (
|
|
593
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, val) && val.$ref.includes(allOfKey)) {
|
|
594
594
|
const resolved = usedSchemas.get(val.$ref);
|
|
595
595
|
if (resolved !== void 0 && !isPendingSchema(resolved)) {
|
|
596
596
|
schema.properties[key] = structuredClone(resolved);
|
|
597
597
|
}
|
|
598
|
-
} else if (val && typeof val === "object" && !Array.isArray(val) && !
|
|
598
|
+
} else if (val && typeof val === "object" && !Array.isArray(val) && !_chunkNR45NABAcjs.isRef.call(void 0, val)) {
|
|
599
599
|
inlineAllOfRefsDeep(val, usedSchemas);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
@@ -620,7 +620,7 @@ function resolveAndCacheRefSchema({
|
|
|
620
620
|
if (_optionalChain([refsEmittedAsStub, 'optionalAccess', _20 => _20.has, 'call', _21 => _21(ref)])) {
|
|
621
621
|
return { $ref: ref };
|
|
622
622
|
}
|
|
623
|
-
if (!
|
|
623
|
+
if (!_chunkNR45NABAcjs.isRef.call(void 0, existing)) {
|
|
624
624
|
return structuredClone(existing);
|
|
625
625
|
}
|
|
626
626
|
return { $ref: ref };
|
|
@@ -634,7 +634,7 @@ function resolveAndCacheRefSchema({
|
|
|
634
634
|
let resolved;
|
|
635
635
|
try {
|
|
636
636
|
const dereferenced = dereferenceRef(schema, definition, seenRefs);
|
|
637
|
-
if (
|
|
637
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, dereferenced)) {
|
|
638
638
|
refLogger(dereferenced.$ref, "ref");
|
|
639
639
|
let converted2;
|
|
640
640
|
try {
|
|
@@ -668,7 +668,7 @@ function resolveAndCacheRefSchema({
|
|
|
668
668
|
}
|
|
669
669
|
try {
|
|
670
670
|
const dereferenced = dereferenceRef(schema, definition, seenRefs);
|
|
671
|
-
if (
|
|
671
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, dereferenced)) {
|
|
672
672
|
let converted2;
|
|
673
673
|
try {
|
|
674
674
|
const pointer = ref.startsWith("#") ? decodeURIComponent(ref.substring(1)) : ref;
|
|
@@ -739,7 +739,7 @@ function searchForValueByPropAndPointer(property, pointer, schemas = []) {
|
|
|
739
739
|
}
|
|
740
740
|
function toJSONSchema(data, opts) {
|
|
741
741
|
let schema = data === true ? {} : { ...data };
|
|
742
|
-
const schemaAdditionalProperties =
|
|
742
|
+
const schemaAdditionalProperties = _chunkNR45NABAcjs.isSchema.call(void 0, schema) ? schema.additionalProperties : null;
|
|
743
743
|
const {
|
|
744
744
|
addEnumsToDescriptions,
|
|
745
745
|
currentLocation,
|
|
@@ -784,7 +784,7 @@ function toJSONSchema(data, opts) {
|
|
|
784
784
|
usedSchemas,
|
|
785
785
|
refsEmittedAsStub
|
|
786
786
|
};
|
|
787
|
-
if (
|
|
787
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, schema)) {
|
|
788
788
|
if (definition && usedSchemas) {
|
|
789
789
|
const resolved = resolveAndCacheRefSchema({
|
|
790
790
|
schema,
|
|
@@ -797,6 +797,12 @@ function toJSONSchema(data, opts) {
|
|
|
797
797
|
});
|
|
798
798
|
const { $ref: _$ref, properties: _propertiesWithRef, ...siblings } = schema;
|
|
799
799
|
if (Object.keys(siblings).length > 0) {
|
|
800
|
+
if ("example" in siblings) {
|
|
801
|
+
if (isPrimitive(siblings.example)) {
|
|
802
|
+
siblings.examples = [siblings.example];
|
|
803
|
+
}
|
|
804
|
+
delete siblings.example;
|
|
805
|
+
}
|
|
800
806
|
return { ...resolved, ...siblings };
|
|
801
807
|
}
|
|
802
808
|
return resolved;
|
|
@@ -804,7 +810,7 @@ function toJSONSchema(data, opts) {
|
|
|
804
810
|
refLogger(schema.$ref, "ref");
|
|
805
811
|
return schema;
|
|
806
812
|
}
|
|
807
|
-
if (
|
|
813
|
+
if (_chunkNR45NABAcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild)) {
|
|
808
814
|
if ("allOf" in schema && Array.isArray(schema.allOf)) {
|
|
809
815
|
if ("properties" in schema && schema.properties !== void 0 && typeof schema.properties === "object" && schema.properties !== null && !Array.isArray(schema.properties)) {
|
|
810
816
|
const preprocessed = {};
|
|
@@ -819,9 +825,9 @@ function toJSONSchema(data, opts) {
|
|
|
819
825
|
});
|
|
820
826
|
if (hideReadOnlyProperties || hideWriteOnlyProperties) {
|
|
821
827
|
let resolvedRefIsEmpty = false;
|
|
822
|
-
if (
|
|
828
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, converted) && usedSchemas) {
|
|
823
829
|
const cached = usedSchemas.get(converted.$ref);
|
|
824
|
-
if (cached && !
|
|
830
|
+
if (cached && !_chunkNR45NABAcjs.isRef.call(void 0, cached) && !isPendingSchema(cached) && Object.keys(cached).length === 0) {
|
|
825
831
|
resolvedRefIsEmpty = true;
|
|
826
832
|
}
|
|
827
833
|
}
|
|
@@ -842,7 +848,7 @@ function toJSONSchema(data, opts) {
|
|
|
842
848
|
const allOfOptions = allOfSchemas.length > 1 ? { ...polyOptions, refLogger: () => {
|
|
843
849
|
} } : polyOptions;
|
|
844
850
|
allOfSchemas = allOfSchemas.map((item) => {
|
|
845
|
-
if (
|
|
851
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, item)) {
|
|
846
852
|
if (Object.keys(item).length === 1) {
|
|
847
853
|
return resolveAndCacheRefSchema({
|
|
848
854
|
schema: item,
|
|
@@ -896,7 +902,7 @@ function toJSONSchema(data, opts) {
|
|
|
896
902
|
};
|
|
897
903
|
const requiredSet = new Set(Array.isArray(fallback.required) ? fallback.required : []);
|
|
898
904
|
for (const branch of branches) {
|
|
899
|
-
if (!branch || typeof branch !== "object" ||
|
|
905
|
+
if (!branch || typeof branch !== "object" || _chunkNR45NABAcjs.isRef.call(void 0, branch)) continue;
|
|
900
906
|
if (fallback.type === void 0 && "type" in branch && branch.type !== void 0) {
|
|
901
907
|
fallback.type = branch.type;
|
|
902
908
|
}
|
|
@@ -927,7 +933,7 @@ function toJSONSchema(data, opts) {
|
|
|
927
933
|
collectRefsInSchema(schema).forEach((ref) => {
|
|
928
934
|
refLogger(ref, "ref");
|
|
929
935
|
});
|
|
930
|
-
if (
|
|
936
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, schema)) {
|
|
931
937
|
refLogger(schema.$ref, "ref");
|
|
932
938
|
return schema;
|
|
933
939
|
}
|
|
@@ -985,7 +991,7 @@ function toJSONSchema(data, opts) {
|
|
|
985
991
|
delete childSchema.anyOf;
|
|
986
992
|
}
|
|
987
993
|
}
|
|
988
|
-
if (definition && usedSchemas &&
|
|
994
|
+
if (definition && usedSchemas && _chunkNR45NABAcjs.isRef.call(void 0, childSchema)) {
|
|
989
995
|
const resolved = usedSchemas.get(childSchema.$ref);
|
|
990
996
|
if (resolved && typeof resolved === "object" && !isPendingSchema(resolved)) {
|
|
991
997
|
if ("discriminator" in resolved) {
|
|
@@ -1106,7 +1112,7 @@ function toJSONSchema(data, opts) {
|
|
|
1106
1112
|
}
|
|
1107
1113
|
}
|
|
1108
1114
|
}
|
|
1109
|
-
if (
|
|
1115
|
+
if (_chunkNR45NABAcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild)) {
|
|
1110
1116
|
if ("default" in schema && isObject(schema.default)) {
|
|
1111
1117
|
prevDefaultSchemas.push({ default: schema.default });
|
|
1112
1118
|
}
|
|
@@ -1130,7 +1136,7 @@ function toJSONSchema(data, opts) {
|
|
|
1130
1136
|
let currentExample = example;
|
|
1131
1137
|
if (name === "$ref") {
|
|
1132
1138
|
currentExample = dereferenceRef({ $ref: currentExample }, definition, seenRefs);
|
|
1133
|
-
if (!currentExample ||
|
|
1139
|
+
if (!currentExample || _chunkNR45NABAcjs.isRef.call(void 0, currentExample)) {
|
|
1134
1140
|
refLogger(currentExample.$ref, "ref");
|
|
1135
1141
|
return;
|
|
1136
1142
|
}
|
|
@@ -1170,7 +1176,7 @@ function toJSONSchema(data, opts) {
|
|
|
1170
1176
|
}
|
|
1171
1177
|
if (hasSchemaType(schema, "array")) {
|
|
1172
1178
|
if ("items" in schema && schema.items !== void 0) {
|
|
1173
|
-
if (!(definition && usedSchemas) && !Array.isArray(schema.items) && Object.keys(schema.items).length === 1 &&
|
|
1179
|
+
if (!(definition && usedSchemas) && !Array.isArray(schema.items) && Object.keys(schema.items).length === 1 && _chunkNR45NABAcjs.isRef.call(void 0, schema.items)) {
|
|
1174
1180
|
refLogger(schema.items.$ref, "ref");
|
|
1175
1181
|
} else if (schema.items !== true) {
|
|
1176
1182
|
schema.items = toJSONSchema(schema.items, {
|
|
@@ -1208,9 +1214,9 @@ function toJSONSchema(data, opts) {
|
|
|
1208
1214
|
let propShouldBeUpdated = true;
|
|
1209
1215
|
if (hideReadOnlyProperties || hideWriteOnlyProperties) {
|
|
1210
1216
|
let resolvedRefIsEmpty = false;
|
|
1211
|
-
if (
|
|
1217
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, newPropSchema) && usedSchemas) {
|
|
1212
1218
|
const cached = usedSchemas.get(newPropSchema.$ref);
|
|
1213
|
-
if (cached && !
|
|
1219
|
+
if (cached && !_chunkNR45NABAcjs.isRef.call(void 0, cached) && !isPendingSchema(cached) && Object.keys(cached).length === 0) {
|
|
1214
1220
|
resolvedRefIsEmpty = true;
|
|
1215
1221
|
}
|
|
1216
1222
|
}
|
|
@@ -1258,7 +1264,7 @@ function toJSONSchema(data, opts) {
|
|
|
1258
1264
|
}
|
|
1259
1265
|
}
|
|
1260
1266
|
}
|
|
1261
|
-
if (
|
|
1267
|
+
if (_chunkNR45NABAcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild) && globalDefaults && Object.keys(globalDefaults).length > 0 && currentLocation) {
|
|
1262
1268
|
try {
|
|
1263
1269
|
const userJwtDefault = _jsonpointer2.default.get(globalDefaults, currentLocation);
|
|
1264
1270
|
if (userJwtDefault) {
|
|
@@ -1280,7 +1286,7 @@ function toJSONSchema(data, opts) {
|
|
|
1280
1286
|
schema.default = foundDefault;
|
|
1281
1287
|
}
|
|
1282
1288
|
}
|
|
1283
|
-
if (
|
|
1289
|
+
if (_chunkNR45NABAcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild) && "enum" in schema && Array.isArray(schema.enum)) {
|
|
1284
1290
|
schema.enum = Array.from(new Set(schema.enum));
|
|
1285
1291
|
if (addEnumsToDescriptions) {
|
|
1286
1292
|
const enums = schema.enum.filter((v) => v !== void 0 && (typeof v !== "string" || v.trim() !== "")).map((str) => `\`${str}\``).join(" ");
|
|
@@ -1389,9 +1395,9 @@ function getParametersAsJSONSchema(operation, api, opts) {
|
|
|
1389
1395
|
examples: Object.values(mediaTypeObject.examples || {}).map((ex) => {
|
|
1390
1396
|
let example = ex;
|
|
1391
1397
|
if (!example) return;
|
|
1392
|
-
if (
|
|
1398
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, example)) {
|
|
1393
1399
|
example = dereferenceRef(example, operation.api);
|
|
1394
|
-
if (!example ||
|
|
1400
|
+
if (!example || _chunkNR45NABAcjs.isRef.call(void 0, example)) return;
|
|
1395
1401
|
}
|
|
1396
1402
|
return example.value;
|
|
1397
1403
|
}).filter((item) => item !== void 0)
|
|
@@ -1518,7 +1524,7 @@ function getParametersAsJSONSchema(operation, api, opts) {
|
|
|
1518
1524
|
}
|
|
1519
1525
|
try {
|
|
1520
1526
|
const resolved = dereferenceRef({ $ref: ref }, api, seenRefs);
|
|
1521
|
-
if (
|
|
1527
|
+
if (_chunkNR45NABAcjs.isRef.call(void 0, resolved)) return;
|
|
1522
1528
|
const converted = toJSONSchema(structuredClone(resolved), {
|
|
1523
1529
|
...baseSchemaOptions,
|
|
1524
1530
|
usedSchemas,
|
|
@@ -1571,4 +1577,4 @@ var SERVER_VARIABLE_REGEX = /{([-_a-zA-Z0-9:.[\]]+)}/g;
|
|
|
1571
1577
|
|
|
1572
1578
|
|
|
1573
1579
|
exports.isObject = isObject; exports.isPrimitive = isPrimitive; exports.decorateComponentSchemasWithRefName = decorateComponentSchemasWithRefName; exports.decodePointer = decodePointer; exports.dereferenceRef = dereferenceRef; exports.dereferenceRefDeep = dereferenceRefDeep; exports.getDereferencingOptions = getDereferencingOptions; exports.collectRefsInSchema = collectRefsInSchema; exports.filterRequiredRefsToReferenced = filterRequiredRefsToReferenced; exports.mergeReferencedSchemasIntoRoot = mergeReferencedSchemasIntoRoot; exports.matches_mimetype_default = matches_mimetype_default; exports.getParameterContentType = getParameterContentType; exports.cloneObject = cloneObject; exports.applyDiscriminatorOneOfToUsedSchemas = applyDiscriminatorOneOfToUsedSchemas; exports.getSchemaVersionString = getSchemaVersionString; exports.toJSONSchema = toJSONSchema; exports.types = types; exports.getParametersAsJSONSchema = getParametersAsJSONSchema; exports.supportedMethods = supportedMethods; exports.SERVER_VARIABLE_REGEX = SERVER_VARIABLE_REGEX;
|
|
1574
|
-
//# sourceMappingURL=chunk-
|
|
1580
|
+
//# sourceMappingURL=chunk-YSYK5CMA.cjs.map
|