@gitbook/react-openapi 1.4.3 → 1.5.2
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 +36 -0
- package/dist/InteractiveSection.js +59 -0
- package/dist/Markdown.js +10 -0
- package/dist/OpenAPICodeSample.js +219 -0
- package/dist/OpenAPICodeSampleInteractive.js +66 -0
- package/dist/OpenAPICodeSampleSelector.js +45 -0
- package/dist/OpenAPICopyButton.js +39 -0
- package/dist/OpenAPIDisclosure.js +30 -0
- package/dist/OpenAPIDisclosureGroup.js +75 -0
- package/dist/OpenAPIExample.js +41 -0
- package/dist/OpenAPIMediaType.js +58 -0
- package/dist/OpenAPIOperation.d.ts +12 -7
- package/dist/OpenAPIOperation.js +30 -0
- package/dist/OpenAPIOperationContext.d.ts +10 -6
- package/dist/OpenAPIOperationContext.js +30 -0
- package/dist/OpenAPIPath.js +51 -0
- package/dist/OpenAPIPrefillContextProvider.d.ts +11 -7
- package/dist/OpenAPIPrefillContextProvider.js +25 -0
- package/dist/OpenAPIRequestBody.js +28 -0
- package/dist/OpenAPIRequestBodyHeaderType.js +23 -0
- package/dist/OpenAPIResponse.js +39 -0
- package/dist/OpenAPIResponseExample.js +75 -0
- package/dist/OpenAPIResponseExampleContent.js +61 -0
- package/dist/OpenAPIResponses.js +61 -0
- package/dist/OpenAPISchema.js +373 -0
- package/dist/OpenAPISchemaName.js +45 -0
- package/dist/OpenAPISchemaServer.js +13 -0
- package/dist/OpenAPISecurities.js +124 -0
- package/dist/OpenAPISelect.js +45 -0
- package/dist/OpenAPISpec.js +73 -0
- package/dist/OpenAPIWebhook.d.ts +12 -7
- package/dist/OpenAPIWebhook.js +28 -0
- package/dist/OpenAPIWebhookExample.js +40 -0
- package/dist/ScalarApiButton.js +87 -0
- package/dist/StaticSection.js +37 -0
- package/dist/code-samples.js +267 -419
- package/dist/common/OpenAPIColumnSpec.js +23 -0
- package/dist/common/OpenAPIOperationDescription.js +18 -0
- package/dist/common/OpenAPIStability.js +17 -0
- package/dist/common/OpenAPISummary.js +27 -0
- package/dist/contentTypeChecks.js +24 -20
- package/dist/context.d.ts +68 -72
- package/dist/context.js +25 -39
- package/dist/decycle.js +39 -68
- package/dist/dereference.js +20 -64
- package/dist/generateSchemaExample.js +188 -332
- package/dist/getDisclosureLabel.js +15 -16
- package/dist/getOrCreateStoreByKey.js +20 -17
- package/dist/index.d.ts +12 -10
- package/dist/index.js +11 -8
- package/dist/json2xml.js +10 -5
- package/dist/resolveOpenAPIOperation.d.ts +11 -7
- package/dist/resolveOpenAPIOperation.js +88 -159
- package/dist/resolveOpenAPIWebhook.d.ts +11 -7
- package/dist/resolveOpenAPIWebhook.js +41 -116
- package/dist/schemas/OpenAPISchemaItem.js +26 -0
- package/dist/schemas/OpenAPISchemas.d.ts +16 -11
- package/dist/schemas/OpenAPISchemas.js +57 -0
- package/dist/schemas/resolveOpenAPISchemas.d.ts +9 -4
- package/dist/schemas/resolveOpenAPISchemas.js +15 -59
- package/dist/stringifyOpenAPI.js +12 -13
- package/dist/translate.js +43 -0
- package/dist/translations/de.js +47 -42
- package/dist/translations/en.d.ts +46 -42
- package/dist/translations/en.js +47 -42
- package/dist/translations/es.js +47 -42
- package/dist/translations/fr.js +47 -42
- package/dist/translations/index.d.ts +404 -391
- package/dist/translations/index.js +28 -24
- package/dist/translations/ja.js +47 -42
- package/dist/translations/nl.js +47 -42
- package/dist/translations/no.js +47 -42
- package/dist/translations/pt-br.js +47 -42
- package/dist/translations/types.d.ts +7 -5
- package/dist/translations/zh.js +47 -42
- package/dist/types.d.ts +30 -24
- package/dist/util/example.js +84 -0
- package/dist/util/server.js +32 -38
- package/dist/util/tryit-prefill.js +135 -121
- package/dist/utils.js +135 -196
- package/package.json +18 -11
- 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.jsx +0 -25
- 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.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.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/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/decycle.d.ts +0 -2
- package/dist/dereference.d.ts +0 -5
- package/dist/generateSchemaExample.d.ts +0 -45
- package/dist/getDisclosureLabel.d.ts +0 -7
- package/dist/getOrCreateStoreByKey.d.ts +0 -10
- package/dist/json2xml.d.ts +0 -4
- package/dist/schemas/OpenAPISchemaItem.d.ts +0 -7
- package/dist/schemas/OpenAPISchemaItem.jsx +0 -16
- package/dist/schemas/OpenAPISchemas.jsx +0 -59
- package/dist/schemas/index.d.ts +0 -2
- package/dist/schemas/index.js +0 -2
- package/dist/stringifyOpenAPI.d.ts +0 -4
- package/dist/translate.d.ts +0 -10
- package/dist/translate.jsx +0 -75
- package/dist/translations/de.d.ts +0 -43
- package/dist/translations/es.d.ts +0 -43
- package/dist/translations/fr.d.ts +0 -43
- package/dist/translations/ja.d.ts +0 -43
- package/dist/translations/nl.d.ts +0 -43
- package/dist/translations/no.d.ts +0 -43
- package/dist/translations/pt-br.d.ts +0 -43
- package/dist/translations/types.js +0 -1
- package/dist/translations/zh.d.ts +0 -43
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- 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/tryit-prefill.d.ts +0 -20
- package/dist/utils.d.ts +0 -50
- 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/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { checkIsValidLocale } from "./translations/index.js";
|
|
2
|
+
import { OpenAPIContextInput } from "./context.js";
|
|
3
|
+
import { OpenAPISchemas } from "./schemas/OpenAPISchemas.js";
|
|
4
|
+
import { resolveOpenAPISchemas } from "./schemas/resolveOpenAPISchemas.js";
|
|
5
|
+
import { OpenAPIOperationData, OpenAPIWebhookData } from "./types.js";
|
|
6
|
+
import { OpenAPIOperation } from "./OpenAPIOperation.js";
|
|
7
|
+
import { OpenAPIWebhook } from "./OpenAPIWebhook.js";
|
|
8
|
+
import { OpenAPIOperationContextProvider, useOpenAPIOperationContext } from "./OpenAPIOperationContext.js";
|
|
9
|
+
import { OpenAPIPrefillContextProvider, PrefillInputContextData, useOpenAPIPrefillContext } from "./OpenAPIPrefillContextProvider.js";
|
|
10
|
+
import { resolveOpenAPIOperation } from "./resolveOpenAPIOperation.js";
|
|
11
|
+
import { resolveOpenAPIWebhook } from "./resolveOpenAPIWebhook.js";
|
|
12
|
+
export { type OpenAPIContextInput, OpenAPIOperation, OpenAPIOperationContextProvider, type OpenAPIOperationData, OpenAPIPrefillContextProvider, OpenAPISchemas, OpenAPIWebhook, type OpenAPIWebhookData, PrefillInputContextData, checkIsValidLocale, resolveOpenAPIOperation, resolveOpenAPISchemas, resolveOpenAPIWebhook, useOpenAPIOperationContext, useOpenAPIPrefillContext };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { checkIsValidLocale } from "./translations/index.js";
|
|
2
|
+
import { OpenAPISchemas } from "./schemas/OpenAPISchemas.js";
|
|
3
|
+
import { resolveOpenAPISchemas } from "./schemas/resolveOpenAPISchemas.js";
|
|
4
|
+
import { OpenAPIOperationContextProvider, useOpenAPIOperationContext } from "./OpenAPIOperationContext.js";
|
|
5
|
+
import { OpenAPIPrefillContextProvider, useOpenAPIPrefillContext } from "./OpenAPIPrefillContextProvider.js";
|
|
6
|
+
import { OpenAPIOperation } from "./OpenAPIOperation.js";
|
|
7
|
+
import { OpenAPIWebhook } from "./OpenAPIWebhook.js";
|
|
8
|
+
import { resolveOpenAPIOperation } from "./resolveOpenAPIOperation.js";
|
|
9
|
+
import { resolveOpenAPIWebhook } from "./resolveOpenAPIWebhook.js";
|
|
10
|
+
|
|
11
|
+
export { OpenAPIOperation, OpenAPIOperationContextProvider, OpenAPIPrefillContextProvider, OpenAPISchemas, OpenAPIWebhook, checkIsValidLocale, resolveOpenAPIOperation, resolveOpenAPISchemas, resolveOpenAPIWebhook, useOpenAPIOperationContext, useOpenAPIPrefillContext };
|
package/dist/json2xml.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { jsXml } from
|
|
1
|
+
import { jsXml } from "json-xml-parse";
|
|
2
|
+
|
|
3
|
+
//#region src/json2xml.ts
|
|
2
4
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
* This function converts an object to XML.
|
|
6
|
+
*/
|
|
7
|
+
function json2xml(data) {
|
|
8
|
+
return jsXml.toXmlString(data, { beautify: true });
|
|
7
9
|
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { json2xml };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { OpenAPIOperationData } from "./types.js";
|
|
2
|
+
import { Filesystem, OpenAPIV3xDocument } from "@gitbook/openapi-parser";
|
|
3
|
+
import "flatted";
|
|
4
|
+
|
|
5
|
+
//#region src/resolveOpenAPIOperation.d.ts
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Resolve an OpenAPI operation in a file and compile it to a more usable format.
|
|
7
9
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
declare function resolveOpenAPIOperation(filesystem: Filesystem<OpenAPIV3xDocument>, operationDescriptor: {
|
|
11
|
+
path: string;
|
|
12
|
+
method: string;
|
|
11
13
|
}): Promise<OpenAPIOperationData | null>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { resolveOpenAPIOperation };
|
|
@@ -1,173 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
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);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
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;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { fromJSON, toJSON } from 'flatted';
|
|
58
|
-
import { dereferenceFilesystem } from './dereference';
|
|
59
|
-
import { checkIsReference } from './utils';
|
|
60
|
-
export { fromJSON, toJSON };
|
|
1
|
+
import { checkIsReference } from "./utils.js";
|
|
2
|
+
import { dereferenceFilesystem } from "./dereference.js";
|
|
3
|
+
import "flatted";
|
|
4
|
+
|
|
5
|
+
//#region src/resolveOpenAPIOperation.ts
|
|
61
6
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
servers: servers,
|
|
108
|
-
operation: operation,
|
|
109
|
-
method: method,
|
|
110
|
-
path: path,
|
|
111
|
-
securities: securities,
|
|
112
|
-
'x-codeSamples': typeof schema['x-codeSamples'] === 'boolean' ? schema['x-codeSamples'] : undefined,
|
|
113
|
-
'x-hideTryItPanel': typeof schema['x-hideTryItPanel'] === 'boolean'
|
|
114
|
-
? schema['x-hideTryItPanel']
|
|
115
|
-
: undefined,
|
|
116
|
-
}];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
7
|
+
* Resolve an OpenAPI operation in a file and compile it to a more usable format.
|
|
8
|
+
*/
|
|
9
|
+
async function resolveOpenAPIOperation(filesystem, operationDescriptor) {
|
|
10
|
+
const { path, method } = operationDescriptor;
|
|
11
|
+
const schema = await dereferenceFilesystem(filesystem);
|
|
12
|
+
let operation = getOperationByPathAndMethod(schema, path, method);
|
|
13
|
+
if (!operation) return null;
|
|
14
|
+
const commonParameters = getPathObjectParameter(schema, path);
|
|
15
|
+
if (commonParameters) operation = {
|
|
16
|
+
...operation,
|
|
17
|
+
parameters: [...commonParameters, ...operation.parameters ?? []]
|
|
18
|
+
};
|
|
19
|
+
const servers = "servers" in schema ? schema.servers ?? [] : [];
|
|
20
|
+
const schemaSecurity = Array.isArray(schema.security) ? schema.security : schema.security ? [schema.security] : [];
|
|
21
|
+
const security = operation.security ?? schemaSecurity;
|
|
22
|
+
const isOptionalSecurity = security.some((entry) => Object.keys(entry).length === 0);
|
|
23
|
+
const flatSecurities = flattenSecurities(security);
|
|
24
|
+
const securities = [];
|
|
25
|
+
for (const entry of flatSecurities) {
|
|
26
|
+
const [securityKey, operationScopes] = Object.entries(entry)[0] ?? [];
|
|
27
|
+
if (securityKey) {
|
|
28
|
+
const securityScheme = schema.components?.securitySchemes?.[securityKey];
|
|
29
|
+
const scopes = resolveSecurityScopes({
|
|
30
|
+
securityScheme,
|
|
31
|
+
operationScopes
|
|
32
|
+
});
|
|
33
|
+
securities.push([securityKey, {
|
|
34
|
+
...securityScheme,
|
|
35
|
+
required: !isOptionalSecurity,
|
|
36
|
+
scopes
|
|
37
|
+
}]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
servers,
|
|
42
|
+
operation: {
|
|
43
|
+
...operation,
|
|
44
|
+
security
|
|
45
|
+
},
|
|
46
|
+
method,
|
|
47
|
+
path,
|
|
48
|
+
securities,
|
|
49
|
+
"x-codeSamples": typeof schema["x-codeSamples"] === "boolean" ? schema["x-codeSamples"] : void 0,
|
|
50
|
+
"x-hideTryItPanel": typeof schema["x-hideTryItPanel"] === "boolean" ? schema["x-hideTryItPanel"] : void 0
|
|
51
|
+
};
|
|
120
52
|
}
|
|
121
53
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
54
|
+
* Get a path object from its path.
|
|
55
|
+
*/
|
|
124
56
|
function getPathObject(schema, path) {
|
|
125
|
-
|
|
126
|
-
if ((_a = schema.paths) === null || _a === void 0 ? void 0 : _a[path]) {
|
|
127
|
-
return schema.paths[path];
|
|
128
|
-
}
|
|
129
|
-
return null;
|
|
57
|
+
return schema.paths?.[path] || null;
|
|
130
58
|
}
|
|
131
59
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
60
|
+
* Resolve parameters from a path in an OpenAPI schema.
|
|
61
|
+
*/
|
|
134
62
|
function getPathObjectParameter(schema, path) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
63
|
+
const pathObject = getPathObject(schema, path);
|
|
64
|
+
if (pathObject?.parameters) return pathObject.parameters;
|
|
65
|
+
return null;
|
|
140
66
|
}
|
|
141
67
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
68
|
+
* Get an operation by its path and method.
|
|
69
|
+
*/
|
|
144
70
|
function getOperationByPathAndMethod(schema, path, method) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
var normalizedMethod = method.toLowerCase();
|
|
151
|
-
if (!pathObject[normalizedMethod]) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
return pathObject[normalizedMethod];
|
|
71
|
+
const pathObject = getPathObject(schema, path);
|
|
72
|
+
if (!pathObject) return null;
|
|
73
|
+
const normalizedMethod = method.toLowerCase();
|
|
74
|
+
if (!pathObject[normalizedMethod]) return null;
|
|
75
|
+
return pathObject[normalizedMethod];
|
|
155
76
|
}
|
|
156
77
|
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
78
|
+
* Flatten security objects in case they are nested.
|
|
79
|
+
* @example [{bearerAuth:[], basicAuth:[]}] => [{ bearerAuth: [] }, { basicAuth: [] }]
|
|
80
|
+
*/
|
|
160
81
|
function flattenSecurities(security) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return Object.entries(securityObject).map(function (_a) {
|
|
166
|
-
var _b;
|
|
167
|
-
var authType = _a[0], config = _a[1];
|
|
168
|
-
return (_b = {},
|
|
169
|
-
_b[authType] = config,
|
|
170
|
-
_b);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
82
|
+
if (!Array.isArray(security) || security.length === 0) return [];
|
|
83
|
+
return security.flatMap((securityObject) => {
|
|
84
|
+
return Object.entries(securityObject).map(([authType, config]) => ({ [authType]: config }));
|
|
85
|
+
});
|
|
173
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolve the scopes for a security scheme.
|
|
89
|
+
*/
|
|
90
|
+
function resolveSecurityScopes({ securityScheme, operationScopes }) {
|
|
91
|
+
if (!securityScheme || checkIsReference(securityScheme) || isOAuthSecurityScheme(securityScheme)) return null;
|
|
92
|
+
return operationScopes?.map((scope) => [scope, void 0]) || [];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Check if a security scheme is an OAuth or OpenID Connect security scheme.
|
|
96
|
+
*/
|
|
97
|
+
function isOAuthSecurityScheme(securityScheme) {
|
|
98
|
+
return securityScheme.type === "oauth2";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { resolveOpenAPIOperation };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { OpenAPIWebhookData } from "./types.js";
|
|
2
|
+
import { Filesystem, OpenAPIV3xDocument } from "@gitbook/openapi-parser";
|
|
3
|
+
import "flatted";
|
|
4
|
+
|
|
5
|
+
//#region src/resolveOpenAPIWebhook.d.ts
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Resolve an OpenAPI webhook in a file and compile it to a more usable format.
|
|
7
9
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
declare function resolveOpenAPIWebhook(filesystem: Filesystem<OpenAPIV3xDocument>, webhookDescriptor: {
|
|
11
|
+
name: string;
|
|
12
|
+
method: string;
|
|
11
13
|
}): Promise<OpenAPIWebhookData | null>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { resolveOpenAPIWebhook };
|
|
@@ -1,127 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
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);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
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;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { fromJSON, toJSON } from 'flatted';
|
|
58
|
-
import { dereferenceFilesystem } from './dereference';
|
|
59
|
-
export { fromJSON, toJSON };
|
|
1
|
+
import { dereferenceFilesystem } from "./dereference.js";
|
|
2
|
+
import "flatted";
|
|
3
|
+
|
|
4
|
+
//#region src/resolveOpenAPIWebhook.ts
|
|
60
5
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (commonParameters) {
|
|
80
|
-
operation = __assign(__assign({}, operation), { parameters: __spreadArray(__spreadArray([], commonParameters, true), ((_a = operation.parameters) !== null && _a !== void 0 ? _a : []), true) });
|
|
81
|
-
}
|
|
82
|
-
servers = 'servers' in schema ? ((_b = schema.servers) !== null && _b !== void 0 ? _b : []) : [];
|
|
83
|
-
return [2 /*return*/, {
|
|
84
|
-
servers: servers,
|
|
85
|
-
operation: operation,
|
|
86
|
-
method: method,
|
|
87
|
-
name: name,
|
|
88
|
-
}];
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
6
|
+
* Resolve an OpenAPI webhook in a file and compile it to a more usable format.
|
|
7
|
+
*/
|
|
8
|
+
async function resolveOpenAPIWebhook(filesystem, webhookDescriptor) {
|
|
9
|
+
const { name, method } = webhookDescriptor;
|
|
10
|
+
const schema = await dereferenceFilesystem(filesystem);
|
|
11
|
+
let operation = getWebhookByNameAndMethod(schema, name, method);
|
|
12
|
+
if (!operation) return null;
|
|
13
|
+
const commonParameters = getPathObjectParameter(schema, name);
|
|
14
|
+
if (commonParameters) operation = {
|
|
15
|
+
...operation,
|
|
16
|
+
parameters: [...commonParameters, ...operation.parameters ?? []]
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
servers: "servers" in schema ? schema.servers ?? [] : [],
|
|
20
|
+
operation,
|
|
21
|
+
method,
|
|
22
|
+
name
|
|
23
|
+
};
|
|
92
24
|
}
|
|
93
25
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
26
|
+
* Get a path object from its path.
|
|
27
|
+
*/
|
|
96
28
|
function getPathObject(schema, name) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return schema.webhooks[name];
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
29
|
+
if (schema.webhooks?.[name]) return schema.webhooks[name];
|
|
30
|
+
return null;
|
|
102
31
|
}
|
|
103
32
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
33
|
+
* Resolve parameters from a path in an OpenAPI schema.
|
|
34
|
+
*/
|
|
106
35
|
function getPathObjectParameter(schema, path) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
36
|
+
const pathObject = getPathObject(schema, path);
|
|
37
|
+
if (pathObject?.parameters) return pathObject.parameters;
|
|
38
|
+
return null;
|
|
112
39
|
}
|
|
113
40
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
41
|
+
* Get an operation by its path and method.
|
|
42
|
+
*/
|
|
116
43
|
function getWebhookByNameAndMethod(schema, name, method) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var normalizedMethod = method.toLowerCase();
|
|
123
|
-
if (!pathObject[normalizedMethod]) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
return pathObject[normalizedMethod];
|
|
44
|
+
const pathObject = getPathObject(schema, name);
|
|
45
|
+
if (!pathObject) return null;
|
|
46
|
+
const normalizedMethod = method.toLowerCase();
|
|
47
|
+
if (!pathObject[normalizedMethod]) return null;
|
|
48
|
+
return pathObject[normalizedMethod];
|
|
127
49
|
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { resolveOpenAPIWebhook };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { OpenAPIDisclosure } from "../OpenAPIDisclosure.js";
|
|
5
|
+
import { getDisclosureLabel } from "../getDisclosureLabel.js";
|
|
6
|
+
import { OpenAPIRootSchema } from "../OpenAPISchemaServer.js";
|
|
7
|
+
import { Section, SectionBody } from "../StaticSection.js";
|
|
8
|
+
|
|
9
|
+
//#region src/schemas/OpenAPISchemaItem.tsx
|
|
10
|
+
function OpenAPISchemaItem(props) {
|
|
11
|
+
const { schema, context, name } = props;
|
|
12
|
+
return <OpenAPIDisclosure className="openapi-schemas-disclosure" key={name} icon={context.icons.plus} header={name} label={(isExpanded) => getDisclosureLabel({
|
|
13
|
+
schema,
|
|
14
|
+
isExpanded,
|
|
15
|
+
context
|
|
16
|
+
})}>
|
|
17
|
+
<Section className="openapi-section-schemas">
|
|
18
|
+
<SectionBody>
|
|
19
|
+
<OpenAPIRootSchema schema={schema} context={context} />
|
|
20
|
+
</SectionBody>
|
|
21
|
+
</Section>
|
|
22
|
+
</OpenAPIDisclosure>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { OpenAPISchemaItem };
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { OpenAPIContextInput } from "../context.js";
|
|
2
|
+
import * as react2 from "react";
|
|
3
|
+
import { OpenAPISchema } from "@gitbook/openapi-parser";
|
|
4
|
+
|
|
5
|
+
//#region src/schemas/OpenAPISchemas.d.ts
|
|
3
6
|
/**
|
|
4
7
|
* OpenAPI Schemas component.
|
|
5
8
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}):
|
|
9
|
+
declare function OpenAPISchemas(props: {
|
|
10
|
+
className?: string;
|
|
11
|
+
schemas: OpenAPISchema[];
|
|
12
|
+
context: OpenAPIContextInput;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to show the schema directly if there is only one.
|
|
15
|
+
*/
|
|
16
|
+
grouped?: boolean;
|
|
17
|
+
}): react2.JSX.Element | null;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { OpenAPISchemas };
|