oas 37.0.0 → 37.2.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/{chunk-AYA3UT4L.cjs → chunk-6HXOZ5GY.cjs} +6 -3
- package/dist/chunk-6HXOZ5GY.cjs.map +1 -0
- package/dist/{chunk-IEN4GZPF.js → chunk-6QP66C5V.js} +54 -58
- package/dist/chunk-6QP66C5V.js.map +1 -0
- package/dist/{chunk-UKD63LKG.cjs → chunk-GPOPN7TQ.cjs} +55 -59
- package/dist/chunk-GPOPN7TQ.cjs.map +1 -0
- package/dist/{chunk-WIVQX3DA.js → chunk-LOR5XCEP.js} +3 -3
- package/dist/{chunk-S27IGTVG.js → chunk-LZNTJ4ZR.js} +5 -2
- package/dist/chunk-LZNTJ4ZR.js.map +1 -0
- package/dist/{chunk-GS43VKJH.cjs → chunk-YCSVUVAC.cjs} +72 -72
- package/dist/{chunk-GS43VKJH.cjs.map → chunk-YCSVUVAC.cjs.map} +1 -1
- package/dist/extensions.cjs +4 -2
- package/dist/extensions.cjs.map +1 -1
- package/dist/extensions.d.cts +1 -1
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +3 -1
- package/dist/index.cjs +40 -40
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +3 -3
- package/dist/operation/index.cjs +4 -4
- package/dist/operation/index.js +3 -3
- package/dist/reducer/index.cjs +8 -8
- package/dist/reducer/index.js +2 -2
- package/dist/utils.cjs +3 -3
- package/dist/utils.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-AYA3UT4L.cjs.map +0 -1
- package/dist/chunk-IEN4GZPF.js.map +0 -1
- package/dist/chunk-S27IGTVG.js.map +0 -1
- package/dist/chunk-UKD63LKG.cjs.map +0 -1
- /package/dist/{chunk-WIVQX3DA.js.map → chunk-LOR5XCEP.js.map} +0 -0
package/dist/extensions.cjs
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var _chunkAYA3UT4Lcjs = require('./chunk-AYA3UT4L.cjs');
|
|
18
17
|
|
|
18
|
+
var _chunk6HXOZ5GYcjs = require('./chunk-6HXOZ5GY.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
@@ -31,5 +31,7 @@ var _chunkAYA3UT4Lcjs = require('./chunk-AYA3UT4L.cjs');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
exports.CODE_SAMPLES = _chunk6HXOZ5GYcjs.CODE_SAMPLES; exports.DISABLE_TAG_SORTING = _chunk6HXOZ5GYcjs.DISABLE_TAG_SORTING; exports.EXPLORER_ENABLED = _chunk6HXOZ5GYcjs.EXPLORER_ENABLED; exports.HEADERS = _chunk6HXOZ5GYcjs.HEADERS; exports.INTERNAL = _chunk6HXOZ5GYcjs.INTERNAL; exports.METRICS_ENABLED = _chunk6HXOZ5GYcjs.METRICS_ENABLED; exports.OAUTH_OPTIONS = _chunk6HXOZ5GYcjs.OAUTH_OPTIONS; exports.PARAMETER_ORDERING = _chunk6HXOZ5GYcjs.PARAMETER_ORDERING; exports.PROXY_ENABLED = _chunk6HXOZ5GYcjs.PROXY_ENABLED; exports.SAMPLES_LANGUAGES = _chunk6HXOZ5GYcjs.SAMPLES_LANGUAGES; exports.SIMPLE_MODE = _chunk6HXOZ5GYcjs.SIMPLE_MODE; exports.STATUS_URL = _chunk6HXOZ5GYcjs.STATUS_URL; exports.extensionDefaults = _chunk6HXOZ5GYcjs.extensionDefaults; exports.getExtension = _chunk6HXOZ5GYcjs.getExtension; exports.hasRootExtension = _chunk6HXOZ5GYcjs.hasRootExtension; exports.validateParameterOrdering = _chunk6HXOZ5GYcjs.validateParameterOrdering;
|
|
35
37
|
//# sourceMappingURL=extensions.cjs.map
|
package/dist/extensions.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/extensions.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,
|
|
1
|
+
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/extensions.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,y7BAAC","file":"/Users/erunion/code/readme/oas/packages/oas/dist/extensions.cjs"}
|
package/dist/extensions.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as CODE_SAMPLES, D as DISABLE_TAG_SORTING, E as EXPLORER_ENABLED, b as Extensions, H as HEADERS, I as INTERNAL, M as METRICS_ENABLED, c as OAUTH_OPTIONS, P as PARAMETER_ORDERING, d as PROXY_ENABLED, S as SAMPLES_LANGUAGES, e as SIMPLE_MODE, f as
|
|
1
|
+
export { a as CODE_SAMPLES, D as DISABLE_TAG_SORTING, E as EXPLORER_ENABLED, b as Extensions, H as HEADERS, I as INTERNAL, M as METRICS_ENABLED, c as OAUTH_OPTIONS, P as PARAMETER_ORDERING, d as PROXY_ENABLED, S as SAMPLES_LANGUAGES, e as SIMPLE_MODE, f as STATUS_URL, g as extensionDefaults, h as getExtension, i as hasRootExtension, v as validateParameterOrdering } from './index.cjs';
|
|
2
2
|
import './types.cjs';
|
|
3
3
|
import 'path-to-regexp';
|
|
4
4
|
import './get-parameters-as-json-schema-Cbp85O99.cjs';
|
package/dist/extensions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as CODE_SAMPLES, D as DISABLE_TAG_SORTING, E as EXPLORER_ENABLED, b as Extensions, H as HEADERS, I as INTERNAL, M as METRICS_ENABLED, c as OAUTH_OPTIONS, P as PARAMETER_ORDERING, d as PROXY_ENABLED, S as SAMPLES_LANGUAGES, e as SIMPLE_MODE, f as
|
|
1
|
+
export { a as CODE_SAMPLES, D as DISABLE_TAG_SORTING, E as EXPLORER_ENABLED, b as Extensions, H as HEADERS, I as INTERNAL, M as METRICS_ENABLED, c as OAUTH_OPTIONS, P as PARAMETER_ORDERING, d as PROXY_ENABLED, S as SAMPLES_LANGUAGES, e as SIMPLE_MODE, f as STATUS_URL, g as extensionDefaults, h as getExtension, i as hasRootExtension, v as validateParameterOrdering } from './index.js';
|
|
2
2
|
import './types.js';
|
|
3
3
|
import 'path-to-regexp';
|
|
4
4
|
import './get-parameters-as-json-schema-BZjPPE3y.js';
|
package/dist/extensions.js
CHANGED
|
@@ -10,11 +10,12 @@ import {
|
|
|
10
10
|
PROXY_ENABLED,
|
|
11
11
|
SAMPLES_LANGUAGES,
|
|
12
12
|
SIMPLE_MODE,
|
|
13
|
+
STATUS_URL,
|
|
13
14
|
extensionDefaults,
|
|
14
15
|
getExtension,
|
|
15
16
|
hasRootExtension,
|
|
16
17
|
validateParameterOrdering
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LZNTJ4ZR.js";
|
|
18
19
|
export {
|
|
19
20
|
CODE_SAMPLES,
|
|
20
21
|
DISABLE_TAG_SORTING,
|
|
@@ -27,6 +28,7 @@ export {
|
|
|
27
28
|
PROXY_ENABLED,
|
|
28
29
|
SAMPLES_LANGUAGES,
|
|
29
30
|
SIMPLE_MODE,
|
|
31
|
+
STATUS_URL,
|
|
30
32
|
extensionDefaults,
|
|
31
33
|
getExtension,
|
|
32
34
|
hasRootExtension,
|
package/dist/index.cjs
CHANGED
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkYCSVUVACcjs = require('./chunk-YCSVUVAC.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkGPOPN7TQcjs = require('./chunk-GPOPN7TQ.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -27,7 +27,7 @@ var _chunkUKD63LKGcjs = require('./chunk-UKD63LKG.cjs');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunk6HXOZ5GYcjs = require('./chunk-6HXOZ5GY.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -73,7 +73,7 @@ function getByScheme(user, scheme = {}, selectedApp) {
|
|
|
73
73
|
}
|
|
74
74
|
function getAuth(api, user, selectedApp) {
|
|
75
75
|
return Object.keys(_optionalChain([api, 'optionalAccess', _3 => _3.components, 'optionalAccess', _4 => _4.securitySchemes]) || {}).map((scheme) => {
|
|
76
|
-
const securityScheme =
|
|
76
|
+
const securityScheme = _chunkGPOPN7TQcjs.dereferenceRef.call(void 0, _optionalChain([api, 'access', _5 => _5.components, 'optionalAccess', _6 => _6.securitySchemes, 'optionalAccess', _7 => _7[scheme]]), api);
|
|
77
77
|
if (!securityScheme || _chunk7PWF3F2Wcjs.isRef.call(void 0, securityScheme)) {
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
@@ -142,17 +142,17 @@ var Oas = class _Oas {
|
|
|
142
142
|
return this.api;
|
|
143
143
|
}
|
|
144
144
|
url(selected = 0, variables) {
|
|
145
|
-
const url =
|
|
145
|
+
const url = _chunkYCSVUVACcjs.normalizedURLFromServers.call(void 0, this.api.servers, selected);
|
|
146
146
|
return this.replaceUrl(url, variables || this.defaultVariables(selected)).trim();
|
|
147
147
|
}
|
|
148
148
|
variables(selected = 0) {
|
|
149
|
-
return
|
|
149
|
+
return _chunkYCSVUVACcjs.variablesFromServers.call(void 0, this.api.servers, selected);
|
|
150
150
|
}
|
|
151
151
|
defaultVariables(selected = 0) {
|
|
152
|
-
return
|
|
152
|
+
return _chunkYCSVUVACcjs.defaultVariablesFromServers.call(void 0, this.api.servers, selected, this.user);
|
|
153
153
|
}
|
|
154
154
|
splitUrl(selected = 0) {
|
|
155
|
-
return
|
|
155
|
+
return _chunkYCSVUVACcjs.splitUrlFromServers.call(void 0, this.api.servers, selected);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* With a fully composed server URL, run through our list of known OAS servers and return back
|
|
@@ -170,13 +170,13 @@ var Oas = class _Oas {
|
|
|
170
170
|
*/
|
|
171
171
|
splitVariables(baseUrl) {
|
|
172
172
|
const matchedServer = (this.api.servers || []).map((server, i) => {
|
|
173
|
-
const rgx =
|
|
173
|
+
const rgx = _chunkYCSVUVACcjs.transformURLIntoRegex.call(void 0, server.url);
|
|
174
174
|
const found = new RegExp(rgx).exec(baseUrl);
|
|
175
175
|
if (!found) {
|
|
176
176
|
return false;
|
|
177
177
|
}
|
|
178
178
|
const variables = {};
|
|
179
|
-
Array.from(server.url.matchAll(
|
|
179
|
+
Array.from(server.url.matchAll(_chunkGPOPN7TQcjs.SERVER_VARIABLE_REGEX)).forEach((variable, y) => {
|
|
180
180
|
variables[variable[1]] = found[y + 1];
|
|
181
181
|
});
|
|
182
182
|
return {
|
|
@@ -206,8 +206,8 @@ var Oas = class _Oas {
|
|
|
206
206
|
* @param variables An object containing variables to swap into the URL.
|
|
207
207
|
*/
|
|
208
208
|
replaceUrl(url, variables = {}) {
|
|
209
|
-
return
|
|
210
|
-
url.replace(
|
|
209
|
+
return _chunkYCSVUVACcjs.stripTrailingSlash.call(void 0,
|
|
210
|
+
url.replace(_chunkGPOPN7TQcjs.SERVER_VARIABLE_REGEX, (original, key) => {
|
|
211
211
|
if (key in variables) {
|
|
212
212
|
const data = variables[key];
|
|
213
213
|
if (typeof data === "object") {
|
|
@@ -218,7 +218,7 @@ var Oas = class _Oas {
|
|
|
218
218
|
return String(data);
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
const userVariable =
|
|
221
|
+
const userVariable = _chunkYCSVUVACcjs.getUserVariable.call(void 0, this.user, key);
|
|
222
222
|
if (userVariable) {
|
|
223
223
|
return String(userVariable);
|
|
224
224
|
}
|
|
@@ -238,22 +238,22 @@ var Oas = class _Oas {
|
|
|
238
238
|
};
|
|
239
239
|
if (opts.isWebhook) {
|
|
240
240
|
if (_chunk7PWF3F2Wcjs.isOpenAPI31.call(void 0, this.api)) {
|
|
241
|
-
const webhookPath =
|
|
241
|
+
const webhookPath = _chunkGPOPN7TQcjs.dereferenceRef.call(void 0, _optionalChain([this, 'access', _8 => _8.api, 'optionalAccess', _9 => _9.webhooks, 'optionalAccess', _10 => _10[path]]), this.api);
|
|
242
242
|
if (webhookPath && !_chunk7PWF3F2Wcjs.isRef.call(void 0, webhookPath)) {
|
|
243
243
|
if (_optionalChain([webhookPath, 'optionalAccess', _11 => _11[method]])) {
|
|
244
244
|
operation = webhookPath[method];
|
|
245
|
-
return new (0,
|
|
245
|
+
return new (0, _chunkYCSVUVACcjs.Webhook)(this, path, method, operation);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
if (_optionalChain([this, 'optionalAccess', _12 => _12.api, 'optionalAccess', _13 => _13.paths, 'optionalAccess', _14 => _14[path]])) {
|
|
251
|
-
const pathItem =
|
|
251
|
+
const pathItem = _chunkGPOPN7TQcjs.dereferenceRef.call(void 0, this.api.paths[path], this.api);
|
|
252
252
|
if (_optionalChain([pathItem, 'optionalAccess', _15 => _15[method]])) {
|
|
253
|
-
operation =
|
|
253
|
+
operation = _chunkGPOPN7TQcjs.dereferenceRef.call(void 0, pathItem[method], this.api);
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
return new (0,
|
|
256
|
+
return new (0, _chunkYCSVUVACcjs.Operation)(this, path, method, operation);
|
|
257
257
|
}
|
|
258
258
|
findOperationMatches(url) {
|
|
259
259
|
const { origin, hostname } = new URL(url);
|
|
@@ -282,7 +282,7 @@ var Oas = class _Oas {
|
|
|
282
282
|
}
|
|
283
283
|
if (!matchedServer || !pathName) {
|
|
284
284
|
const matchedServerAndPath = (servers || []).map((server) => {
|
|
285
|
-
const rgx =
|
|
285
|
+
const rgx = _chunkYCSVUVACcjs.transformURLIntoRegex.call(void 0, server.url);
|
|
286
286
|
const found = new RegExp(rgx).exec(url);
|
|
287
287
|
if (!found) {
|
|
288
288
|
return;
|
|
@@ -303,7 +303,7 @@ var Oas = class _Oas {
|
|
|
303
303
|
if (pathName === void 0) return void 0;
|
|
304
304
|
if (pathName === "") pathName = "/";
|
|
305
305
|
if (!paths || !targetServer) return void 0;
|
|
306
|
-
const annotatedPaths =
|
|
306
|
+
const annotatedPaths = _chunkYCSVUVACcjs.generatePathMatches.call(void 0, paths, pathName, targetServer.url);
|
|
307
307
|
if (!annotatedPaths.length) return void 0;
|
|
308
308
|
return annotatedPaths;
|
|
309
309
|
}
|
|
@@ -320,9 +320,9 @@ var Oas = class _Oas {
|
|
|
320
320
|
if (!annotatedPaths) {
|
|
321
321
|
return void 0;
|
|
322
322
|
}
|
|
323
|
-
const matches =
|
|
323
|
+
const matches = _chunkYCSVUVACcjs.filterPathMethods.call(void 0, annotatedPaths, method);
|
|
324
324
|
if (!matches.length) return void 0;
|
|
325
|
-
return
|
|
325
|
+
return _chunkYCSVUVACcjs.findTargetPath.call(void 0, matches);
|
|
326
326
|
}
|
|
327
327
|
/**
|
|
328
328
|
* Discover an operation in an OAS from a fully-formed URL without an HTTP method. Will return an
|
|
@@ -335,7 +335,7 @@ var Oas = class _Oas {
|
|
|
335
335
|
if (!annotatedPaths) {
|
|
336
336
|
return void 0;
|
|
337
337
|
}
|
|
338
|
-
return
|
|
338
|
+
return _chunkYCSVUVACcjs.findTargetPath.call(void 0, annotatedPaths);
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
341
341
|
* Retrieve an operation in an OAS from a fully-formed URL and HTTP method. Differs from
|
|
@@ -421,7 +421,7 @@ var Oas = class _Oas {
|
|
|
421
421
|
let scheme = _optionalChain([this, 'access', _23 => _23.api, 'optionalAccess', _24 => _24.components, 'optionalAccess', _25 => _25.securitySchemes, 'optionalAccess', _26 => _26[name]]);
|
|
422
422
|
if (!scheme) return void 0;
|
|
423
423
|
if (_chunk7PWF3F2Wcjs.isRef.call(void 0, scheme)) {
|
|
424
|
-
scheme =
|
|
424
|
+
scheme = _chunkGPOPN7TQcjs.dereferenceRef.call(void 0, scheme, this.api);
|
|
425
425
|
if (!scheme || _chunk7PWF3F2Wcjs.isRef.call(void 0, scheme)) return void 0;
|
|
426
426
|
}
|
|
427
427
|
return scheme;
|
|
@@ -447,14 +447,14 @@ var Oas = class _Oas {
|
|
|
447
447
|
if (!pathItem) {
|
|
448
448
|
return;
|
|
449
449
|
} else if (_chunk7PWF3F2Wcjs.isRef.call(void 0, pathItem)) {
|
|
450
|
-
this.api.paths[path] =
|
|
450
|
+
this.api.paths[path] = _chunkGPOPN7TQcjs.dereferenceRef.call(void 0, pathItem, this.api);
|
|
451
451
|
pathItem = this.api.paths[path];
|
|
452
452
|
if (!pathItem || _chunk7PWF3F2Wcjs.isRef.call(void 0, pathItem)) {
|
|
453
453
|
return;
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
Object.keys(pathItem).forEach((method) => {
|
|
457
|
-
if (!
|
|
457
|
+
if (!_chunkGPOPN7TQcjs.supportedMethods.includes(method)) {
|
|
458
458
|
return;
|
|
459
459
|
}
|
|
460
460
|
paths[path][method] = this.operation(path, method);
|
|
@@ -476,10 +476,10 @@ var Oas = class _Oas {
|
|
|
476
476
|
}
|
|
477
477
|
Object.keys(this.api.webhooks).forEach((id) => {
|
|
478
478
|
webhooks[id] = {};
|
|
479
|
-
const webhookPath =
|
|
479
|
+
const webhookPath = _chunkGPOPN7TQcjs.dereferenceRef.call(void 0, _optionalChain([this, 'access', _27 => _27.api, 'access', _28 => _28.webhooks, 'optionalAccess', _29 => _29[id]]), this.api);
|
|
480
480
|
if (webhookPath) {
|
|
481
481
|
Object.keys(webhookPath).forEach((method) => {
|
|
482
|
-
if (!
|
|
482
|
+
if (!_chunkGPOPN7TQcjs.supportedMethods.includes(method)) {
|
|
483
483
|
return;
|
|
484
484
|
}
|
|
485
485
|
webhooks[id][method] = this.operation(id, method, {
|
|
@@ -504,7 +504,7 @@ var Oas = class _Oas {
|
|
|
504
504
|
getTags(setIfMissing = false) {
|
|
505
505
|
const allTags = /* @__PURE__ */ new Set();
|
|
506
506
|
const oasTags = _optionalChain([this, 'access', _30 => _30.api, 'access', _31 => _31.tags, 'optionalAccess', _32 => _32.map, 'call', _33 => _33((tag) => tag.name)]) || [];
|
|
507
|
-
const disableTagSorting =
|
|
507
|
+
const disableTagSorting = _chunk6HXOZ5GYcjs.getExtension.call(void 0, "disable-tag-sorting", this.api);
|
|
508
508
|
Object.entries(this.getPaths()).forEach(([path, operations]) => {
|
|
509
509
|
Object.values(operations).forEach((operation) => {
|
|
510
510
|
const tags = operation.getTags();
|
|
@@ -555,7 +555,7 @@ var Oas = class _Oas {
|
|
|
555
555
|
* @param extension Specification extension to lookup.
|
|
556
556
|
*/
|
|
557
557
|
hasExtension(extension) {
|
|
558
|
-
return
|
|
558
|
+
return _chunk6HXOZ5GYcjs.hasRootExtension.call(void 0, extension, this.api);
|
|
559
559
|
}
|
|
560
560
|
/**
|
|
561
561
|
* Retrieve a custom specification extension off of the API definition.
|
|
@@ -565,7 +565,7 @@ var Oas = class _Oas {
|
|
|
565
565
|
* @param extension Specification extension to lookup.
|
|
566
566
|
*/
|
|
567
567
|
getExtension(extension, operation) {
|
|
568
|
-
return
|
|
568
|
+
return _chunk6HXOZ5GYcjs.getExtension.call(void 0, extension, this.api, operation);
|
|
569
569
|
}
|
|
570
570
|
/**
|
|
571
571
|
* Determine if a given OpenAPI custom extension is valid or not.
|
|
@@ -583,16 +583,16 @@ var Oas = class _Oas {
|
|
|
583
583
|
throw new TypeError('"x-readme" must be of type "Object"');
|
|
584
584
|
}
|
|
585
585
|
if (extension in data) {
|
|
586
|
-
if ([
|
|
586
|
+
if ([_chunk6HXOZ5GYcjs.CODE_SAMPLES, _chunk6HXOZ5GYcjs.HEADERS, _chunk6HXOZ5GYcjs.PARAMETER_ORDERING, _chunk6HXOZ5GYcjs.SAMPLES_LANGUAGES].includes(extension)) {
|
|
587
587
|
if (data[extension] !== void 0) {
|
|
588
588
|
if (!Array.isArray(data[extension])) {
|
|
589
589
|
throw new TypeError(`"x-readme.${extension}" must be of type "Array"`);
|
|
590
590
|
}
|
|
591
|
-
if (extension ===
|
|
592
|
-
|
|
591
|
+
if (extension === _chunk6HXOZ5GYcjs.PARAMETER_ORDERING) {
|
|
592
|
+
_chunk6HXOZ5GYcjs.validateParameterOrdering.call(void 0, data[extension], `x-readme.${extension}`);
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
-
} else if (extension ===
|
|
595
|
+
} else if (extension === _chunk6HXOZ5GYcjs.OAUTH_OPTIONS) {
|
|
596
596
|
if (typeof data[extension] !== "object") {
|
|
597
597
|
throw new TypeError(`"x-readme.${extension}" must be of type "Object"`);
|
|
598
598
|
}
|
|
@@ -603,14 +603,14 @@ var Oas = class _Oas {
|
|
|
603
603
|
}
|
|
604
604
|
if (this.hasExtension(`x-${extension}`)) {
|
|
605
605
|
const data = this.getExtension(`x-${extension}`);
|
|
606
|
-
if ([
|
|
606
|
+
if ([_chunk6HXOZ5GYcjs.CODE_SAMPLES, _chunk6HXOZ5GYcjs.HEADERS, _chunk6HXOZ5GYcjs.PARAMETER_ORDERING, _chunk6HXOZ5GYcjs.SAMPLES_LANGUAGES].includes(extension)) {
|
|
607
607
|
if (!Array.isArray(data)) {
|
|
608
608
|
throw new TypeError(`"x-${extension}" must be of type "Array"`);
|
|
609
609
|
}
|
|
610
|
-
if (extension ===
|
|
611
|
-
|
|
610
|
+
if (extension === _chunk6HXOZ5GYcjs.PARAMETER_ORDERING) {
|
|
611
|
+
_chunk6HXOZ5GYcjs.validateParameterOrdering.call(void 0, data, `x-${extension}`);
|
|
612
612
|
}
|
|
613
|
-
} else if (extension ===
|
|
613
|
+
} else if (extension === _chunk6HXOZ5GYcjs.OAUTH_OPTIONS) {
|
|
614
614
|
if (typeof data !== "object") {
|
|
615
615
|
throw new TypeError(`"x-${extension}" must be of type "Object"`);
|
|
616
616
|
}
|
|
@@ -627,7 +627,7 @@ var Oas = class _Oas {
|
|
|
627
627
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions}
|
|
628
628
|
*/
|
|
629
629
|
validateExtensions() {
|
|
630
|
-
Object.keys(
|
|
630
|
+
Object.keys(_chunk6HXOZ5GYcjs.extensionDefaults).forEach((extension) => {
|
|
631
631
|
this.validateExtension(extension);
|
|
632
632
|
});
|
|
633
633
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1035,6 +1035,20 @@ declare const SIMPLE_MODE = "simple-mode";
|
|
|
1035
1035
|
* }
|
|
1036
1036
|
*/
|
|
1037
1037
|
declare const DISABLE_TAG_SORTING = "disable-tag-sorting";
|
|
1038
|
+
/**
|
|
1039
|
+
* A customer-declared health/status URL for the API. When present, it's surfaced to AI agents as
|
|
1040
|
+
* the RFC 9727 `status` link relation in the project's `/.well-known/api-catalog`.
|
|
1041
|
+
*
|
|
1042
|
+
* @see {@link https://docs.readme.com/main/docs/openapi-extensions}
|
|
1043
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9727}
|
|
1044
|
+
* @example
|
|
1045
|
+
* {
|
|
1046
|
+
* "x-readme": {
|
|
1047
|
+
* "status-url": "https://status.example.com"
|
|
1048
|
+
* }
|
|
1049
|
+
* }
|
|
1050
|
+
*/
|
|
1051
|
+
declare const STATUS_URL = "status-url";
|
|
1038
1052
|
interface Extensions {
|
|
1039
1053
|
[CODE_SAMPLES]: {
|
|
1040
1054
|
/**
|
|
@@ -1109,6 +1123,7 @@ interface Extensions {
|
|
|
1109
1123
|
[PROXY_ENABLED]: boolean;
|
|
1110
1124
|
[SAMPLES_LANGUAGES]: string[];
|
|
1111
1125
|
[SIMPLE_MODE]: boolean;
|
|
1126
|
+
[STATUS_URL]: string | undefined;
|
|
1112
1127
|
}
|
|
1113
1128
|
declare const extensionDefaults: Extensions;
|
|
1114
1129
|
/**
|
|
@@ -1131,4 +1146,4 @@ declare function validateParameterOrdering(ordering: (typeof extensionDefaults)[
|
|
|
1131
1146
|
|
|
1132
1147
|
// @ts-ignore
|
|
1133
1148
|
export = Oas;
|
|
1134
|
-
export { Callback as C, DISABLE_TAG_SORTING as D, EXPLORER_ENABLED as E, HEADERS as H, INTERNAL as I, METRICS_ENABLED as M, Operation as O, PARAMETER_ORDERING as P, SAMPLES_LANGUAGES as S, Webhook as W, CODE_SAMPLES as a, type Extensions as b, OAUTH_OPTIONS as c, PROXY_ENABLED as d, SIMPLE_MODE as e,
|
|
1149
|
+
export { Callback as C, DISABLE_TAG_SORTING as D, EXPLORER_ENABLED as E, HEADERS as H, INTERNAL as I, METRICS_ENABLED as M, Operation as O, PARAMETER_ORDERING as P, SAMPLES_LANGUAGES as S, Webhook as W, CODE_SAMPLES as a, type Extensions as b, OAUTH_OPTIONS as c, PROXY_ENABLED as d, SIMPLE_MODE as e, STATUS_URL as f, extensionDefaults as g, getExtension as h, hasRootExtension as i, validateParameterOrdering as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -1035,6 +1035,20 @@ declare const SIMPLE_MODE = "simple-mode";
|
|
|
1035
1035
|
* }
|
|
1036
1036
|
*/
|
|
1037
1037
|
declare const DISABLE_TAG_SORTING = "disable-tag-sorting";
|
|
1038
|
+
/**
|
|
1039
|
+
* A customer-declared health/status URL for the API. When present, it's surfaced to AI agents as
|
|
1040
|
+
* the RFC 9727 `status` link relation in the project's `/.well-known/api-catalog`.
|
|
1041
|
+
*
|
|
1042
|
+
* @see {@link https://docs.readme.com/main/docs/openapi-extensions}
|
|
1043
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9727}
|
|
1044
|
+
* @example
|
|
1045
|
+
* {
|
|
1046
|
+
* "x-readme": {
|
|
1047
|
+
* "status-url": "https://status.example.com"
|
|
1048
|
+
* }
|
|
1049
|
+
* }
|
|
1050
|
+
*/
|
|
1051
|
+
declare const STATUS_URL = "status-url";
|
|
1038
1052
|
interface Extensions {
|
|
1039
1053
|
[CODE_SAMPLES]: {
|
|
1040
1054
|
/**
|
|
@@ -1109,6 +1123,7 @@ interface Extensions {
|
|
|
1109
1123
|
[PROXY_ENABLED]: boolean;
|
|
1110
1124
|
[SAMPLES_LANGUAGES]: string[];
|
|
1111
1125
|
[SIMPLE_MODE]: boolean;
|
|
1126
|
+
[STATUS_URL]: string | undefined;
|
|
1112
1127
|
}
|
|
1113
1128
|
declare const extensionDefaults: Extensions;
|
|
1114
1129
|
/**
|
|
@@ -1129,4 +1144,4 @@ declare function getExtension(extension: string | keyof Extensions, api: OASDocu
|
|
|
1129
1144
|
*/
|
|
1130
1145
|
declare function validateParameterOrdering(ordering: (typeof extensionDefaults)[typeof PARAMETER_ORDERING] | undefined, extension: string): void;
|
|
1131
1146
|
|
|
1132
|
-
export { Callback as C, DISABLE_TAG_SORTING as D, EXPLORER_ENABLED as E, HEADERS as H, INTERNAL as I, METRICS_ENABLED as M, Operation as O, PARAMETER_ORDERING as P, SAMPLES_LANGUAGES as S, Webhook as W, CODE_SAMPLES as a, type Extensions as b, OAUTH_OPTIONS as c, PROXY_ENABLED as d, Oas as default, SIMPLE_MODE as e,
|
|
1147
|
+
export { Callback as C, DISABLE_TAG_SORTING as D, EXPLORER_ENABLED as E, HEADERS as H, INTERNAL as I, METRICS_ENABLED as M, Operation as O, PARAMETER_ORDERING as P, SAMPLES_LANGUAGES as S, Webhook as W, CODE_SAMPLES as a, type Extensions as b, OAUTH_OPTIONS as c, PROXY_ENABLED as d, Oas as default, SIMPLE_MODE as e, STATUS_URL as f, extensionDefaults as g, getExtension as h, hasRootExtension as i, validateParameterOrdering as v };
|
package/dist/index.js
CHANGED
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
stripTrailingSlash,
|
|
12
12
|
transformURLIntoRegex,
|
|
13
13
|
variablesFromServers
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LOR5XCEP.js";
|
|
15
15
|
import {
|
|
16
16
|
SERVER_VARIABLE_REGEX,
|
|
17
17
|
dereferenceRef,
|
|
18
18
|
supportedMethods
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-6QP66C5V.js";
|
|
20
20
|
import {
|
|
21
21
|
CODE_SAMPLES,
|
|
22
22
|
HEADERS,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
getExtension,
|
|
28
28
|
hasRootExtension,
|
|
29
29
|
validateParameterOrdering
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-LZNTJ4ZR.js";
|
|
31
31
|
import {
|
|
32
32
|
isOpenAPI31,
|
|
33
33
|
isRef
|
package/dist/operation/index.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
5
|
+
var _chunkYCSVUVACcjs = require('../chunk-YCSVUVAC.cjs');
|
|
6
|
+
require('../chunk-GPOPN7TQ.cjs');
|
|
7
|
+
require('../chunk-6HXOZ5GY.cjs');
|
|
8
8
|
require('../chunk-7PWF3F2W.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
exports.Callback =
|
|
13
|
+
exports.Callback = _chunkYCSVUVACcjs.Callback; exports.Operation = _chunkYCSVUVACcjs.Operation; exports.Webhook = _chunkYCSVUVACcjs.Webhook;
|
|
14
14
|
//# sourceMappingURL=index.cjs.map
|
package/dist/operation/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
Callback,
|
|
3
3
|
Operation,
|
|
4
4
|
Webhook
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-LOR5XCEP.js";
|
|
6
|
+
import "../chunk-6QP66C5V.js";
|
|
7
|
+
import "../chunk-LZNTJ4ZR.js";
|
|
8
8
|
import "../chunk-XG4HGNCN.js";
|
|
9
9
|
export {
|
|
10
10
|
Callback,
|
package/dist/reducer/index.cjs
CHANGED
|
@@ -4,8 +4,8 @@ var _chunkW6GBV2JTcjs = require('../chunk-W6GBV2JT.cjs');
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('../chunk-
|
|
7
|
+
var _chunkGPOPN7TQcjs = require('../chunk-GPOPN7TQ.cjs');
|
|
8
|
+
require('../chunk-6HXOZ5GY.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -274,7 +274,7 @@ var OpenAPIReducer = (_class = class _OpenAPIReducer {
|
|
|
274
274
|
const pathSegment = match[1];
|
|
275
275
|
const method = match[2];
|
|
276
276
|
if (pathSegment && method) {
|
|
277
|
-
return { path:
|
|
277
|
+
return { path: _chunkGPOPN7TQcjs.decodePointer.call(void 0, pathSegment), method };
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
return null;
|
|
@@ -293,7 +293,7 @@ var OpenAPIReducer = (_class = class _OpenAPIReducer {
|
|
|
293
293
|
const webhookName = match[1];
|
|
294
294
|
const method = match[2];
|
|
295
295
|
if (webhookName && method) {
|
|
296
|
-
return { name:
|
|
296
|
+
return { name: _chunkGPOPN7TQcjs.decodePointer.call(void 0, webhookName), method };
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
return null;
|
|
@@ -321,7 +321,7 @@ var OpenAPIReducer = (_class = class _OpenAPIReducer {
|
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
Object.keys(_optionalChain([this, 'access', _23 => _23.definition, 'access', _24 => _24.paths, 'optionalAccess', _25 => _25[path]]) || {}).forEach((method) => {
|
|
324
|
-
if (method === "parameters" || !
|
|
324
|
+
if (method === "parameters" || !_chunkGPOPN7TQcjs.supportedMethods.includes(method.toLowerCase())) {
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
if (this.hasPathsToReduceBy) {
|
|
@@ -395,7 +395,7 @@ var OpenAPIReducer = (_class = class _OpenAPIReducer {
|
|
|
395
395
|
return;
|
|
396
396
|
}
|
|
397
397
|
Object.keys(webhook).forEach((method) => {
|
|
398
|
-
if (method === "parameters" || !
|
|
398
|
+
if (method === "parameters" || !_chunkGPOPN7TQcjs.supportedMethods.includes(method.toLowerCase())) {
|
|
399
399
|
return;
|
|
400
400
|
}
|
|
401
401
|
if (this.hasWebhooksToReduceBy) {
|
|
@@ -470,7 +470,7 @@ var OpenAPIReducer = (_class = class _OpenAPIReducer {
|
|
|
470
470
|
}
|
|
471
471
|
Object.keys(_optionalChain([this, 'access', _39 => _39.definition, 'access', _40 => _40.paths, 'optionalAccess', _41 => _41[path]]) || {}).forEach((method) => {
|
|
472
472
|
const methodLC = method.toLowerCase();
|
|
473
|
-
if (method === "parameters" || !
|
|
473
|
+
if (method === "parameters" || !_chunkGPOPN7TQcjs.supportedMethods.includes(methodLC)) {
|
|
474
474
|
return;
|
|
475
475
|
}
|
|
476
476
|
const retainedByRef = this.retainPathMethods.has(`${pathLC}|${methodLC}`) || Array.from(this.$refs).some((ref) => {
|
|
@@ -555,7 +555,7 @@ var OpenAPIReducer = (_class = class _OpenAPIReducer {
|
|
|
555
555
|
}
|
|
556
556
|
Object.keys(webhook).forEach((method) => {
|
|
557
557
|
const methodLC = method.toLowerCase();
|
|
558
|
-
if (method === "parameters" || !
|
|
558
|
+
if (method === "parameters" || !_chunkGPOPN7TQcjs.supportedMethods.includes(methodLC)) {
|
|
559
559
|
return;
|
|
560
560
|
}
|
|
561
561
|
const retainedByRef = this.retainWebhookMethods.has(`${nameLC}|${methodLC}`);
|
package/dist/reducer/index.js
CHANGED
package/dist/utils.cjs
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
10
|
-
require('./chunk-
|
|
9
|
+
var _chunkGPOPN7TQcjs = require('./chunk-GPOPN7TQ.cjs');
|
|
10
|
+
require('./chunk-6HXOZ5GY.cjs');
|
|
11
11
|
require('./chunk-7PWF3F2W.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
@@ -17,5 +17,5 @@ require('./chunk-7PWF3F2W.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
exports.SERVER_VARIABLE_REGEX =
|
|
20
|
+
exports.SERVER_VARIABLE_REGEX = _chunkGPOPN7TQcjs.SERVER_VARIABLE_REGEX; exports.dereferenceRef = _chunkGPOPN7TQcjs.dereferenceRef; exports.dereferenceRefDeep = _chunkGPOPN7TQcjs.dereferenceRefDeep; exports.getParameterContentType = _chunkGPOPN7TQcjs.getParameterContentType; exports.jsonSchemaTypes = _chunkGPOPN7TQcjs.types; exports.matchesMimeType = _chunkGPOPN7TQcjs.matches_mimetype_default; exports.supportedMethods = _chunkGPOPN7TQcjs.supportedMethods;
|
|
21
21
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
matches_mimetype_default,
|
|
7
7
|
supportedMethods,
|
|
8
8
|
types
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-6QP66C5V.js";
|
|
10
|
+
import "./chunk-LZNTJ4ZR.js";
|
|
11
11
|
import "./chunk-XG4HGNCN.js";
|
|
12
12
|
export {
|
|
13
13
|
SERVER_VARIABLE_REGEX,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oas",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.2.0",
|
|
4
4
|
"description": "Comprehensive tooling for working with OpenAPI definitions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ReadMe <support@readme.io> (https://readme.com)",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"watch": "tsc --watch"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@readme/openapi-parser": "^6.1
|
|
86
|
+
"@readme/openapi-parser": "^6.2.1",
|
|
87
87
|
"@types/json-schema": "^7.0.11",
|
|
88
88
|
"json-schema-merge-allof": "^0.8.1",
|
|
89
89
|
"jsonpath-plus": "^10.4.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/chunk-AYA3UT4L.cjs","../src/extensions.ts"],"names":[],"mappings":"AAAA;AC+BO,IAAM,aAAA,EAAe,cAAA;AAoBrB,IAAM,iBAAA,EAAmB,kBAAA;AAwBzB,IAAM,QAAA,EAAU,SAAA;AAmBhB,IAAM,SAAA,EAAW,UAAA;AAmBjB,IAAM,gBAAA,EAAkB,iBAAA;AAkBxB,IAAM,cAAA,EAAgB,eAAA;AAuBtB,IAAM,mBAAA,EAAqB,oBAAA;AAoB3B,IAAM,cAAA,EAAgB,eAAA;AAiBtB,IAAM,kBAAA,EAAoB,mBAAA;AAc1B,IAAM,YAAA,EAAc,aAAA;AAepB,IAAM,oBAAA,EAAsB,qBAAA;AAkF5B,IAAM,kBAAA,EAAgC;AAAA,EAC3C,CAAC,YAAY,CAAA,EAAG,KAAA,CAAA;AAAA,EAChB,CAAC,mBAAmB,CAAA,EAAG,KAAA;AAAA,EACvB,CAAC,gBAAgB,CAAA,EAAG,IAAA;AAAA,EACpB,CAAC,OAAO,CAAA,EAAG,KAAA,CAAA;AAAA,EACX,CAAC,QAAQ,CAAA,EAAG,KAAA;AAAA,EACZ,CAAC,eAAe,CAAA,EAAG,IAAA;AAAA,EACnB,CAAC,aAAa,CAAA,EAAG,CAAC,CAAA;AAAA,EAClB,CAAC,kBAAkB,CAAA,EAAG,CAAC,MAAA,EAAQ,OAAA,EAAS,MAAA,EAAQ,QAAA,EAAU,MAAA,EAAQ,QAAQ,CAAA;AAAA,EAC1E,CAAC,aAAa,CAAA,EAAG,IAAA;AAAA,EACjB,CAAC,iBAAiB,CAAA,EAAG,CAAC,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,QAAA,EAAU,MAAA,EAAQ,QAAQ,CAAA;AAAA,EAChF,CAAC,WAAW,CAAA,EAAG;AACjB,CAAA;AAMO,SAAS,gBAAA,CAAiB,SAAA,EAAsC,GAAA,EAA2B;AAChG,EAAA,OAAO,OAAA,CAAQ,IAAA,GAAO,UAAA,GAAa,GAAG,CAAA;AACxC;AAMO,SAAS,YAAA,CAAa,SAAA,EAAsC,GAAA,EAAkB,SAAA,EAA4B;AAC/G,EAAA,GAAA,CAAI,SAAA,EAAW;AACb,IAAA,GAAA,CAAI,SAAA,CAAU,YAAA,CAAa,UAAU,CAAA,EAAG;AACtC,MAAA,MAAM,KAAA,EAAO,SAAA,CAAU,YAAA,CAAa,UAAU,CAAA;AAC9C,MAAA,GAAA,CAAI,KAAA,GAAQ,OAAO,KAAA,IAAS,SAAA,GAAY,UAAA,GAAa,IAAA,EAAM;AACzD,QAAA,OAAO,IAAA,CAAK,SAA6B,CAAA;AAAA,MAC3C;AAAA,IACF;AAEA,IAAA,GAAA,CAAI,SAAA,CAAU,YAAA,CAAa,CAAA,EAAA,EAAK,SAAS,CAAA,CAAA;AACJ,MAAA;AACH,IAAA;AACO,MAAA;AACzC,IAAA;AACF,EAAA;AAIgC,EAAA;AACI,IAAA;AACpC,EAAA;AAEuC,EAAA;AACR,IAAA;AACW,IAAA;AACG,MAAA;AAC3C,IAAA;AACF,EAAA;AAE0C,EAAA;AACX,IAAA;AACW,EAAA;AAClB,IAAA;AACxB,EAAA;AAGoC,EAAA;AACoB,IAAA;AACxD,EAAA;AAEO,EAAA;AACT;AAUE;AAEe,EAAA;AACb,IAAA;AACF,EAAA;AAEuC,EAAA;AACH,EAAA;AACQ,EAAA;AAEJ,EAAA;AACL,IAAA;AACnC,EAAA;AAEqC,EAAA;AACO,EAAA;AACT,IAAA;AACnC,EAAA;AACF;ADjU8C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas/dist/chunk-AYA3UT4L.cjs","sourcesContent":[null,"import type { Operation } from './operation/index.js';\nimport type { OASDocument } from './types.js';\n\n/**\n * Enables custom-written code samples to be set for your operations. Use this if you have specific\n * formatting that may not be followed by the auto-generated code samples. Custom code samples are\n * treated as static content.\n *\n * This extension only be placed at the operation level.\n *\n * @defaultValue []\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#custom-code-samples}\n * @example\n * {\n * \"x-readme\": {\n * \"code-samples\": [\n * {\n * \"language\": \"curl\",\n * \"code\": \"curl -X POST https://api.example.com/v2/alert\",\n * \"name\": \"Custom cURL snippet\",\n * \"install\": \"brew install curl\"\n * },\n * {\n * \"language\": \"php\",\n * \"code\": \"<?php echo \\\"This is our custom PHP code snippet.\\\"; ?>\",\n * \"name\": \"Custom PHP snippet\"\n * }\n * ]\n * }\n * }\n */\nexport const CODE_SAMPLES = 'code-samples';\n\n/**\n * Disables the API Explorer's \"Try It\" button, preventing users from making API requests from\n * within your docs. Users will still be able to fill out any entry fields (path or query\n * parameters, etc.), and code snippets will be auto-generated based on the user's input, however\n * to interact with your API the user will need to copy the code snippet and execute it outside of\n * your docs.\n *\n * This **does not** disable your API Reference documentation.\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-the-api-explorer}\n * @example\n * {\n * \"x-readme\": {\n * \"explorer-enabled\": true\n * }\n * }\n */\nexport const EXPLORER_ENABLED = 'explorer-enabled';\n\n/**\n * Adds static headers to add to each request. Use this when there are specific headers unique to\n * your API.\n *\n * @defaultValue []\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#static-headers}\n * @example\n * {\n * \"x-readme\": {\n * \"headers\": [\n * {\n * \"key\": \"X-Static-Header-One\",\n * \"value\": \"owlbert\"\n * },\n * {\n * \"key\": \"X-Static-Header-Two\",\n * \"value\": \"owlivia\"\n * }\n * ]\n * }\n * }\n */\nexport const HEADERS = 'headers';\n\n/**\n * Allows you to mark an API endpoint, or _every_ API endpoint if defined in the root, as being\n * internal and hidden from your public API reference.\n *\n * @defaultValue false\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#internal}\n * @example\n * {\n * \"x-internal\": true\n * }\n * @example\n * {\n * \"x-readme\": {\n * \"internal\": true\n * }\n * }\n */\nexport const INTERNAL = 'internal';\n\n/**\n * Disables API requests from the API Explorer's \"Try It\" button from being sent into our [API\n * Metrics](https://readme.com/metrics) for you and your users. Additionally on any API endpoint\n * that this is disabled on your users will not see lists or graphs of previous requests they've\n * made against that API endpoint — either through the API Explorer's interactivity or through one\n * of our [Metrics SDKs](https://docs.readme.com/main/docs/api-metrics-setup) (if you have those\n * installed on your API).\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-api-metrics}\n * @example\n * {\n * \"x-readme\": {\n * \"metrics-defaults\": false\n * }\n * }\n */\nexport const METRICS_ENABLED = 'metrics-enabled';\n\n/**\n * Configuration options for OAuth flows in the API Explorer.\n *\n * @defaultValue {}\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#oauth-configuration-options}\n * @example\n * {\n * \"x-readme\": {\n * \"oauth-options\": {\n * \"scopeSeparator\": \",\",\n * \"useInsecureClientAuthentication\": true,\n * \"usePkce\": false\n * }\n * }\n * }\n */\nexport const OAUTH_OPTIONS = 'oauth-options';\n\n/**\n * Controls the order of parameters on your API Reference pages.\n *\n * Your custom ordering **must** contain all of our available parameter types:\n *\n * - `path`: Path parameters\n * - `query`: Query parameters\n * - `body`: Non-`application/x-www-form-urlencoded` request body payloads\n * - `cookie`: Cookie parameters\n * - `form`: `application/x-www-form-urlencoded` request body payloads\n * - `header`: Header parameters\n *\n * @defaultValue ['path', 'query', 'body', 'cookie', 'form', 'header']\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#parameter-ordering}\n * @example\n * {\n * \"x-readme\": {\n * \"parameter-ordering\": ['path', 'query', 'header', 'cookie', 'body', 'form']\n * }\n * }\n */\nexport const PARAMETER_ORDERING = 'parameter-ordering';\n\n/**\n * Toggles the CORS proxy used when making API requests from within your docs (via the \"Try It\"\n * button). If your API is already set up to return CORS headers, you can safely disable this\n * feature.\n *\n * Disabling the CORS proxy will make the request directly from the user's browser and will prevent\n * [Metrics](https://docs.readme.com/main/docs/getting-started-with-metrics) data from being logged\n * by us unless [Metrics have already set up on your backend](https://docs.readme.com/main/docs/api-metrics-setup).\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#cors-proxy-enabled}\n * @example\n * {\n * \"x-readme\": {\n * \"proxy-enabled\": true\n * }\n * }\n */\nexport const PROXY_ENABLED = 'proxy-enabled';\n\n/**\n * Toggles what languages are shown by default for code samples in the API Explorer. This only\n * affects what languages are initially shown to the user; if the user picks another language from\n * the three-dot menu, that language and the respective auto-generated code snippet will also appear\n * as an option in the API Explorer.\n *\n * @defaultValue ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp']\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#code-sample-languages}\n * @example\n * {\n * \"x-readme\": {\n * \"samples-languages\": [\"shell\", \"node\", \"ruby\", \"javascript\", \"python\"]\n * }\n * }\n */\nexport const SAMPLES_LANGUAGES = 'samples-languages';\n\n/**\n * Toggles if you will see code snippets for ReadMe's SDK code generator tool `api`.\n *\n * @defaultValue true\n * @see {@link https://api.readme.dev}\n * @example\n * {\n * \"x-readme\": {\n * \"simple-mode\": false\n * }\n * }\n */\nexport const SIMPLE_MODE = 'simple-mode';\n\n/**\n * If `true`, tags are generated from the file top-down. If `false`, we sort the tags\n * based off the `tags` array in the OAS file.\n *\n * @defaultValue false\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-tag-sorting}\n * @example\n * {\n * \"x-readme\": {\n * \"disable-tag-sorting\": true\n * }\n * }\n */\nexport const DISABLE_TAG_SORTING = 'disable-tag-sorting';\n\nexport interface Extensions {\n [CODE_SAMPLES]:\n | {\n /**\n * Custom code snippet\n * @example \"curl -X POST https://api.example.com/v2/alert\"\n */\n code: string;\n /**\n * Corresponding response example\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#corresponding-response-examples}\n */\n correspondingExample?: string;\n /**\n * Library installation instructions\n * @example \"brew install httpie\"\n * @example \"npm install node-fetch@2 --save\"\n */\n install?: string;\n /**\n * Language for syntax highlighting\n * @example shell\n */\n language: string;\n /**\n * Optional title for code sample\n * @example \"Custom cURL snippet\"\n */\n name?: string;\n }[]\n | undefined;\n [DISABLE_TAG_SORTING]: boolean;\n [EXPLORER_ENABLED]: boolean;\n [HEADERS]: Record<string, number | string>[] | undefined;\n [INTERNAL]: boolean;\n [METRICS_ENABLED]: boolean;\n [OAUTH_OPTIONS]: {\n /**\n * Scope separator for passing scopes. This value will be URL-encoded.\n *\n * @example \",\"\n * @example \"+\"\n * @default \" \"\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.3} Scope separators information from OAuth 2.0 specification\n */\n scopeSeparator?: string;\n\n /**\n * When enabled, the client credentials (i.e., `client_id` and `client_secret`) are sent in the request body (NOT recommended).\n * When disabled (the default), client credentials are sent using the HTTP Basic Authentication scheme.\n *\n * This is applicable for all requests to the token endpoint.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1}\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.2}\n *\n * @example true\n * @default false\n */\n useInsecureClientAuthentication?: boolean;\n\n /**\n * When enabled, uses PKCE (Proof Key for Code Exchange) for the authorization code flow.\n * The client secret is replaced with an auto-generated code verifier and code challenge.\n * When disabled, uses the standard OAuth 2.0 authorization code flow with client credentials.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc7636#section-4.1}\n * @see {@link https://datatracker.ietf.org/doc/html/rfc7636#section-4.2}\n *\n * @example true\n * @default false\n */\n usePkce?: boolean;\n };\n [PARAMETER_ORDERING]: ('body' | 'cookie' | 'form' | 'header' | 'path' | 'query')[];\n [PROXY_ENABLED]: boolean;\n [SAMPLES_LANGUAGES]: string[];\n [SIMPLE_MODE]: boolean;\n}\n\nexport const extensionDefaults: Extensions = {\n [CODE_SAMPLES]: undefined,\n [DISABLE_TAG_SORTING]: false,\n [EXPLORER_ENABLED]: true,\n [HEADERS]: undefined,\n [INTERNAL]: false,\n [METRICS_ENABLED]: true,\n [OAUTH_OPTIONS]: {},\n [PARAMETER_ORDERING]: ['path', 'query', 'body', 'cookie', 'form', 'header'],\n [PROXY_ENABLED]: true,\n [SAMPLES_LANGUAGES]: ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp'],\n [SIMPLE_MODE]: true,\n};\n\n/**\n * Determing if an OpenAPI definition has an extension set in its root schema.\n *\n */\nexport function hasRootExtension(extension: string | keyof Extensions, api: OASDocument): boolean {\n return Boolean(api && extension in api);\n}\n\n/**\n * Retrieve a custom specification extension off of the API definition.\n *\n */\nexport function getExtension(extension: string | keyof Extensions, api: OASDocument, operation?: Operation): any {\n if (operation) {\n if (operation.hasExtension('x-readme')) {\n const data = operation.getExtension('x-readme') as Extensions;\n if (data && typeof data === 'object' && extension in data) {\n return data[extension as keyof Extensions];\n }\n }\n\n if (operation.hasExtension(`x-${extension}`)) {\n return operation.getExtension(`x-${extension}`);\n } else if (operation.hasExtension(extension)) {\n return operation.getExtension(extension);\n }\n }\n\n // Because our `code-samples` extension is intended for operation-level use, if it's instead\n // placed at the API definition root level then we should ignore it and return our set defaults.\n if (extension === CODE_SAMPLES) {\n return extensionDefaults[extension];\n }\n\n if (hasRootExtension('x-readme', api)) {\n const data = api?.['x-readme'] as Extensions;\n if (data && typeof data === 'object' && extension in data) {\n return data[extension as keyof Extensions];\n }\n }\n\n if (hasRootExtension(`x-${extension}`, api)) {\n return api?.[`x-${extension}`];\n } else if (hasRootExtension(extension, api)) {\n return api?.[extension];\n }\n\n // If this is otherwise an extension of our own then we should return the default value for it.\n if (extension in extensionDefaults) {\n return extensionDefaults[extension as keyof Extensions];\n }\n\n return undefined;\n}\n\n/**\n * Validate that the data for an instanceof our `PARAMETER_ORDERING` extension is properly\n * configured.\n *\n * @private\n */\nexport function validateParameterOrdering(\n ordering: (typeof extensionDefaults)[typeof PARAMETER_ORDERING] | undefined,\n extension: string,\n): void {\n if (!ordering) {\n return;\n }\n\n const defaultValue = extensionDefaults[PARAMETER_ORDERING];\n const requiredLength = defaultValue.length;\n const defaultsHuman = `${defaultValue.slice(0, -1).join(', ')}, and ${defaultValue.slice(-1)}`;\n\n if (ordering.length !== requiredLength) {\n throw new TypeError(`\"${extension}\" must contain ${requiredLength} items comprised of: ${defaultsHuman}`);\n }\n\n const intersection = ordering.filter(value => defaultValue.includes(value.toLowerCase() as any));\n if (intersection.length !== requiredLength) {\n throw new TypeError(`\"${extension}\" must contain ${requiredLength} items comprised of: ${defaultsHuman}`);\n }\n}\n"]}
|