@gitbook/react-openapi 1.4.2 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/index.d.ts +663 -10
- package/dist/index.js +3873 -8
- package/package.json +11 -7
- package/dist/InteractiveSection.d.ts +0 -33
- package/dist/InteractiveSection.jsx +0 -61
- package/dist/Markdown.d.ts +0 -4
- package/dist/Markdown.jsx +0 -5
- package/dist/OpenAPICodeSample.d.ts +0 -19
- package/dist/OpenAPICodeSample.jsx +0 -230
- package/dist/OpenAPICodeSampleInteractive.d.ts +0 -14
- package/dist/OpenAPICodeSampleInteractive.jsx +0 -73
- package/dist/OpenAPICodeSampleSelector.d.ts +0 -14
- package/dist/OpenAPICodeSampleSelector.jsx +0 -44
- package/dist/OpenAPICopyButton.d.ts +0 -13
- package/dist/OpenAPICopyButton.jsx +0 -35
- package/dist/OpenAPIDisclosure.d.ts +0 -11
- package/dist/OpenAPIDisclosure.jsx +0 -30
- package/dist/OpenAPIDisclosureGroup.d.ts +0 -23
- package/dist/OpenAPIDisclosureGroup.jsx +0 -83
- package/dist/OpenAPIExample.d.ts +0 -16
- package/dist/OpenAPIExample.jsx +0 -36
- package/dist/OpenAPIMediaType.d.ts +0 -21
- package/dist/OpenAPIMediaType.jsx +0 -61
- package/dist/OpenAPIOperation.d.ts +0 -10
- package/dist/OpenAPIOperation.jsx +0 -25
- package/dist/OpenAPIOperationContext.d.ts +0 -16
- package/dist/OpenAPIOperationContext.jsx +0 -26
- package/dist/OpenAPIOperationDescription.d.ts +0 -9
- package/dist/OpenAPIOperationDescription.jsx +0 -22
- package/dist/OpenAPIOperationStability.d.ts +0 -9
- package/dist/OpenAPIOperationStability.jsx +0 -27
- package/dist/OpenAPIPath.d.ts +0 -18
- package/dist/OpenAPIPath.jsx +0 -55
- package/dist/OpenAPIPrefillContextProvider.d.ts +0 -22
- package/dist/OpenAPIPrefillContextProvider.jsx +0 -19
- package/dist/OpenAPIRequestBody.d.ts +0 -11
- package/dist/OpenAPIRequestBody.jsx +0 -28
- package/dist/OpenAPIRequestBodyHeaderType.d.ts +0 -8
- package/dist/OpenAPIRequestBodyHeaderType.jsx +0 -25
- package/dist/OpenAPIResponse.d.ts +0 -10
- package/dist/OpenAPIResponse.jsx +0 -57
- package/dist/OpenAPIResponseExample.d.ts +0 -9
- package/dist/OpenAPIResponseExample.jsx +0 -105
- package/dist/OpenAPIResponseExampleContent.d.ts +0 -22
- package/dist/OpenAPIResponseExampleContent.jsx +0 -60
- package/dist/OpenAPIResponses.d.ts +0 -9
- package/dist/OpenAPIResponses.jsx +0 -77
- package/dist/OpenAPISchema.d.ts +0 -27
- package/dist/OpenAPISchema.jsx +0 -400
- package/dist/OpenAPISchemaName.d.ts +0 -16
- package/dist/OpenAPISchemaName.jsx +0 -43
- package/dist/OpenAPISchemaServer.d.ts +0 -12
- package/dist/OpenAPISchemaServer.jsx +0 -8
- package/dist/OpenAPISecurities.d.ts +0 -9
- package/dist/OpenAPISecurities.jsx +0 -114
- package/dist/OpenAPISelect.d.ts +0 -22
- package/dist/OpenAPISelect.jsx +0 -44
- package/dist/OpenAPISpec.d.ts +0 -6
- package/dist/OpenAPISpec.jsx +0 -80
- package/dist/OpenAPITabs.d.ts +0 -26
- package/dist/OpenAPITabs.jsx +0 -109
- package/dist/OpenAPIWebhook.d.ts +0 -10
- package/dist/OpenAPIWebhook.jsx +0 -23
- package/dist/OpenAPIWebhookExample.d.ts +0 -6
- package/dist/OpenAPIWebhookExample.jsx +0 -41
- package/dist/ScalarApiButton.d.ts +0 -14
- package/dist/ScalarApiButton.jsx +0 -81
- package/dist/StaticSection.d.ts +0 -13
- package/dist/StaticSection.jsx +0 -32
- package/dist/code-samples.d.ts +0 -17
- package/dist/code-samples.js +0 -427
- package/dist/common/OpenAPIColumnSpec.d.ts +0 -6
- package/dist/common/OpenAPIColumnSpec.jsx +0 -20
- package/dist/common/OpenAPIOperationDescription.d.ts +0 -6
- package/dist/common/OpenAPIOperationDescription.jsx +0 -19
- package/dist/common/OpenAPIStability.d.ts +0 -4
- package/dist/common/OpenAPIStability.jsx +0 -15
- package/dist/common/OpenAPISummary.d.ts +0 -6
- package/dist/common/OpenAPISummary.jsx +0 -30
- package/dist/contentTypeChecks.d.ts +0 -10
- package/dist/contentTypeChecks.js +0 -30
- package/dist/context.d.ts +0 -75
- package/dist/context.js +0 -43
- package/dist/decycle.d.ts +0 -2
- package/dist/decycle.js +0 -70
- package/dist/dereference.d.ts +0 -5
- package/dist/dereference.js +0 -68
- package/dist/generateSchemaExample.d.ts +0 -45
- package/dist/generateSchemaExample.js +0 -342
- package/dist/getDisclosureLabel.d.ts +0 -7
- package/dist/getDisclosureLabel.js +0 -18
- package/dist/getOrCreateStoreByKey.d.ts +0 -10
- package/dist/getOrCreateStoreByKey.js +0 -19
- package/dist/json2xml.d.ts +0 -4
- package/dist/json2xml.js +0 -7
- package/dist/resolveOpenAPIOperation.d.ts +0 -11
- package/dist/resolveOpenAPIOperation.js +0 -173
- package/dist/resolveOpenAPIWebhook.d.ts +0 -11
- package/dist/resolveOpenAPIWebhook.js +0 -127
- package/dist/schemas/OpenAPISchemaItem.d.ts +0 -7
- package/dist/schemas/OpenAPISchemaItem.jsx +0 -16
- package/dist/schemas/OpenAPISchemas.d.ts +0 -14
- package/dist/schemas/OpenAPISchemas.jsx +0 -59
- package/dist/schemas/index.d.ts +0 -2
- package/dist/schemas/index.js +0 -2
- package/dist/schemas/resolveOpenAPISchemas.d.ts +0 -10
- package/dist/schemas/resolveOpenAPISchemas.js +0 -61
- package/dist/stringifyOpenAPI.d.ts +0 -4
- package/dist/stringifyOpenAPI.js +0 -15
- package/dist/translate.d.ts +0 -10
- package/dist/translate.jsx +0 -75
- package/dist/translations/de.d.ts +0 -43
- package/dist/translations/de.js +0 -43
- package/dist/translations/en.d.ts +0 -43
- package/dist/translations/en.js +0 -43
- package/dist/translations/es.d.ts +0 -43
- package/dist/translations/es.js +0 -43
- package/dist/translations/fr.d.ts +0 -43
- package/dist/translations/fr.js +0 -43
- package/dist/translations/index.d.ts +0 -395
- package/dist/translations/index.js +0 -27
- package/dist/translations/ja.d.ts +0 -43
- package/dist/translations/ja.js +0 -43
- package/dist/translations/nl.d.ts +0 -43
- package/dist/translations/nl.js +0 -43
- package/dist/translations/no.d.ts +0 -43
- package/dist/translations/no.js +0 -43
- package/dist/translations/pt-br.d.ts +0 -43
- package/dist/translations/pt-br.js +0 -43
- package/dist/translations/types.d.ts +0 -5
- package/dist/translations/types.js +0 -1
- package/dist/translations/zh.d.ts +0 -43
- package/dist/translations/zh.js +0 -43
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types.d.ts +0 -31
- package/dist/types.js +0 -1
- package/dist/util/example.d.ts +0 -35
- package/dist/util/example.jsx +0 -103
- package/dist/util/server.d.ts +0 -9
- package/dist/util/server.js +0 -44
- package/dist/util/tryit-prefill.d.ts +0 -20
- package/dist/util/tryit-prefill.js +0 -129
- package/dist/utils.d.ts +0 -50
- package/dist/utils.js +0 -224
- package/src/InteractiveSection.tsx +0 -147
- package/src/Markdown.tsx +0 -12
- package/src/OpenAPICodeSample.tsx +0 -330
- package/src/OpenAPICodeSampleInteractive.tsx +0 -136
- package/src/OpenAPICodeSampleSelector.tsx +0 -94
- package/src/OpenAPICopyButton.tsx +0 -72
- package/src/OpenAPIDisclosure.tsx +0 -46
- package/src/OpenAPIDisclosureGroup.tsx +0 -158
- package/src/OpenAPIExample.tsx +0 -55
- package/src/OpenAPIMediaType.tsx +0 -139
- package/src/OpenAPIOperation.tsx +0 -35
- package/src/OpenAPIOperationContext.tsx +0 -45
- package/src/OpenAPIOperationDescription.tsx +0 -34
- package/src/OpenAPIOperationStability.tsx +0 -39
- package/src/OpenAPIPath.tsx +0 -90
- package/src/OpenAPIPrefillContextProvider.tsx +0 -40
- package/src/OpenAPIRequestBody.tsx +0 -54
- package/src/OpenAPIRequestBodyHeaderType.tsx +0 -36
- package/src/OpenAPIResponse.tsx +0 -82
- package/src/OpenAPIResponseExample.tsx +0 -151
- package/src/OpenAPIResponseExampleContent.tsx +0 -125
- package/src/OpenAPIResponses.tsx +0 -125
- package/src/OpenAPISchema.test.ts +0 -172
- package/src/OpenAPISchema.tsx +0 -654
- package/src/OpenAPISchemaName.tsx +0 -80
- package/src/OpenAPISchemaServer.tsx +0 -34
- package/src/OpenAPISecurities.tsx +0 -231
- package/src/OpenAPISelect.tsx +0 -96
- package/src/OpenAPISpec.tsx +0 -138
- package/src/OpenAPITabs.tsx +0 -147
- package/src/OpenAPIWebhook.tsx +0 -33
- package/src/OpenAPIWebhookExample.tsx +0 -60
- package/src/ScalarApiButton.tsx +0 -132
- package/src/StaticSection.tsx +0 -91
- package/src/__snapshots__/json2xml.test.ts.snap +0 -18
- package/src/code-samples.test.ts +0 -714
- package/src/code-samples.ts +0 -448
- package/src/common/OpenAPIColumnSpec.tsx +0 -31
- package/src/common/OpenAPIOperationDescription.tsx +0 -31
- package/src/common/OpenAPIStability.tsx +0 -23
- package/src/common/OpenAPISummary.tsx +0 -45
- package/src/contentTypeChecks.ts +0 -39
- package/src/context.ts +0 -99
- package/src/decycle.ts +0 -68
- package/src/dereference.ts +0 -29
- package/src/generateSchemaExample.test.ts +0 -1040
- package/src/generateSchemaExample.ts +0 -530
- package/src/getDisclosureLabel.ts +0 -25
- package/src/getOrCreateStoreByKey.ts +0 -33
- package/src/index.ts +0 -10
- package/src/json2xml.test.ts +0 -46
- package/src/json2xml.ts +0 -8
- package/src/resolveOpenAPIOperation.test.ts +0 -177
- package/src/resolveOpenAPIOperation.ts +0 -151
- package/src/resolveOpenAPIWebhook.ts +0 -99
- package/src/schemas/OpenAPISchemaItem.tsx +0 -34
- package/src/schemas/OpenAPISchemas.tsx +0 -98
- package/src/schemas/index.ts +0 -2
- package/src/schemas/resolveOpenAPISchemas.test.ts +0 -174
- package/src/schemas/resolveOpenAPISchemas.ts +0 -28
- package/src/stringifyOpenAPI.ts +0 -25
- package/src/translate.tsx +0 -80
- package/src/translations/de.ts +0 -43
- package/src/translations/en.ts +0 -43
- package/src/translations/es.ts +0 -43
- package/src/translations/fr.ts +0 -43
- package/src/translations/index.ts +0 -33
- package/src/translations/ja.ts +0 -43
- package/src/translations/nl.ts +0 -43
- package/src/translations/no.ts +0 -43
- package/src/translations/pt-br.ts +0 -43
- package/src/translations/types.ts +0 -7
- package/src/translations/zh.ts +0 -43
- package/src/types.ts +0 -46
- package/src/util/example.tsx +0 -129
- package/src/util/server.test.ts +0 -58
- package/src/util/server.ts +0 -47
- package/src/util/tryit-prefill.test.ts +0 -311
- package/src/util/tryit-prefill.ts +0 -160
- package/src/utils.ts +0 -255
package/dist/context.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
import { translations } from './translations';
|
|
24
|
-
/**
|
|
25
|
-
* Resolve OpenAPI context from the input.
|
|
26
|
-
*/
|
|
27
|
-
export function resolveOpenAPIContext(context) {
|
|
28
|
-
var locale = context.locale, rest = __rest(context, ["locale"]);
|
|
29
|
-
return __assign(__assign({}, rest), { translation: translations[locale !== null && locale !== void 0 ? locale : 'en'] });
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Get the client context from the OpenAPI context.
|
|
33
|
-
*/
|
|
34
|
-
export function getOpenAPIClientContext(context) {
|
|
35
|
-
return {
|
|
36
|
-
translation: context.translation,
|
|
37
|
-
icons: context.icons,
|
|
38
|
-
defaultInteractiveOpened: context.defaultInteractiveOpened,
|
|
39
|
-
blockKey: context.blockKey,
|
|
40
|
-
id: context.id,
|
|
41
|
-
$$isClientContext$$: true,
|
|
42
|
-
};
|
|
43
|
-
}
|
package/dist/decycle.d.ts
DELETED
package/dist/decycle.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// Forked from: https://github.com/YChebotaev/json-decycle/blob/master/src/index.ts
|
|
2
|
-
// Replaced `$ref` with `$reference` to avoid conflicts with OpenAPI
|
|
3
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
4
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
5
|
-
if (ar || !(i in from)) {
|
|
6
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
7
|
-
ar[i] = from[i];
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11
|
-
};
|
|
12
|
-
var isObject = function (value) {
|
|
13
|
-
return typeof value === 'object' &&
|
|
14
|
-
value != null &&
|
|
15
|
-
!(value instanceof Boolean) &&
|
|
16
|
-
!(value instanceof Date) &&
|
|
17
|
-
!(value instanceof Number) &&
|
|
18
|
-
!(value instanceof RegExp) &&
|
|
19
|
-
!(value instanceof String);
|
|
20
|
-
};
|
|
21
|
-
var toPointer = function (parts) {
|
|
22
|
-
return "#".concat(parts.map(function (part) { return String(part).replace(/~/g, '~0').replace(/\//g, '~1'); }).join('/'));
|
|
23
|
-
};
|
|
24
|
-
export var decycle = function () {
|
|
25
|
-
var paths = new WeakMap();
|
|
26
|
-
return function replacer(key, value) {
|
|
27
|
-
var _a;
|
|
28
|
-
if (key !== '$reference' && isObject(value)) {
|
|
29
|
-
var seen = paths.has(value);
|
|
30
|
-
if (seen) {
|
|
31
|
-
return { $reference: toPointer(paths.get(value)) };
|
|
32
|
-
}
|
|
33
|
-
paths.set(value, __spreadArray(__spreadArray([], ((_a = paths.get(this)) !== null && _a !== void 0 ? _a : []), true), [key], false));
|
|
34
|
-
}
|
|
35
|
-
return value;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export function retrocycle() {
|
|
39
|
-
var parents = new WeakMap();
|
|
40
|
-
var keys = new WeakMap();
|
|
41
|
-
var refs = new Set();
|
|
42
|
-
function dereference(ref) {
|
|
43
|
-
var _a;
|
|
44
|
-
var parts = ref.$reference.slice(1).split('/');
|
|
45
|
-
var key;
|
|
46
|
-
var value = this;
|
|
47
|
-
for (var i = 0; i < parts.length; i++) {
|
|
48
|
-
key = (_a = parts[i]) === null || _a === void 0 ? void 0 : _a.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
49
|
-
value = value[key];
|
|
50
|
-
}
|
|
51
|
-
var parent = parents.get(ref);
|
|
52
|
-
parent[keys.get(ref)] = value;
|
|
53
|
-
}
|
|
54
|
-
return function reviver(key, value) {
|
|
55
|
-
if (key === '$reference') {
|
|
56
|
-
refs.add(this);
|
|
57
|
-
}
|
|
58
|
-
else if (isObject(value)) {
|
|
59
|
-
var isRoot = key === '' && Object.keys(this).length === 1;
|
|
60
|
-
if (isRoot) {
|
|
61
|
-
refs.forEach(dereference, this);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
parents.set(value, this);
|
|
65
|
-
keys.set(value, key);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return value;
|
|
69
|
-
};
|
|
70
|
-
}
|
package/dist/dereference.d.ts
DELETED
package/dist/dereference.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { dereference } from '@gitbook/openapi-parser';
|
|
38
|
-
var dereferenceCache = new WeakMap();
|
|
39
|
-
/**
|
|
40
|
-
* Memoized version of `dereferenceSchema`.
|
|
41
|
-
*/
|
|
42
|
-
export function dereferenceFilesystem(filesystem) {
|
|
43
|
-
if (dereferenceCache.has(filesystem)) {
|
|
44
|
-
return dereferenceCache.get(filesystem);
|
|
45
|
-
}
|
|
46
|
-
var promise = baseDereferenceFilesystem(filesystem);
|
|
47
|
-
dereferenceCache.set(filesystem, promise);
|
|
48
|
-
return promise;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Dereference an OpenAPI schema.
|
|
52
|
-
*/
|
|
53
|
-
function baseDereferenceFilesystem(filesystem) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
var result;
|
|
56
|
-
return __generator(this, function (_a) {
|
|
57
|
-
switch (_a.label) {
|
|
58
|
-
case 0: return [4 /*yield*/, dereference(filesystem)];
|
|
59
|
-
case 1:
|
|
60
|
-
result = _a.sent();
|
|
61
|
-
if (!result.schema) {
|
|
62
|
-
throw new Error('Failed to dereference OpenAPI document');
|
|
63
|
-
}
|
|
64
|
-
return [2 /*return*/, result.schema];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
-
type JSONValue = string | number | boolean | null | JSONValue[] | {
|
|
3
|
-
[key: string]: JSONValue;
|
|
4
|
-
};
|
|
5
|
-
type ScalarGetExampleFromSchemaOptions = NonNullable<Parameters<typeof getExampleFromSchema>[1]>;
|
|
6
|
-
type GenerateSchemaExampleOptions = Pick<ScalarGetExampleFromSchemaOptions, 'xml' | 'omitEmptyAndOptionalProperties' | 'mode'>;
|
|
7
|
-
/**
|
|
8
|
-
* Generate a JSON example from a schema
|
|
9
|
-
*/
|
|
10
|
-
export declare function generateSchemaExample(schema: OpenAPIV3.SchemaObject, options?: GenerateSchemaExampleOptions): JSONValue | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Generate an example for a media type.
|
|
13
|
-
*/
|
|
14
|
-
export declare function generateMediaTypeExamples(mediaType: OpenAPIV3.MediaTypeObject, options?: GenerateSchemaExampleOptions): OpenAPIV3.ExampleObject[];
|
|
15
|
-
/**
|
|
16
|
-
* This function takes an OpenAPI schema and generates an example from it
|
|
17
|
-
* Forked from : https://github.com/scalar/scalar/blob/main/packages/oas-utils/src/spec-getters/getExampleFromSchema.ts
|
|
18
|
-
*/
|
|
19
|
-
declare const getExampleFromSchema: (schema: Record<string, any>, options?: {
|
|
20
|
-
/**
|
|
21
|
-
* The fallback string for empty string values.
|
|
22
|
-
* @default ''
|
|
23
|
-
*/
|
|
24
|
-
emptyString?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Whether to use the XML tag names as keys
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
29
|
-
xml?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Whether to show read-only/write-only properties. Otherwise all properties are shown.
|
|
32
|
-
* @default undefined
|
|
33
|
-
*/
|
|
34
|
-
mode?: "read" | "write";
|
|
35
|
-
/**
|
|
36
|
-
* Dynamic values to add to the example.
|
|
37
|
-
*/
|
|
38
|
-
variables?: Record<string, any>;
|
|
39
|
-
/**
|
|
40
|
-
* Whether to omit empty and optional properties.
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
omitEmptyAndOptionalProperties?: boolean;
|
|
44
|
-
}, level?: number, parentSchema?: Record<string, any>, name?: string, resultCache?: WeakMap<Record<string, any>, any>) => any;
|
|
45
|
-
export {};
|
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
|
-
var _a, _b, _c;
|
|
22
|
-
import { checkIsReference } from './utils';
|
|
23
|
-
/**
|
|
24
|
-
* Generate a JSON example from a schema
|
|
25
|
-
*/
|
|
26
|
-
export function generateSchemaExample(schema, options) {
|
|
27
|
-
return getExampleFromSchema(schema, __assign({ emptyString: 'text' }, options));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Generate an example for a media type.
|
|
31
|
-
*/
|
|
32
|
-
export function generateMediaTypeExamples(mediaType, options) {
|
|
33
|
-
if (mediaType.example) {
|
|
34
|
-
return [{ summary: 'default', value: mediaType.example }];
|
|
35
|
-
}
|
|
36
|
-
if (mediaType.examples) {
|
|
37
|
-
var examples_1 = mediaType.examples;
|
|
38
|
-
var keys = Object.keys(examples_1);
|
|
39
|
-
if (keys.length > 0) {
|
|
40
|
-
return keys.reduce(function (result, key) {
|
|
41
|
-
var example = examples_1[key];
|
|
42
|
-
if (!example || checkIsReference(example)) {
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
result.push({
|
|
46
|
-
summary: example.summary || key,
|
|
47
|
-
value: example.value,
|
|
48
|
-
description: example.description,
|
|
49
|
-
externalValue: example.externalValue,
|
|
50
|
-
});
|
|
51
|
-
return result;
|
|
52
|
-
}, []);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (mediaType.schema) {
|
|
56
|
-
return [{ summary: 'default', value: generateSchemaExample(mediaType.schema, options) }];
|
|
57
|
-
}
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
/** Hard limit for rendering circular references */
|
|
61
|
-
var MAX_LEVELS_DEEP = 5;
|
|
62
|
-
var genericExampleValues = {
|
|
63
|
-
'date-time': new Date().toISOString(),
|
|
64
|
-
date: (_a = new Date().toISOString().split('T')[0]) !== null && _a !== void 0 ? _a : '1970-01-01',
|
|
65
|
-
email: 'name@gmail.com',
|
|
66
|
-
hostname: 'example.com',
|
|
67
|
-
ipv4: '0.0.0.0',
|
|
68
|
-
ipv6: '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
|
|
69
|
-
uri: 'https://example.com',
|
|
70
|
-
uuid: '123e4567-e89b-12d3-a456-426614174000',
|
|
71
|
-
binary: 'binary',
|
|
72
|
-
byte: 'Ynl0ZXM=',
|
|
73
|
-
password: 'password',
|
|
74
|
-
'idn-email': 'jane.doe@example.com',
|
|
75
|
-
'idn-hostname': 'example.com',
|
|
76
|
-
'iri-reference': '/entitiy/1',
|
|
77
|
-
// https://tools.ietf.org/html/rfc3987
|
|
78
|
-
iri: 'https://example.com/entity/123',
|
|
79
|
-
'json-pointer': '/nested/objects',
|
|
80
|
-
regex: '/[a-z]/',
|
|
81
|
-
// https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
|
|
82
|
-
'relative-json-pointer': '1/nested/objects',
|
|
83
|
-
// full-time in https://tools.ietf.org/html/rfc3339#section-5.6
|
|
84
|
-
time: (_c = (_b = new Date().toISOString().split('T')[1]) === null || _b === void 0 ? void 0 : _b.split('.')[0]) !== null && _c !== void 0 ? _c : '00:00:00Z',
|
|
85
|
-
// either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1
|
|
86
|
-
'uri-reference': '../folder',
|
|
87
|
-
'uri-template': 'https://example.com/{id}',
|
|
88
|
-
'object-id': '6592008029c8c3e4dc76256c',
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* We can use the `format` to generate some random values.
|
|
92
|
-
*/
|
|
93
|
-
function guessFromFormat(schema, fallback) {
|
|
94
|
-
var _a;
|
|
95
|
-
if (fallback === void 0) { fallback = ''; }
|
|
96
|
-
return (_a = genericExampleValues[schema.format]) !== null && _a !== void 0 ? _a : fallback;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* This function takes an OpenAPI schema and generates an example from it
|
|
100
|
-
* Forked from : https://github.com/scalar/scalar/blob/main/packages/oas-utils/src/spec-getters/getExampleFromSchema.ts
|
|
101
|
-
*/
|
|
102
|
-
var getExampleFromSchema = function (schema, options, level, parentSchema, name, resultCache) {
|
|
103
|
-
var _a, _b, _c, _d;
|
|
104
|
-
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
105
|
-
if (level === void 0) { level = 0; }
|
|
106
|
-
if (resultCache === void 0) { resultCache = new WeakMap(); }
|
|
107
|
-
// Store result in the cache, and return the result
|
|
108
|
-
function cache(schema, result) {
|
|
109
|
-
// Avoid unnecessary WeakMap operations for primitive values
|
|
110
|
-
if (typeof result !== 'object' || result === null) {
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
resultCache.set(schema, result);
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
// Check if the result is already cached
|
|
117
|
-
if (resultCache.has(schema)) {
|
|
118
|
-
return resultCache.get(schema);
|
|
119
|
-
}
|
|
120
|
-
// Check whether it’s a circular reference
|
|
121
|
-
if (level === MAX_LEVELS_DEEP + 1) {
|
|
122
|
-
try {
|
|
123
|
-
// Fails if it contains a circular reference
|
|
124
|
-
JSON.stringify(schema);
|
|
125
|
-
}
|
|
126
|
-
catch (_w) {
|
|
127
|
-
return '[Circular Reference]';
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
// Sometimes, we just want the structure and no values.
|
|
131
|
-
// But if `emptyString` is set, we do want to see some values.
|
|
132
|
-
var makeUpRandomData = !!(options === null || options === void 0 ? void 0 : options.emptyString);
|
|
133
|
-
// If the property is deprecated we don't show it in examples.
|
|
134
|
-
if (schema.deprecated || (schema.type === 'array' && ((_e = schema.items) === null || _e === void 0 ? void 0 : _e.deprecated))) {
|
|
135
|
-
return undefined;
|
|
136
|
-
}
|
|
137
|
-
// Check if the property is read-only/write-only
|
|
138
|
-
if (((options === null || options === void 0 ? void 0 : options.mode) === 'write' && schema.readOnly) ||
|
|
139
|
-
((options === null || options === void 0 ? void 0 : options.mode) === 'read' && schema.writeOnly)) {
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
// Use given variables as values
|
|
143
|
-
if (schema['x-variable']) {
|
|
144
|
-
var value = (_f = options === null || options === void 0 ? void 0 : options.variables) === null || _f === void 0 ? void 0 : _f[schema['x-variable']];
|
|
145
|
-
// Return the value if it’s defined
|
|
146
|
-
if (value !== undefined) {
|
|
147
|
-
// Type-casting
|
|
148
|
-
if (schema.type === 'number' || schema.type === 'integer') {
|
|
149
|
-
return Number.parseInt(value, 10);
|
|
150
|
-
}
|
|
151
|
-
return cache(schema, value);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
// Use the first example, if there’s an array
|
|
155
|
-
if (Array.isArray(schema.examples) && schema.examples.length > 0) {
|
|
156
|
-
return cache(schema, schema.examples[0]);
|
|
157
|
-
}
|
|
158
|
-
// Use an example, if there’s one
|
|
159
|
-
if (schema.example !== undefined) {
|
|
160
|
-
return cache(schema, schema.example);
|
|
161
|
-
}
|
|
162
|
-
// Use a default value, if there’s one and it’s a string or number
|
|
163
|
-
if (schema.default !== undefined &&
|
|
164
|
-
['string', 'number', 'boolean'].includes(typeof schema.default)) {
|
|
165
|
-
return cache(schema, schema.default);
|
|
166
|
-
}
|
|
167
|
-
// enum: [ 'available', 'pending', 'sold' ]
|
|
168
|
-
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
169
|
-
return cache(schema, schema.enum[0]);
|
|
170
|
-
}
|
|
171
|
-
// Check if the property is required
|
|
172
|
-
var isObjectOrArray = schema.type === 'object' ||
|
|
173
|
-
schema.type === 'array' ||
|
|
174
|
-
!!((_h = (_g = schema.allOf) === null || _g === void 0 ? void 0 : _g.at) === null || _h === void 0 ? void 0 : _h.call(_g, 0)) ||
|
|
175
|
-
!!((_k = (_j = schema.anyOf) === null || _j === void 0 ? void 0 : _j.at) === null || _k === void 0 ? void 0 : _k.call(_j, 0)) ||
|
|
176
|
-
!!((_m = (_l = schema.oneOf) === null || _l === void 0 ? void 0 : _l.at) === null || _m === void 0 ? void 0 : _m.call(_l, 0));
|
|
177
|
-
if (!isObjectOrArray && (options === null || options === void 0 ? void 0 : options.omitEmptyAndOptionalProperties) === true) {
|
|
178
|
-
var isRequired = schema.required === true ||
|
|
179
|
-
(parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.required) === true ||
|
|
180
|
-
((_o = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.required) === null || _o === void 0 ? void 0 : _o.includes(name !== null && name !== void 0 ? name : schema.name));
|
|
181
|
-
if (!isRequired) {
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// Object
|
|
186
|
-
if (schema.type === 'object' || schema.properties !== undefined) {
|
|
187
|
-
var response = {};
|
|
188
|
-
// Regular properties
|
|
189
|
-
if (schema.properties !== undefined) {
|
|
190
|
-
for (var propertyName in schema.properties) {
|
|
191
|
-
if (Object.prototype.hasOwnProperty.call(schema.properties, propertyName)) {
|
|
192
|
-
var property = schema.properties[propertyName];
|
|
193
|
-
var propertyXmlTagName = (options === null || options === void 0 ? void 0 : options.xml) ? (_p = property.xml) === null || _p === void 0 ? void 0 : _p.name : undefined;
|
|
194
|
-
response[propertyXmlTagName !== null && propertyXmlTagName !== void 0 ? propertyXmlTagName : propertyName] = getExampleFromSchema(property, options, level + 1, schema, propertyName, resultCache);
|
|
195
|
-
if (typeof response[propertyXmlTagName !== null && propertyXmlTagName !== void 0 ? propertyXmlTagName : propertyName] === 'undefined') {
|
|
196
|
-
delete response[propertyXmlTagName !== null && propertyXmlTagName !== void 0 ? propertyXmlTagName : propertyName];
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// Pattern properties (regex)
|
|
202
|
-
if (schema.patternProperties !== undefined) {
|
|
203
|
-
for (var pattern in schema.patternProperties) {
|
|
204
|
-
if (Object.prototype.hasOwnProperty.call(schema.patternProperties, pattern)) {
|
|
205
|
-
var property = schema.patternProperties[pattern];
|
|
206
|
-
// Use the regex pattern as an example key
|
|
207
|
-
var exampleKey = pattern;
|
|
208
|
-
response[exampleKey] = getExampleFromSchema(property, options, level + 1, schema, exampleKey, resultCache);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
// Additional properties
|
|
213
|
-
if (schema.additionalProperties !== undefined) {
|
|
214
|
-
var anyTypeIsValid =
|
|
215
|
-
// true
|
|
216
|
-
schema.additionalProperties === true ||
|
|
217
|
-
// or an empty object {}
|
|
218
|
-
(typeof schema.additionalProperties === 'object' &&
|
|
219
|
-
!Object.keys(schema.additionalProperties).length);
|
|
220
|
-
if (anyTypeIsValid) {
|
|
221
|
-
response.ANY_ADDITIONAL_PROPERTY = 'anything';
|
|
222
|
-
}
|
|
223
|
-
else if (schema.additionalProperties !== false) {
|
|
224
|
-
response.ANY_ADDITIONAL_PROPERTY = getExampleFromSchema(schema.additionalProperties, options, level + 1, undefined, undefined, resultCache);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (schema.anyOf !== undefined) {
|
|
228
|
-
Object.assign(response, getExampleFromSchema(schema.anyOf[0], options, level + 1, undefined, undefined, resultCache));
|
|
229
|
-
}
|
|
230
|
-
else if (schema.oneOf !== undefined) {
|
|
231
|
-
Object.assign(response, getExampleFromSchema(schema.oneOf[0], options, level + 1, undefined, undefined, resultCache));
|
|
232
|
-
}
|
|
233
|
-
else if (schema.allOf !== undefined) {
|
|
234
|
-
Object.assign.apply(Object, __spreadArray([response], schema.allOf
|
|
235
|
-
.map(function (item) {
|
|
236
|
-
return getExampleFromSchema(item, options, level + 1, schema, undefined, resultCache);
|
|
237
|
-
})
|
|
238
|
-
.filter(function (item) { return item !== undefined; }), false));
|
|
239
|
-
}
|
|
240
|
-
return cache(schema, response);
|
|
241
|
-
}
|
|
242
|
-
// Array
|
|
243
|
-
if (schema.type === 'array' || schema.items !== undefined) {
|
|
244
|
-
var itemsXmlTagName_1 = (_r = (_q = schema === null || schema === void 0 ? void 0 : schema.items) === null || _q === void 0 ? void 0 : _q.xml) === null || _r === void 0 ? void 0 : _r.name;
|
|
245
|
-
var wrapItems = !!((options === null || options === void 0 ? void 0 : options.xml) && ((_s = schema.xml) === null || _s === void 0 ? void 0 : _s.wrapped) && itemsXmlTagName_1);
|
|
246
|
-
if (schema.example !== undefined) {
|
|
247
|
-
return cache(schema, wrapItems ? (_a = {}, _a[itemsXmlTagName_1] = schema.example, _a) : schema.example);
|
|
248
|
-
}
|
|
249
|
-
// Check whether the array has a anyOf, oneOf, or allOf rule
|
|
250
|
-
if (schema.items) {
|
|
251
|
-
// First handle allOf separately since it needs special handling
|
|
252
|
-
if (schema.items.allOf) {
|
|
253
|
-
// If the first item is an object type, merge all schemas
|
|
254
|
-
if (schema.items.allOf[0].type === 'object') {
|
|
255
|
-
var mergedExample = getExampleFromSchema({ type: 'object', allOf: schema.items.allOf }, options, level + 1, schema, undefined, resultCache);
|
|
256
|
-
return cache(schema, wrapItems ? [(_b = {}, _b[itemsXmlTagName_1] = mergedExample, _b)] : [mergedExample]);
|
|
257
|
-
}
|
|
258
|
-
// For non-objects (like strings), collect all examples
|
|
259
|
-
var examples = schema.items.allOf
|
|
260
|
-
.map(function (item) {
|
|
261
|
-
return getExampleFromSchema(item, options, level + 1, schema, undefined, resultCache);
|
|
262
|
-
})
|
|
263
|
-
.filter(function (item) { return item !== undefined; });
|
|
264
|
-
return cache(schema, wrapItems
|
|
265
|
-
? examples.map(function (example) {
|
|
266
|
-
var _a;
|
|
267
|
-
return (_a = {}, _a[itemsXmlTagName_1] = example, _a);
|
|
268
|
-
})
|
|
269
|
-
: examples);
|
|
270
|
-
}
|
|
271
|
-
// Handle other rules (anyOf, oneOf)
|
|
272
|
-
var rules = ['anyOf', 'oneOf'];
|
|
273
|
-
for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) {
|
|
274
|
-
var rule = rules_1[_i];
|
|
275
|
-
if (!schema.items[rule]) {
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
var schemas = schema.items[rule].slice(0, 1);
|
|
279
|
-
var exampleFromRule = schemas
|
|
280
|
-
.map(function (item) {
|
|
281
|
-
return getExampleFromSchema(item, options, level + 1, schema, undefined, resultCache);
|
|
282
|
-
})
|
|
283
|
-
.filter(function (item) { return item !== undefined; });
|
|
284
|
-
return cache(schema, wrapItems ? [(_c = {}, _c[itemsXmlTagName_1] = exampleFromRule, _c)] : exampleFromRule);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if ((_t = schema.items) === null || _t === void 0 ? void 0 : _t.type) {
|
|
288
|
-
var exampleFromSchema = getExampleFromSchema(schema.items, options, level + 1, undefined, undefined, resultCache);
|
|
289
|
-
return wrapItems ? [(_d = {}, _d[itemsXmlTagName_1] = exampleFromSchema, _d)] : [exampleFromSchema];
|
|
290
|
-
}
|
|
291
|
-
return [];
|
|
292
|
-
}
|
|
293
|
-
var exampleValues = {
|
|
294
|
-
string: makeUpRandomData ? guessFromFormat(schema, options === null || options === void 0 ? void 0 : options.emptyString) : '',
|
|
295
|
-
boolean: true,
|
|
296
|
-
integer: (_u = schema.min) !== null && _u !== void 0 ? _u : 1,
|
|
297
|
-
number: (_v = schema.min) !== null && _v !== void 0 ? _v : 1,
|
|
298
|
-
array: [],
|
|
299
|
-
};
|
|
300
|
-
if (schema.type !== undefined && exampleValues[schema.type] !== undefined) {
|
|
301
|
-
return cache(schema, exampleValues[schema.type]);
|
|
302
|
-
}
|
|
303
|
-
var discriminateSchema = schema.oneOf || schema.anyOf;
|
|
304
|
-
// Check if property has the `oneOf` | `anyOf` key
|
|
305
|
-
if (Array.isArray(discriminateSchema) && discriminateSchema.length > 0) {
|
|
306
|
-
// Get the first item from the `oneOf` | `anyOf` array
|
|
307
|
-
var firstOneOfItem = discriminateSchema[0];
|
|
308
|
-
// Return an example for the first item
|
|
309
|
-
return getExampleFromSchema(firstOneOfItem, options, level + 1, undefined, undefined, resultCache);
|
|
310
|
-
}
|
|
311
|
-
// Check if schema has the `allOf` key
|
|
312
|
-
if (Array.isArray(schema.allOf)) {
|
|
313
|
-
var example_1 = null;
|
|
314
|
-
// Loop through all `allOf` schemas
|
|
315
|
-
schema.allOf.forEach(function (allOfItem) {
|
|
316
|
-
// Return an example from the schema
|
|
317
|
-
var newExample = getExampleFromSchema(allOfItem, options, level + 1, undefined, undefined, resultCache);
|
|
318
|
-
// Merge or overwrite the example
|
|
319
|
-
example_1 =
|
|
320
|
-
typeof newExample === 'object' && typeof example_1 === 'object'
|
|
321
|
-
? __assign(__assign({}, (example_1 !== null && example_1 !== void 0 ? example_1 : {})), newExample) : Array.isArray(newExample) && Array.isArray(example_1)
|
|
322
|
-
? __spreadArray(__spreadArray([], (example_1 !== null && example_1 !== void 0 ? example_1 : {}), true), newExample, true) : newExample;
|
|
323
|
-
});
|
|
324
|
-
return cache(schema, example_1);
|
|
325
|
-
}
|
|
326
|
-
// Check if schema is a union type
|
|
327
|
-
if (Array.isArray(schema.type)) {
|
|
328
|
-
// Return null if the type is nullable
|
|
329
|
-
if (schema.type.includes('null')) {
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
// Return an example for the first type in the union
|
|
333
|
-
var exampleValue = exampleValues[schema.type[0]];
|
|
334
|
-
if (exampleValue !== undefined) {
|
|
335
|
-
return cache(schema, exampleValue);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
// Warn if the type is unknown …
|
|
339
|
-
// console.warn(`[getExampleFromSchema] Unknown property type "${schema.type}".`)
|
|
340
|
-
// … and just return null for now.
|
|
341
|
-
return null;
|
|
342
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
-
import type { OpenAPIClientContext } from './context';
|
|
3
|
-
export declare function getDisclosureLabel(props: {
|
|
4
|
-
schema: OpenAPIV3.SchemaObject;
|
|
5
|
-
isExpanded: boolean;
|
|
6
|
-
context: OpenAPIClientContext;
|
|
7
|
-
}): string;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { tString } from './translate';
|
|
3
|
-
export function getDisclosureLabel(props) {
|
|
4
|
-
var schema = props.schema, isExpanded = props.isExpanded, context = props.context;
|
|
5
|
-
var label;
|
|
6
|
-
if (schema.type === 'array' && !!schema.items) {
|
|
7
|
-
if (schema.items.oneOf) {
|
|
8
|
-
label = tString(context.translation, 'available_items').toLowerCase();
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
label = tString(context.translation, 'properties').toLowerCase();
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
label = tString(context.translation, 'properties').toLowerCase();
|
|
16
|
-
}
|
|
17
|
-
return tString(context.translation, isExpanded ? 'hide' : 'show', label);
|
|
18
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type Key = string | number;
|
|
2
|
-
type State = {
|
|
3
|
-
key: Key | null;
|
|
4
|
-
};
|
|
5
|
-
type Actions = {
|
|
6
|
-
setKey: (key: Key | null) => void;
|
|
7
|
-
};
|
|
8
|
-
export type Store = State & Actions;
|
|
9
|
-
export declare const getOrCreateStoreByKey: (storeKey: string, initialKey?: Key) => import("zustand").StoreApi<Store>;
|
|
10
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createStore } from 'zustand';
|
|
2
|
-
var createStateStore = function (initial) {
|
|
3
|
-
return createStore()(function (set) { return ({
|
|
4
|
-
key: initial !== null && initial !== void 0 ? initial : null,
|
|
5
|
-
setKey: function (key) {
|
|
6
|
-
set(function () { return ({ key: key }); });
|
|
7
|
-
},
|
|
8
|
-
}); });
|
|
9
|
-
};
|
|
10
|
-
var defaultStores = new Map();
|
|
11
|
-
var createStateStoreFactory = function (stores) {
|
|
12
|
-
return function (storeKey, initialKey) {
|
|
13
|
-
if (!stores.has(storeKey)) {
|
|
14
|
-
stores.set(storeKey, createStateStore(initialKey));
|
|
15
|
-
}
|
|
16
|
-
return stores.get(storeKey);
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export var getOrCreateStoreByKey = createStateStoreFactory(defaultStores);
|
package/dist/json2xml.d.ts
DELETED
package/dist/json2xml.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { fromJSON, toJSON } from 'flatted';
|
|
2
|
-
import type { Filesystem, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
|
|
3
|
-
import type { OpenAPIOperationData } from './types';
|
|
4
|
-
export { fromJSON, toJSON };
|
|
5
|
-
/**
|
|
6
|
-
* Resolve an OpenAPI operation in a file and compile it to a more usable format.
|
|
7
|
-
*/
|
|
8
|
-
export declare function resolveOpenAPIOperation(filesystem: Filesystem<OpenAPIV3xDocument>, operationDescriptor: {
|
|
9
|
-
path: string;
|
|
10
|
-
method: string;
|
|
11
|
-
}): Promise<OpenAPIOperationData | null>;
|