@gitbook/react-openapi 1.5.4 → 1.5.6
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 +13 -0
- package/dist/InteractiveSection.js +52 -30
- package/dist/Markdown.js +5 -1
- package/dist/OpenAPICodeSample.js +45 -9
- package/dist/OpenAPICodeSampleInteractive.js +41 -15
- package/dist/OpenAPICodeSampleSelector.js +34 -14
- package/dist/OpenAPICopyButton.js +21 -15
- package/dist/OpenAPIDisclosure.js +18 -10
- package/dist/OpenAPIDisclosureGroup.js +56 -30
- package/dist/OpenAPIExample.js +6 -4
- package/dist/OpenAPIMediaType.js +38 -17
- package/dist/OpenAPIOperation.d.ts +2 -2
- package/dist/OpenAPIOperation.js +26 -12
- package/dist/OpenAPIOperationContext.d.ts +2 -2
- package/dist/OpenAPIOperationContext.js +5 -3
- package/dist/OpenAPIPath.js +14 -5
- package/dist/OpenAPIPathItem.js +26 -12
- package/dist/OpenAPIPathMultipleServers.js +29 -12
- package/dist/OpenAPIPrefillContextProvider.d.ts +2 -1
- package/dist/OpenAPIPrefillContextProvider.js +5 -3
- package/dist/OpenAPIRequestBody.js +20 -10
- package/dist/OpenAPIRequestBodyHeaderType.js +5 -3
- package/dist/OpenAPIRequiredScopes.js +41 -26
- package/dist/OpenAPIResponse.js +34 -19
- package/dist/OpenAPIResponseExample.js +25 -8
- package/dist/OpenAPIResponseExampleContent.js +39 -18
- package/dist/OpenAPIResponses.js +40 -17
- package/dist/OpenAPISchema.js +212 -88
- package/dist/OpenAPISchemaName.js +44 -24
- package/dist/OpenAPISchemaServer.js +10 -2
- package/dist/OpenAPISecurities.js +125 -57
- package/dist/OpenAPISelect.js +27 -18
- package/dist/OpenAPISpec.js +27 -12
- package/dist/OpenAPITooltip.js +14 -6
- package/dist/OpenAPIWebhook.d.ts +2 -2
- package/dist/OpenAPIWebhook.js +23 -11
- package/dist/OpenAPIWebhookExample.js +18 -8
- package/dist/ScalarApiButton.js +50 -29
- package/dist/StaticSection.js +49 -15
- package/dist/common/OpenAPIColumnSpec.js +21 -9
- package/dist/common/OpenAPIOperationDescription.js +12 -6
- package/dist/common/OpenAPIStability.js +6 -3
- package/dist/common/OpenAPISummary.js +23 -12
- package/dist/formatPath.js +7 -4
- package/dist/schemas/OpenAPISchemaItem.js +18 -11
- package/dist/schemas/OpenAPISchemas.d.ts +2 -2
- package/dist/schemas/OpenAPISchemas.js +55 -31
- package/dist/translate.js +4 -6
- package/dist/util/example.js +6 -1
- package/package.json +3 -3
package/dist/ScalarApiButton.js
CHANGED
|
@@ -6,6 +6,7 @@ import { useOpenAPIOperationContext } from "./OpenAPIOperationContext.js";
|
|
|
6
6
|
import { useOpenAPIPrefillContext } from "./OpenAPIPrefillContextProvider.js";
|
|
7
7
|
import { resolveTryItPrefillForOperation } from "./util/tryit-prefill.js";
|
|
8
8
|
import { Suspense, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { ApiClientModalProvider, useApiClientModal } from "@scalar/api-client-react";
|
|
10
11
|
import { createPortal } from "react-dom";
|
|
11
12
|
|
|
@@ -17,41 +18,61 @@ function ScalarApiButton(props) {
|
|
|
17
18
|
const { method, path, securities, servers, specUrl, context } = props;
|
|
18
19
|
const [isOpen, setIsOpen] = useState(false);
|
|
19
20
|
const controllerRef = useRef(null);
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: "scalar scalar-activate",
|
|
23
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
24
|
+
className: "scalar-activate-button button",
|
|
25
|
+
onClick: () => {
|
|
26
|
+
controllerRef.current?.openClient?.();
|
|
27
|
+
setIsOpen(true);
|
|
28
|
+
},
|
|
29
|
+
children: [t(context.translation, "test_it"), /* @__PURE__ */ jsx("svg", {
|
|
30
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
31
|
+
viewBox: "0 0 10 12",
|
|
32
|
+
fill: "currentColor",
|
|
33
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
34
|
+
stroke: "currentColor",
|
|
35
|
+
strokeWidth: "1.5",
|
|
36
|
+
d: "M1 10.05V1.43c0-.2.2-.31.37-.22l7.26 4.08c.17.1.17.33.01.43l-7.26 4.54a.25.25 0 0 1-.38-.21Z"
|
|
37
|
+
})
|
|
38
|
+
})]
|
|
39
|
+
}), isOpen && createPortal(/* @__PURE__ */ jsx(Suspense, {
|
|
40
|
+
fallback: null,
|
|
41
|
+
children: /* @__PURE__ */ jsx(ScalarModal, {
|
|
42
|
+
controllerRef,
|
|
43
|
+
method,
|
|
44
|
+
path,
|
|
45
|
+
securities,
|
|
46
|
+
servers,
|
|
47
|
+
specUrl
|
|
48
|
+
})
|
|
49
|
+
}), document.body)]
|
|
50
|
+
});
|
|
35
51
|
}
|
|
36
52
|
function ScalarModal(props) {
|
|
37
53
|
const { method, path, securities, servers, specUrl, controllerRef } = props;
|
|
38
54
|
const prefillInputContext = useOpenAPIPrefillContext()();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
return /* @__PURE__ */ jsx(ApiClientModalProvider, {
|
|
56
|
+
configuration: {
|
|
57
|
+
url: specUrl,
|
|
58
|
+
...resolveTryItPrefillForOperation({
|
|
59
|
+
operation: {
|
|
60
|
+
securities,
|
|
61
|
+
servers
|
|
62
|
+
},
|
|
63
|
+
prefillInputContext
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
initialRequest: {
|
|
67
|
+
method: toScalarHttpMethod(method),
|
|
68
|
+
path
|
|
43
69
|
},
|
|
44
|
-
|
|
70
|
+
children: /* @__PURE__ */ jsx(ScalarModalController, {
|
|
71
|
+
method,
|
|
72
|
+
path,
|
|
73
|
+
controllerRef
|
|
74
|
+
})
|
|
45
75
|
});
|
|
46
|
-
return <ApiClientModalProvider configuration={{
|
|
47
|
-
url: specUrl,
|
|
48
|
-
...prefillConfig
|
|
49
|
-
}} initialRequest={{
|
|
50
|
-
method: toScalarHttpMethod(method),
|
|
51
|
-
path
|
|
52
|
-
}}>
|
|
53
|
-
<ScalarModalController method={method} path={path} controllerRef={controllerRef} />
|
|
54
|
-
</ApiClientModalProvider>;
|
|
55
76
|
}
|
|
56
77
|
function toScalarHttpMethod(method) {
|
|
57
78
|
return method.toUpperCase();
|
package/dist/StaticSection.js
CHANGED
|
@@ -1,36 +1,70 @@
|
|
|
1
1
|
import clsx from "classnames";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
|
|
4
5
|
//#region src/StaticSection.tsx
|
|
5
6
|
function Section(props) {
|
|
6
|
-
return
|
|
7
|
+
return /* @__PURE__ */ jsx("div", {
|
|
8
|
+
...props,
|
|
9
|
+
className: clsx("openapi-section", props.className)
|
|
10
|
+
});
|
|
7
11
|
}
|
|
8
12
|
function SectionHeader(props) {
|
|
9
|
-
return
|
|
13
|
+
return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
...props,
|
|
15
|
+
className: clsx("openapi-section-header", props.className ? `${props.className}-header` : void 0)
|
|
16
|
+
});
|
|
10
17
|
}
|
|
11
18
|
function SectionHeaderContent(props) {
|
|
12
|
-
return
|
|
19
|
+
return /* @__PURE__ */ jsx("div", {
|
|
20
|
+
...props,
|
|
21
|
+
className: clsx("openapi-section-header-content", props.className && `${props.className}-header-content`)
|
|
22
|
+
});
|
|
13
23
|
}
|
|
14
24
|
const SectionBody = forwardRef(function SectionBody$1(props, ref) {
|
|
15
|
-
return
|
|
25
|
+
return /* @__PURE__ */ jsx("div", {
|
|
26
|
+
ref,
|
|
27
|
+
...props,
|
|
28
|
+
className: clsx("openapi-section-body", props.className && `${props.className}-body`)
|
|
29
|
+
});
|
|
16
30
|
});
|
|
17
31
|
function SectionFooter(props) {
|
|
18
|
-
return
|
|
32
|
+
return /* @__PURE__ */ jsx("div", {
|
|
33
|
+
...props,
|
|
34
|
+
className: clsx("openapi-section-footer", props.className && `${props.className}-footer`)
|
|
35
|
+
});
|
|
19
36
|
}
|
|
20
37
|
function SectionFooterContent(props) {
|
|
21
|
-
return
|
|
38
|
+
return /* @__PURE__ */ jsx("div", {
|
|
39
|
+
...props,
|
|
40
|
+
className: clsx("openapi-section-footer-content", props.className && `${props.className}-footer-content`)
|
|
41
|
+
});
|
|
22
42
|
}
|
|
23
43
|
function StaticSection(props) {
|
|
24
44
|
const { className, header, children, footer } = props;
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
return /* @__PURE__ */ jsxs(Section, {
|
|
46
|
+
className,
|
|
47
|
+
children: [
|
|
48
|
+
header ? /* @__PURE__ */ jsx(SectionHeader, {
|
|
49
|
+
className,
|
|
50
|
+
children: /* @__PURE__ */ jsx(SectionHeaderContent, {
|
|
51
|
+
className,
|
|
52
|
+
children: header
|
|
53
|
+
})
|
|
54
|
+
}) : null,
|
|
55
|
+
/* @__PURE__ */ jsx(SectionBody, {
|
|
56
|
+
className,
|
|
57
|
+
children
|
|
58
|
+
}),
|
|
59
|
+
footer ? /* @__PURE__ */ jsx(SectionFooter, {
|
|
60
|
+
className,
|
|
61
|
+
children: /* @__PURE__ */ jsx(SectionFooterContent, {
|
|
62
|
+
className,
|
|
63
|
+
children: footer
|
|
64
|
+
})
|
|
65
|
+
}) : null
|
|
66
|
+
]
|
|
67
|
+
});
|
|
34
68
|
}
|
|
35
69
|
|
|
36
70
|
//#endregion
|
|
@@ -2,21 +2,33 @@ import { t } from "../translate.js";
|
|
|
2
2
|
import { getOpenAPIClientContext } from "../context.js";
|
|
3
3
|
import { OpenAPISpec } from "../OpenAPISpec.js";
|
|
4
4
|
import { OpenAPIOperationDescription } from "./OpenAPIOperationDescription.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
|
|
6
7
|
//#region src/common/OpenAPIColumnSpec.tsx
|
|
7
8
|
function OpenAPIColumnSpec(props) {
|
|
8
9
|
const { data, context } = props;
|
|
9
10
|
const { operation } = data;
|
|
10
11
|
const clientContext = getOpenAPIClientContext(context);
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
13
|
+
className: "openapi-column-spec",
|
|
14
|
+
children: [
|
|
15
|
+
operation["x-deprecated-sunset"] ? /* @__PURE__ */ jsx("div", {
|
|
16
|
+
className: "openapi-deprecated-sunset openapi-description openapi-markdown",
|
|
17
|
+
children: t(context.translation, "deprecated_and_sunset_on", [/* @__PURE__ */ jsx("span", {
|
|
18
|
+
className: "openapi-deprecated-sunset-date",
|
|
19
|
+
children: operation["x-deprecated-sunset"]
|
|
20
|
+
}, "date")])
|
|
21
|
+
}) : null,
|
|
22
|
+
/* @__PURE__ */ jsx(OpenAPIOperationDescription, {
|
|
23
|
+
operation,
|
|
24
|
+
context
|
|
25
|
+
}),
|
|
26
|
+
/* @__PURE__ */ jsx(OpenAPISpec, {
|
|
27
|
+
data,
|
|
28
|
+
context: clientContext
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
});
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
//#endregion
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { Markdown } from "../Markdown.js";
|
|
2
2
|
import { resolveDescription } from "../utils.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
|
|
4
5
|
//#region src/common/OpenAPIOperationDescription.tsx
|
|
5
6
|
function OpenAPIOperationDescription(props) {
|
|
6
7
|
const { operation } = props;
|
|
7
|
-
if (operation["x-gitbook-description-document"]) return
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
if (operation["x-gitbook-description-document"]) return /* @__PURE__ */ jsx("div", {
|
|
9
|
+
className: "openapi-intro",
|
|
10
|
+
children: props.context.renderDocument({ document: operation["x-gitbook-description-document"] })
|
|
11
|
+
});
|
|
10
12
|
const description = resolveDescription(operation);
|
|
11
13
|
if (!description) return null;
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
return /* @__PURE__ */ jsx("div", {
|
|
15
|
+
className: "openapi-intro",
|
|
16
|
+
children: /* @__PURE__ */ jsx(Markdown, {
|
|
17
|
+
className: "openapi-description",
|
|
18
|
+
source: description
|
|
19
|
+
})
|
|
20
|
+
});
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
//#endregion
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
|
|
1
3
|
//#region src/common/OpenAPIStability.tsx
|
|
2
4
|
const stabilityEnum = {
|
|
3
5
|
experimental: "Experimental",
|
|
@@ -8,9 +10,10 @@ function OpenAPIStability(props) {
|
|
|
8
10
|
const { stability } = props;
|
|
9
11
|
const foundStability = stabilityEnum[stability];
|
|
10
12
|
if (!foundStability) return null;
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
className: `openapi-stability openapi-stability-${foundStability.toLowerCase()}`,
|
|
15
|
+
children: foundStability
|
|
16
|
+
});
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OpenAPIPath } from "../OpenAPIPath.js";
|
|
2
2
|
import { OpenAPIStability } from "./OpenAPIStability.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
|
|
4
5
|
//#region src/common/OpenAPISummary.tsx
|
|
5
6
|
function OpenAPISummary(props) {
|
|
@@ -9,18 +10,28 @@ function OpenAPISummary(props) {
|
|
|
9
10
|
if (operation.summary) return operation.summary;
|
|
10
11
|
if ("name" in data) return data.name;
|
|
11
12
|
})();
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
14
|
+
className: "openapi-summary",
|
|
15
|
+
id: operation.summary ? void 0 : context.id,
|
|
16
|
+
children: [
|
|
17
|
+
(operation.deprecated || operation["x-stability"]) && /* @__PURE__ */ jsxs("div", {
|
|
18
|
+
className: "openapi-summary-tags",
|
|
19
|
+
children: [operation.deprecated && /* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: "openapi-deprecated",
|
|
21
|
+
children: "Deprecated"
|
|
22
|
+
}), operation["x-stability"] && /* @__PURE__ */ jsx(OpenAPIStability, { stability: operation["x-stability"] })]
|
|
23
|
+
}),
|
|
24
|
+
title ? context.renderHeading({
|
|
25
|
+
deprecated: operation.deprecated ?? false,
|
|
26
|
+
stability: operation["x-stability"],
|
|
27
|
+
title
|
|
28
|
+
}) : null,
|
|
29
|
+
"path" in data ? /* @__PURE__ */ jsx(OpenAPIPath, {
|
|
30
|
+
data,
|
|
31
|
+
context
|
|
32
|
+
}) : null
|
|
33
|
+
]
|
|
34
|
+
});
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
//#endregion
|
package/dist/formatPath.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
|
|
1
3
|
//#region src/formatPath.tsx
|
|
2
4
|
/**
|
|
3
5
|
* Format the path by wrapping placeholders in <span> tags.
|
|
@@ -8,15 +10,16 @@ function formatPath(path) {
|
|
|
8
10
|
let lastIndex = 0;
|
|
9
11
|
path.replace(regex, (match, _, offset) => {
|
|
10
12
|
if (offset > lastIndex) parts.push(path.slice(lastIndex, offset));
|
|
11
|
-
parts.push(
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
parts.push(/* @__PURE__ */ jsx("span", {
|
|
14
|
+
className: "openapi-path-variable",
|
|
15
|
+
children: match
|
|
16
|
+
}, `offset-${offset}`));
|
|
14
17
|
lastIndex = offset + match.length;
|
|
15
18
|
return match;
|
|
16
19
|
});
|
|
17
20
|
if (lastIndex < path.length) parts.push(path.slice(lastIndex));
|
|
18
21
|
return parts.map((part, index) => {
|
|
19
|
-
if (typeof part === "string") return
|
|
22
|
+
if (typeof part === "string") return /* @__PURE__ */ jsx("span", { children: part }, `part-${index}`);
|
|
20
23
|
return part;
|
|
21
24
|
});
|
|
22
25
|
}
|
|
@@ -5,21 +5,28 @@ import { OpenAPIDisclosure } from "../OpenAPIDisclosure.js";
|
|
|
5
5
|
import { getDisclosureLabel } from "../getDisclosureLabel.js";
|
|
6
6
|
import { OpenAPIRootSchema } from "../OpenAPISchemaServer.js";
|
|
7
7
|
import { Section, SectionBody } from "../StaticSection.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
9
|
|
|
9
10
|
//#region src/schemas/OpenAPISchemaItem.tsx
|
|
10
11
|
function OpenAPISchemaItem(props) {
|
|
11
12
|
const { schema, context, name } = props;
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
return /* @__PURE__ */ jsx(OpenAPIDisclosure, {
|
|
14
|
+
className: "openapi-schemas-disclosure",
|
|
15
|
+
icon: context.icons.plus,
|
|
16
|
+
header: name,
|
|
17
|
+
label: (isExpanded) => getDisclosureLabel({
|
|
18
|
+
schema,
|
|
19
|
+
isExpanded,
|
|
20
|
+
context
|
|
21
|
+
}),
|
|
22
|
+
children: /* @__PURE__ */ jsx(Section, {
|
|
23
|
+
className: "openapi-section-schemas",
|
|
24
|
+
children: /* @__PURE__ */ jsx(SectionBody, { children: /* @__PURE__ */ jsx(OpenAPIRootSchema, {
|
|
25
|
+
schema,
|
|
26
|
+
context
|
|
27
|
+
}) })
|
|
28
|
+
})
|
|
29
|
+
}, name);
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIContextInput } from "../context.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
3
|
import { OpenAPISchema } from "@gitbook/openapi-parser";
|
|
4
4
|
|
|
5
5
|
//#region src/schemas/OpenAPISchemas.d.ts
|
|
@@ -14,6 +14,6 @@ declare function OpenAPISchemas(props: {
|
|
|
14
14
|
* Whether to show the schema directly if there is only one.
|
|
15
15
|
*/
|
|
16
16
|
grouped?: boolean;
|
|
17
|
-
}):
|
|
17
|
+
}): react_jsx_runtime3.JSX.Element | null;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { OpenAPISchemas };
|
|
@@ -6,6 +6,7 @@ import { getOpenAPIClientContext, resolveOpenAPIContext } from "../context.js";
|
|
|
6
6
|
import { getExampleFromSchema } from "../util/example.js";
|
|
7
7
|
import { OpenAPISchemaItem } from "./OpenAPISchemaItem.js";
|
|
8
8
|
import clsx from "classnames";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
|
|
10
11
|
//#region src/schemas/OpenAPISchemas.tsx
|
|
11
12
|
/**
|
|
@@ -19,38 +20,61 @@ function OpenAPISchemas(props) {
|
|
|
19
20
|
const clientContext = getOpenAPIClientContext(context);
|
|
20
21
|
if (schemas.length === 1 && !grouped) {
|
|
21
22
|
const title = `The ${firstSchema.name} object`;
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
className: clsx("openapi-schemas", className),
|
|
25
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
26
|
+
className: "openapi-summary",
|
|
27
|
+
id: context.id,
|
|
28
|
+
children: context.renderHeading({
|
|
29
|
+
title,
|
|
30
|
+
deprecated: Boolean(firstSchema.schema.deprecated),
|
|
31
|
+
stability: firstSchema.schema["x-stability"]
|
|
32
|
+
})
|
|
33
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
34
|
+
className: "openapi-columns",
|
|
35
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
36
|
+
className: "openapi-column-spec",
|
|
37
|
+
children: /* @__PURE__ */ jsx(StaticSection, {
|
|
38
|
+
className: "openapi-parameters",
|
|
39
|
+
header: t(context.translation, "attributes"),
|
|
40
|
+
children: /* @__PURE__ */ jsx(OpenAPIRootSchema, {
|
|
41
|
+
schema: firstSchema.schema,
|
|
42
|
+
context: clientContext
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
46
|
+
className: "openapi-column-preview",
|
|
47
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
48
|
+
className: "openapi-column-preview-body",
|
|
49
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
50
|
+
className: "openapi-panel",
|
|
51
|
+
children: [/* @__PURE__ */ jsx("h4", {
|
|
52
|
+
className: "openapi-panel-heading",
|
|
53
|
+
children: title
|
|
54
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
55
|
+
className: "openapi-panel-body",
|
|
56
|
+
children: /* @__PURE__ */ jsx(OpenAPIExample, {
|
|
57
|
+
example: getExampleFromSchema({ schema: firstSchema.schema }),
|
|
58
|
+
context,
|
|
59
|
+
syntax: "json"
|
|
60
|
+
})
|
|
61
|
+
})]
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
})]
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
48
67
|
}
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
return /* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: clsx("openapi-schemas", className),
|
|
70
|
+
children: schemas.map(({ name, schema }) => {
|
|
71
|
+
return /* @__PURE__ */ jsx(OpenAPISchemaItem, {
|
|
72
|
+
name,
|
|
73
|
+
context: clientContext,
|
|
74
|
+
schema
|
|
75
|
+
}, name);
|
|
76
|
+
})
|
|
77
|
+
});
|
|
54
78
|
}
|
|
55
79
|
|
|
56
80
|
//#endregion
|
package/dist/translate.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { isValidElement } from "react";
|
|
2
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
|
|
3
4
|
//#region src/translate.tsx
|
|
4
5
|
/**
|
|
@@ -14,16 +15,13 @@ function t(translation, id, ...args) {
|
|
|
14
15
|
else {
|
|
15
16
|
const [partToPush, partToReplace] = currentStringToReplace.split(`\${${i + 1}}`);
|
|
16
17
|
if (partToPush === void 0 || partToReplace === void 0) throw new Error(`Invalid translation "${id}"`);
|
|
17
|
-
parts.push(
|
|
18
|
-
parts.push(
|
|
18
|
+
parts.push(/* @__PURE__ */ jsx(React.Fragment, { children: partToPush }, `string-${i}`));
|
|
19
|
+
parts.push(/* @__PURE__ */ jsx(React.Fragment, { children: arg }, `arg-${i}`));
|
|
19
20
|
currentStringToReplace = partToReplace;
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
if (!parts.length) return currentStringToReplace;
|
|
23
|
-
return
|
|
24
|
-
{parts}
|
|
25
|
-
{currentStringToReplace}
|
|
26
|
-
</>;
|
|
24
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [parts, currentStringToReplace] });
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
27
|
* Version of `t` that returns a string.
|
package/dist/util/example.js
CHANGED
|
@@ -2,6 +2,7 @@ import { tString } from "../translate.js";
|
|
|
2
2
|
import { OpenAPIExample } from "../OpenAPIExample.js";
|
|
3
3
|
import { checkIsReference } from "../utils.js";
|
|
4
4
|
import { generateSchemaExample } from "../generateSchemaExample.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
|
|
6
7
|
//#region src/util/example.tsx
|
|
7
8
|
/**
|
|
@@ -66,7 +67,11 @@ function getExamples(props) {
|
|
|
66
67
|
return {
|
|
67
68
|
key: example.key,
|
|
68
69
|
label: example.example.summary || example.key,
|
|
69
|
-
body:
|
|
70
|
+
body: /* @__PURE__ */ jsx(OpenAPIExample, {
|
|
71
|
+
example: example.example,
|
|
72
|
+
context: props.context,
|
|
73
|
+
syntax
|
|
74
|
+
})
|
|
70
75
|
};
|
|
71
76
|
});
|
|
72
77
|
}
|
package/package.json
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
"default": "./dist/index.js"
|
|
8
8
|
}
|
|
9
9
|
},
|
|
10
|
-
"version": "1.5.
|
|
10
|
+
"version": "1.5.6",
|
|
11
11
|
"sideEffects": false,
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@gitbook/expr": "1.2.4",
|
|
14
|
-
"@gitbook/openapi-parser": "3.0.
|
|
14
|
+
"@gitbook/openapi-parser": "3.0.7",
|
|
15
15
|
"@scalar/api-client-react": "^1.3.46",
|
|
16
16
|
"@scalar/oas-utils": "^0.6.3",
|
|
17
17
|
"@scalar/types": "^0.4.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "catalog:"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"react": "
|
|
45
|
+
"react": ">=17",
|
|
46
46
|
"react-dom": "*"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|