@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t } from "../translate.js";
|
|
2
|
+
import { getOpenAPIClientContext } from "../context.js";
|
|
3
|
+
import { OpenAPISpec } from "../OpenAPISpec.js";
|
|
4
|
+
import { OpenAPIOperationDescription } from "./OpenAPIOperationDescription.js";
|
|
5
|
+
|
|
6
|
+
//#region src/common/OpenAPIColumnSpec.tsx
|
|
7
|
+
function OpenAPIColumnSpec(props) {
|
|
8
|
+
const { data, context } = props;
|
|
9
|
+
const { operation } = data;
|
|
10
|
+
const clientContext = getOpenAPIClientContext(context);
|
|
11
|
+
return <div className="openapi-column-spec">
|
|
12
|
+
{operation["x-deprecated-sunset"] ? <div className="openapi-deprecated-sunset openapi-description openapi-markdown">
|
|
13
|
+
{t(context.translation, "deprecated_and_sunset_on", [<span key="date" className="openapi-deprecated-sunset-date">
|
|
14
|
+
{operation["x-deprecated-sunset"]}
|
|
15
|
+
</span>])}
|
|
16
|
+
</div> : null}
|
|
17
|
+
<OpenAPIOperationDescription operation={operation} context={context} />
|
|
18
|
+
<OpenAPISpec data={data} context={clientContext} />
|
|
19
|
+
</div>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { OpenAPIColumnSpec };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Markdown } from "../Markdown.js";
|
|
2
|
+
import { resolveDescription } from "../utils.js";
|
|
3
|
+
|
|
4
|
+
//#region src/common/OpenAPIOperationDescription.tsx
|
|
5
|
+
function OpenAPIOperationDescription(props) {
|
|
6
|
+
const { operation } = props;
|
|
7
|
+
if (operation["x-gitbook-description-document"]) return <div className="openapi-intro">
|
|
8
|
+
{props.context.renderDocument({ document: operation["x-gitbook-description-document"] })}
|
|
9
|
+
</div>;
|
|
10
|
+
const description = resolveDescription(operation);
|
|
11
|
+
if (!description) return null;
|
|
12
|
+
return <div className="openapi-intro">
|
|
13
|
+
<Markdown className="openapi-description" source={description} />
|
|
14
|
+
</div>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { OpenAPIOperationDescription };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/common/OpenAPIStability.tsx
|
|
2
|
+
const stabilityEnum = {
|
|
3
|
+
experimental: "Experimental",
|
|
4
|
+
alpha: "Alpha",
|
|
5
|
+
beta: "Beta"
|
|
6
|
+
};
|
|
7
|
+
function OpenAPIStability(props) {
|
|
8
|
+
const { stability } = props;
|
|
9
|
+
const foundStability = stabilityEnum[stability];
|
|
10
|
+
if (!foundStability) return null;
|
|
11
|
+
return <div className={`openapi-stability openapi-stability-${foundStability.toLowerCase()}`}>
|
|
12
|
+
{foundStability}
|
|
13
|
+
</div>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { OpenAPIStability };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OpenAPIPath } from "../OpenAPIPath.js";
|
|
2
|
+
import { OpenAPIStability } from "./OpenAPIStability.js";
|
|
3
|
+
|
|
4
|
+
//#region src/common/OpenAPISummary.tsx
|
|
5
|
+
function OpenAPISummary(props) {
|
|
6
|
+
const { data, context } = props;
|
|
7
|
+
const { operation } = data;
|
|
8
|
+
const title = (() => {
|
|
9
|
+
if (operation.summary) return operation.summary;
|
|
10
|
+
if ("name" in data) return data.name;
|
|
11
|
+
})();
|
|
12
|
+
return <div className="openapi-summary" id={operation.summary ? void 0 : context.id}>
|
|
13
|
+
{(operation.deprecated || operation["x-stability"]) && <div className="openapi-summary-tags">
|
|
14
|
+
{operation.deprecated && <div className="openapi-deprecated">Deprecated</div>}
|
|
15
|
+
{operation["x-stability"] && <OpenAPIStability stability={operation["x-stability"]} />}
|
|
16
|
+
</div>}
|
|
17
|
+
{title ? context.renderHeading({
|
|
18
|
+
deprecated: operation.deprecated ?? false,
|
|
19
|
+
stability: operation["x-stability"],
|
|
20
|
+
title
|
|
21
|
+
}) : null}
|
|
22
|
+
{"path" in data ? <OpenAPIPath data={data} context={context} /> : null}
|
|
23
|
+
</div>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { OpenAPISummary };
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/contentTypeChecks.ts
|
|
2
|
+
function isJSON(contentType) {
|
|
3
|
+
return contentType?.toLowerCase().includes("application/json") || false;
|
|
3
4
|
}
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
function isXML(contentType) {
|
|
6
|
+
return contentType?.toLowerCase().includes("application/xml") || false;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
function isYAML(contentType) {
|
|
9
|
+
return contentType?.toLowerCase().includes("application/yaml") || false;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
function isGraphQL(contentType) {
|
|
12
|
+
return contentType?.toLowerCase().includes("application/graphql") || false;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
function isCSV(contentType) {
|
|
15
|
+
return contentType?.toLowerCase().includes("text/csv") || false;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
function isPDF(contentType) {
|
|
18
|
+
return contentType?.toLowerCase().includes("application/pdf") || false;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
function isText(contentType) {
|
|
21
|
+
return contentType?.toLowerCase().includes("text/plain") || false;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
function isFormUrlEncoded(contentType) {
|
|
24
|
+
return contentType?.toLowerCase().includes("application/x-www-form-urlencoded") || false;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
function isFormData(contentType) {
|
|
27
|
+
return !!contentType && contentType.toLowerCase().includes("multipart/form-data");
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
function isPlainObject(value) {
|
|
30
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { isCSV, isFormData, isFormUrlEncoded, isGraphQL, isJSON, isPDF, isPlainObject, isText, isXML, isYAML };
|
package/dist/context.d.ts
CHANGED
|
@@ -1,75 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { Translation } from "./translations/types.js";
|
|
2
|
+
import { TranslationLocale } from "./translations/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/context.d.ts
|
|
5
|
+
interface OpenAPIClientContext {
|
|
6
|
+
/**
|
|
7
|
+
* The translation language to use.
|
|
8
|
+
*/
|
|
9
|
+
translation: Translation;
|
|
10
|
+
/**
|
|
11
|
+
* Icons used in the block.
|
|
12
|
+
*/
|
|
13
|
+
icons: {
|
|
14
|
+
chevronDown: React.ReactNode;
|
|
15
|
+
chevronRight: React.ReactNode;
|
|
16
|
+
plus: React.ReactNode;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Force all sections to be opened by default.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
defaultInteractiveOpened?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The key of the block
|
|
25
|
+
*/
|
|
26
|
+
blockKey?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Optional id attached to the heading and used as an anchor.
|
|
29
|
+
*/
|
|
30
|
+
id?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Mark the context as a client context.
|
|
33
|
+
*/
|
|
34
|
+
$$isClientContext$$: true;
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
36
|
+
interface OpenAPIContext extends Omit<OpenAPIClientContext, '$$isClientContext$$'> {
|
|
37
|
+
/**
|
|
38
|
+
* Render a code block.
|
|
39
|
+
*/
|
|
40
|
+
renderCodeBlock: (props: {
|
|
41
|
+
code: string;
|
|
42
|
+
syntax: string;
|
|
43
|
+
}) => React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Render the heading of the operation.
|
|
46
|
+
*/
|
|
47
|
+
renderHeading: (props: {
|
|
48
|
+
deprecated: boolean;
|
|
49
|
+
title: string;
|
|
50
|
+
stability?: string;
|
|
51
|
+
}) => React.ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* Render the document of the operation.
|
|
54
|
+
*/
|
|
55
|
+
renderDocument: (props: {
|
|
56
|
+
document: object;
|
|
57
|
+
}) => React.ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Specification URL.
|
|
60
|
+
*/
|
|
61
|
+
specUrl: string;
|
|
59
62
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
locale?: TranslationLocale | undefined;
|
|
63
|
+
interface OpenAPIContextInput extends Omit<OpenAPIContext, 'translation'> {
|
|
64
|
+
/**
|
|
65
|
+
* The translation language to use.
|
|
66
|
+
* @default 'en'
|
|
67
|
+
*/
|
|
68
|
+
locale?: TranslationLocale | undefined;
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*/
|
|
71
|
-
export declare function resolveOpenAPIContext(context: OpenAPIContextInput): OpenAPIContext;
|
|
72
|
-
/**
|
|
73
|
-
* Get the client context from the OpenAPI context.
|
|
74
|
-
*/
|
|
75
|
-
export declare function getOpenAPIClientContext(context: OpenAPIUniversalContext): OpenAPIClientContext;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { OpenAPIContextInput };
|
package/dist/context.js
CHANGED
|
@@ -1,43 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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';
|
|
1
|
+
import { translations } from "./translations/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/context.ts
|
|
24
4
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
* Resolve OpenAPI context from the input.
|
|
6
|
+
*/
|
|
7
|
+
function resolveOpenAPIContext(context) {
|
|
8
|
+
const { locale,...rest } = context;
|
|
9
|
+
return {
|
|
10
|
+
...rest,
|
|
11
|
+
translation: translations[locale ?? "en"]
|
|
12
|
+
};
|
|
30
13
|
}
|
|
31
14
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
* Get the client context from the OpenAPI context.
|
|
16
|
+
*/
|
|
17
|
+
function getOpenAPIClientContext(context) {
|
|
18
|
+
return {
|
|
19
|
+
translation: context.translation,
|
|
20
|
+
icons: context.icons,
|
|
21
|
+
defaultInteractiveOpened: context.defaultInteractiveOpened,
|
|
22
|
+
blockKey: context.blockKey,
|
|
23
|
+
id: context.id,
|
|
24
|
+
$$isClientContext$$: true
|
|
25
|
+
};
|
|
43
26
|
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getOpenAPIClientContext, resolveOpenAPIContext };
|
package/dist/decycle.js
CHANGED
|
@@ -1,70 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
//#region src/decycle.ts
|
|
2
|
+
const isObject = (value) => typeof value === "object" && value != null && !(value instanceof Boolean) && !(value instanceof Date) && !(value instanceof Number) && !(value instanceof RegExp) && !(value instanceof String);
|
|
3
|
+
const toPointer = (parts) => `#${parts.map((part) => String(part).replace(/~/g, "~0").replace(/\//g, "~1")).join("/")}`;
|
|
4
|
+
const decycle = () => {
|
|
5
|
+
const paths = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
return function replacer(key, value) {
|
|
7
|
+
if (key !== "$reference" && isObject(value)) {
|
|
8
|
+
if (paths.has(value)) return { $reference: toPointer(paths.get(value)) };
|
|
9
|
+
paths.set(value, [...paths.get(this) ?? [], key]);
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
};
|
|
14
|
+
function retrocycle() {
|
|
15
|
+
const parents = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
const keys = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
const refs = /* @__PURE__ */ new Set();
|
|
18
|
+
function dereference(ref) {
|
|
19
|
+
const parts = ref.$reference.slice(1).split("/");
|
|
20
|
+
let key;
|
|
21
|
+
let value = this;
|
|
22
|
+
for (let i = 0; i < parts.length; i++) {
|
|
23
|
+
key = parts[i]?.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
24
|
+
value = value[key];
|
|
25
|
+
}
|
|
26
|
+
const parent = parents.get(ref);
|
|
27
|
+
parent[keys.get(ref)] = value;
|
|
28
|
+
}
|
|
29
|
+
return function reviver(key, value) {
|
|
30
|
+
if (key === "$reference") refs.add(this);
|
|
31
|
+
else if (isObject(value)) if (key === "" && Object.keys(this).length === 1) refs.forEach(dereference, this);
|
|
32
|
+
else {
|
|
33
|
+
parents.set(value, this);
|
|
34
|
+
keys.set(value, key);
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
70
38
|
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { decycle, retrocycle };
|
package/dist/dereference.js
CHANGED
|
@@ -1,68 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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();
|
|
1
|
+
import { dereference } from "@gitbook/openapi-parser";
|
|
2
|
+
|
|
3
|
+
//#region src/dereference.ts
|
|
4
|
+
const dereferenceCache = /* @__PURE__ */ new WeakMap();
|
|
39
5
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
dereferenceCache.set(filesystem, promise);
|
|
48
|
-
return promise;
|
|
6
|
+
* Memoized version of `dereferenceSchema`.
|
|
7
|
+
*/
|
|
8
|
+
function dereferenceFilesystem(filesystem) {
|
|
9
|
+
if (dereferenceCache.has(filesystem)) return dereferenceCache.get(filesystem);
|
|
10
|
+
const promise = baseDereferenceFilesystem(filesystem);
|
|
11
|
+
dereferenceCache.set(filesystem, promise);
|
|
12
|
+
return promise;
|
|
49
13
|
}
|
|
50
14
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function baseDereferenceFilesystem(filesystem) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
});
|
|
15
|
+
* Dereference an OpenAPI schema.
|
|
16
|
+
*/
|
|
17
|
+
async function baseDereferenceFilesystem(filesystem) {
|
|
18
|
+
const result = await dereference(filesystem);
|
|
19
|
+
if (!result.schema) throw new Error("Failed to dereference OpenAPI document");
|
|
20
|
+
return result.schema;
|
|
68
21
|
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { dereferenceFilesystem };
|