docusaurus-theme-openapi-docs 0.0.0-1000
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/LICENSE +21 -0
- package/babel.config.js +35 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +81 -0
- package/lib/markdown/createDescription.d.ts +1 -0
- package/lib/markdown/createDescription.js +15 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +149 -0
- package/lib/markdown/utils.d.ts +10 -0
- package/lib/markdown/utils.js +49 -0
- package/lib/markdown/utils.test.d.ts +1 -0
- package/lib/markdown/utils.test.js +43 -0
- package/lib/theme/ApiExplorer/Accept/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/Accept/index.js +38 -0
- package/lib/theme/ApiExplorer/Accept/slice.d.ts +11 -0
- package/lib/theme/ApiExplorer/Accept/slice.js +22 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/_Container.scss +7 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +35 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +41 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +153 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/_Content.scss +91 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/_CopyButton.scss +44 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +147 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/_ExitButton.scss +16 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +58 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/_ExpandButton.scss +62 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.d.ts +14 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +248 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +34 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +59 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/_WordWrapButton.scss +10 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +51 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +110 -0
- package/lib/theme/ApiExplorer/Authorization/auth-types.d.ts +3 -0
- package/lib/theme/ApiExplorer/Authorization/auth-types.js +28 -0
- package/lib/theme/ApiExplorer/Authorization/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/Authorization/index.js +160 -0
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +40 -0
- package/lib/theme/ApiExplorer/Authorization/slice.js +102 -0
- package/lib/theme/ApiExplorer/Body/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/Body/index.js +381 -0
- package/lib/theme/ApiExplorer/Body/json2xml.js +43 -0
- package/lib/theme/ApiExplorer/Body/slice.d.ts +82 -0
- package/lib/theme/ApiExplorer/Body/slice.js +97 -0
- package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.d.ts +21 -0
- package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.js +8 -0
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +389 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +5 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +95 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +501 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +271 -0
- package/lib/theme/ApiExplorer/ContentType/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ContentType/index.js +40 -0
- package/lib/theme/ApiExplorer/ContentType/slice.d.ts +11 -0
- package/lib/theme/ApiExplorer/ContentType/slice.js +22 -0
- package/lib/theme/ApiExplorer/Export/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/Export/index.js +57 -0
- package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +27 -0
- package/lib/theme/ApiExplorer/FloatingButton/index.d.ts +8 -0
- package/lib/theme/ApiExplorer/FloatingButton/index.js +28 -0
- package/lib/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +74 -0
- package/lib/theme/ApiExplorer/FormFileUpload/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +173 -0
- package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +21 -0
- package/lib/theme/ApiExplorer/FormItem/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/FormItem/index.js +44 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/_FormMultiSelect.scss +30 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/index.js +51 -0
- package/lib/theme/ApiExplorer/FormSelect/_FormSelect.scss +43 -0
- package/lib/theme/ApiExplorer/FormSelect/index.d.ts +8 -0
- package/lib/theme/ApiExplorer/FormSelect/index.js +35 -0
- package/lib/theme/ApiExplorer/FormTextInput/_FormTextInput.scss +34 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.js +73 -0
- package/lib/theme/ApiExplorer/LiveEditor/_LiveEditor.scss +15 -0
- package/lib/theme/ApiExplorer/LiveEditor/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/LiveEditor/index.js +168 -0
- package/lib/theme/ApiExplorer/MethodEndpoint/_MethodEndpoint.scss +22 -0
- package/lib/theme/ApiExplorer/MethodEndpoint/index.d.ts +8 -0
- package/lib/theme/ApiExplorer/MethodEndpoint/index.js +86 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +220 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +63 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +89 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +63 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +38 -0
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +123 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.js +223 -0
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +17 -0
- package/lib/theme/ApiExplorer/ParamOptions/slice.js +25 -0
- package/lib/theme/ApiExplorer/Request/_Request.scss +129 -0
- package/lib/theme/ApiExplorer/Request/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/Request/index.js +396 -0
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +4 -0
- package/lib/theme/ApiExplorer/Request/makeRequest.js +222 -0
- package/lib/theme/ApiExplorer/Response/_Response.scss +121 -0
- package/lib/theme/ApiExplorer/Response/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/Response/index.js +193 -0
- package/lib/theme/ApiExplorer/Response/slice.d.ts +17 -0
- package/lib/theme/ApiExplorer/Response/slice.js +51 -0
- package/lib/theme/ApiExplorer/SecuritySchemes/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +380 -0
- package/lib/theme/ApiExplorer/Server/_Server.scss +26 -0
- package/lib/theme/ApiExplorer/Server/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/Server/index.js +199 -0
- package/lib/theme/ApiExplorer/Server/slice.d.ts +13 -0
- package/lib/theme/ApiExplorer/Server/slice.js +33 -0
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +20 -0
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +465 -0
- package/lib/theme/ApiExplorer/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/index.js +41 -0
- package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +3 -0
- package/lib/theme/ApiExplorer/persistanceMiddleware.js +54 -0
- package/lib/theme/ApiExplorer/storage-utils.d.ts +4 -0
- package/lib/theme/ApiExplorer/storage-utils.js +41 -0
- package/lib/theme/ApiItem/Layout/index.d.ts +3 -0
- package/lib/theme/ApiItem/Layout/index.js +121 -0
- package/lib/theme/ApiItem/Layout/styles.module.css +17 -0
- package/lib/theme/ApiItem/hooks.d.ts +12 -0
- package/lib/theme/ApiItem/hooks.js +13 -0
- package/lib/theme/ApiItem/index.d.ts +2 -0
- package/lib/theme/ApiItem/index.js +238 -0
- package/lib/theme/ApiItem/store.d.ts +46 -0
- package/lib/theme/ApiItem/store.js +53 -0
- package/lib/theme/ApiLogo/index.d.ts +2 -0
- package/lib/theme/ApiLogo/index.js +51 -0
- package/lib/theme/ApiTabs/_ApiTabs.scss +142 -0
- package/lib/theme/ApiTabs/index.d.ts +7 -0
- package/lib/theme/ApiTabs/index.js +270 -0
- package/lib/theme/ArrayBrackets/index.d.ts +3 -0
- package/lib/theme/ArrayBrackets/index.js +50 -0
- package/lib/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +98 -0
- package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
- package/lib/theme/DiscriminatorTabs/index.js +258 -0
- package/lib/theme/Markdown/Details/_Details.scss +122 -0
- package/lib/theme/Markdown/index.js +179 -0
- package/lib/theme/MimeTabs/_MimeTabs.scss +70 -0
- package/lib/theme/MimeTabs/index.d.ts +6 -0
- package/lib/theme/MimeTabs/index.js +286 -0
- package/lib/theme/OperationTabs/_OperationTabs.scss +72 -0
- package/lib/theme/OperationTabs/index.d.ts +3 -0
- package/lib/theme/OperationTabs/index.js +248 -0
- package/lib/theme/ParamsDetails/index.d.ts +6 -0
- package/lib/theme/ParamsDetails/index.js +85 -0
- package/lib/theme/ParamsItem/_ParamsItem.scss +54 -0
- package/lib/theme/ParamsItem/index.d.ts +25 -0
- package/lib/theme/ParamsItem/index.js +218 -0
- package/lib/theme/RequestSchema/index.d.ts +15 -0
- package/lib/theme/RequestSchema/index.js +194 -0
- package/lib/theme/ResponseExamples/index.d.ts +18 -0
- package/lib/theme/ResponseExamples/index.js +193 -0
- package/lib/theme/ResponseHeaders/index.d.ts +13 -0
- package/lib/theme/ResponseHeaders/index.js +39 -0
- package/lib/theme/ResponseSamples/_ResponseSamples.scss +3 -0
- package/lib/theme/ResponseSamples/index.d.ts +8 -0
- package/lib/theme/ResponseSamples/index.js +27 -0
- package/lib/theme/ResponseSchema/index.d.ts +15 -0
- package/lib/theme/ResponseSchema/index.js +159 -0
- package/lib/theme/Schema/index.d.ts +8 -0
- package/lib/theme/Schema/index.js +885 -0
- package/lib/theme/SchemaItem/_SchemaItem.scss +89 -0
- package/lib/theme/SchemaItem/index.d.ts +12 -0
- package/lib/theme/SchemaItem/index.js +213 -0
- package/lib/theme/SchemaTabs/_SchemaTabs.scss +61 -0
- package/lib/theme/SchemaTabs/index.d.ts +3 -0
- package/lib/theme/SchemaTabs/index.js +255 -0
- package/lib/theme/SkeletonLoader/index.d.ts +6 -0
- package/lib/theme/SkeletonLoader/index.js +20 -0
- package/lib/theme/StatusCodes/index.d.ts +9 -0
- package/lib/theme/StatusCodes/index.js +81 -0
- package/lib/theme/styles.scss +212 -0
- package/lib/types.d.ts +157 -0
- package/lib/types.js +8 -0
- package/package.json +83 -0
- package/src/index.ts +85 -0
- package/src/markdown/createDescription.ts +13 -0
- package/src/markdown/schema.ts +181 -0
- package/src/markdown/utils.test.ts +49 -0
- package/src/markdown/utils.ts +59 -0
- package/src/plugin-content-docs.d.ts +20 -0
- package/src/postman-code-generators.d.ts +9 -0
- package/src/react-magic-dropzone.d.ts +9 -0
- package/src/theme/ApiExplorer/Accept/index.tsx +36 -0
- package/src/theme/ApiExplorer/Accept/slice.ts +29 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/_Container.scss +7 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.tsx +32 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/Element.tsx +34 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +134 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/_Content.scss +91 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/_CopyButton.scss +44 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.tsx +79 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/_ExitButton.scss +16 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.tsx +55 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/_ExpandButton.scss +62 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.tsx +166 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +34 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.tsx +48 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/_WordWrapButton.scss +10 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.tsx +54 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/index.tsx +45 -0
- package/src/theme/ApiExplorer/Authorization/auth-types.ts +30 -0
- package/src/theme/ApiExplorer/Authorization/index.tsx +158 -0
- package/src/theme/ApiExplorer/Authorization/slice.ts +146 -0
- package/src/theme/ApiExplorer/Body/index.tsx +376 -0
- package/src/theme/ApiExplorer/Body/json2xml.js +43 -0
- package/src/theme/ApiExplorer/Body/slice.ts +133 -0
- package/src/theme/ApiExplorer/CodeSnippets/code-snippets-types.ts +57 -0
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +338 -0
- package/src/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +96 -0
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +501 -0
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +248 -0
- package/src/theme/ApiExplorer/ContentType/index.tsx +38 -0
- package/src/theme/ApiExplorer/ContentType/slice.ts +29 -0
- package/src/theme/ApiExplorer/Export/index.tsx +47 -0
- package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +27 -0
- package/src/theme/ApiExplorer/FloatingButton/index.tsx +29 -0
- package/src/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +74 -0
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +119 -0
- package/src/theme/ApiExplorer/FormItem/_FormItem.scss +21 -0
- package/src/theme/ApiExplorer/FormItem/index.tsx +33 -0
- package/src/theme/ApiExplorer/FormMultiSelect/_FormMultiSelect.scss +30 -0
- package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +57 -0
- package/src/theme/ApiExplorer/FormSelect/_FormSelect.scss +43 -0
- package/src/theme/ApiExplorer/FormSelect/index.tsx +38 -0
- package/src/theme/ApiExplorer/FormTextInput/_FormTextInput.scss +34 -0
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +80 -0
- package/src/theme/ApiExplorer/LiveEditor/_LiveEditor.scss +15 -0
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +114 -0
- package/src/theme/ApiExplorer/MethodEndpoint/_MethodEndpoint.scss +22 -0
- package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +91 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +175 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +64 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +86 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +65 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +38 -0
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +123 -0
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +146 -0
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +37 -0
- package/src/theme/ApiExplorer/Request/_Request.scss +129 -0
- package/src/theme/ApiExplorer/Request/index.tsx +309 -0
- package/src/theme/ApiExplorer/Request/makeRequest.ts +254 -0
- package/src/theme/ApiExplorer/Response/_Response.scss +121 -0
- package/src/theme/ApiExplorer/Response/index.tsx +157 -0
- package/src/theme/ApiExplorer/Response/slice.ts +52 -0
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +287 -0
- package/src/theme/ApiExplorer/Server/_Server.scss +26 -0
- package/src/theme/ApiExplorer/Server/index.tsx +130 -0
- package/src/theme/ApiExplorer/Server/slice.ts +39 -0
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +526 -0
- package/src/theme/ApiExplorer/index.tsx +41 -0
- package/src/theme/ApiExplorer/persistanceMiddleware.ts +71 -0
- package/src/theme/ApiExplorer/postman-collection.d.ts +10 -0
- package/src/theme/ApiExplorer/react-modal.d.ts +8 -0
- package/src/theme/ApiExplorer/storage-utils.ts +39 -0
- package/src/theme/ApiItem/Layout/index.tsx +85 -0
- package/src/theme/ApiItem/Layout/styles.module.css +17 -0
- package/src/theme/ApiItem/hooks.ts +13 -0
- package/src/theme/ApiItem/index.tsx +222 -0
- package/src/theme/ApiItem/store.ts +51 -0
- package/src/theme/ApiLogo/index.tsx +52 -0
- package/src/theme/ApiTabs/_ApiTabs.scss +142 -0
- package/src/theme/ApiTabs/index.tsx +238 -0
- package/src/theme/ArrayBrackets/index.tsx +37 -0
- package/src/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +98 -0
- package/src/theme/DiscriminatorTabs/index.tsx +229 -0
- package/src/theme/Markdown/Details/_Details.scss +122 -0
- package/src/theme/Markdown/index.js +179 -0
- package/src/theme/MimeTabs/_MimeTabs.scss +70 -0
- package/src/theme/MimeTabs/index.tsx +257 -0
- package/src/theme/OperationTabs/_OperationTabs.scss +72 -0
- package/src/theme/OperationTabs/index.tsx +220 -0
- package/src/theme/ParamsDetails/index.tsx +81 -0
- package/src/theme/ParamsItem/_ParamsItem.scss +54 -0
- package/src/theme/ParamsItem/index.tsx +205 -0
- package/src/theme/RequestSchema/index.tsx +157 -0
- package/src/theme/ResponseExamples/index.tsx +192 -0
- package/src/theme/ResponseHeaders/index.tsx +49 -0
- package/src/theme/ResponseSamples/_ResponseSamples.scss +3 -0
- package/src/theme/ResponseSamples/index.tsx +31 -0
- package/src/theme/ResponseSchema/index.tsx +144 -0
- package/src/theme/Schema/index.tsx +939 -0
- package/src/theme/SchemaItem/_SchemaItem.scss +89 -0
- package/src/theme/SchemaItem/index.tsx +198 -0
- package/src/theme/SchemaTabs/_SchemaTabs.scss +61 -0
- package/src/theme/SchemaTabs/index.tsx +224 -0
- package/src/theme/SkeletonLoader/index.tsx +18 -0
- package/src/theme/StatusCodes/index.tsx +72 -0
- package/src/theme/styles.scss +212 -0
- package/src/theme-classic.d.ts +80 -0
- package/src/theme-openapi.d.ts +288 -0
- package/src/theme-translations.d.ts +9 -0
- package/src/types.ts +182 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { SchemaObject } from "../types";
|
|
9
|
+
|
|
10
|
+
function prettyName(schema: SchemaObject, circular?: boolean) {
|
|
11
|
+
if (schema.format) {
|
|
12
|
+
return schema.format;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (schema.allOf) {
|
|
16
|
+
if (typeof schema.allOf[0] === "string") {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
if (schema.allOf[0].includes("circular")) {
|
|
19
|
+
return schema.allOf[0];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return "object";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (schema.oneOf) {
|
|
26
|
+
return "object";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (schema.anyOf) {
|
|
30
|
+
return "object";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (schema.type === "object") {
|
|
34
|
+
return schema.xml?.name ?? schema.type;
|
|
35
|
+
// return schema.type;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (schema.type === "array") {
|
|
39
|
+
return schema.xml?.name ?? schema.type;
|
|
40
|
+
// return schema.type;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return schema.title ?? schema.type;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getSchemaName(
|
|
47
|
+
schema: SchemaObject,
|
|
48
|
+
circular?: boolean
|
|
49
|
+
): string {
|
|
50
|
+
if (schema.items) {
|
|
51
|
+
return prettyName(schema.items, circular) + "[]";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return prettyName(schema, circular) ?? "";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
58
|
+
// TODO:
|
|
59
|
+
// - uniqueItems
|
|
60
|
+
// - maxProperties
|
|
61
|
+
// - minProperties
|
|
62
|
+
// - multipleOf
|
|
63
|
+
if (!schema) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (
|
|
68
|
+
schema.items &&
|
|
69
|
+
schema.minItems === undefined &&
|
|
70
|
+
schema.maxItems === undefined
|
|
71
|
+
) {
|
|
72
|
+
return getQualifierMessage(schema.items);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let message = "**Possible values:** ";
|
|
76
|
+
|
|
77
|
+
let qualifierGroups = [];
|
|
78
|
+
|
|
79
|
+
if (schema.items && schema.items.enum) {
|
|
80
|
+
if (schema.items.enum) {
|
|
81
|
+
qualifierGroups.push(
|
|
82
|
+
`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (schema.minLength || schema.maxLength) {
|
|
88
|
+
let lengthQualifier = "";
|
|
89
|
+
let minLength;
|
|
90
|
+
let maxLength;
|
|
91
|
+
if (schema.minLength && schema.minLength > 1) {
|
|
92
|
+
minLength = `\`>= ${schema.minLength} characters\``;
|
|
93
|
+
}
|
|
94
|
+
if (schema.minLength && schema.minLength === 1) {
|
|
95
|
+
minLength = `\`non-empty\``;
|
|
96
|
+
}
|
|
97
|
+
if (schema.maxLength) {
|
|
98
|
+
maxLength = `\`<= ${schema.maxLength} characters\``;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (minLength && !maxLength) {
|
|
102
|
+
lengthQualifier += minLength;
|
|
103
|
+
}
|
|
104
|
+
if (maxLength && !minLength) {
|
|
105
|
+
lengthQualifier += maxLength;
|
|
106
|
+
}
|
|
107
|
+
if (minLength && maxLength) {
|
|
108
|
+
lengthQualifier += `${minLength} and ${maxLength}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
qualifierGroups.push(lengthQualifier);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (
|
|
115
|
+
schema.minimum != null ||
|
|
116
|
+
schema.maximum != null ||
|
|
117
|
+
typeof schema.exclusiveMinimum === "number" ||
|
|
118
|
+
typeof schema.exclusiveMaximum === "number"
|
|
119
|
+
) {
|
|
120
|
+
let minmaxQualifier = "";
|
|
121
|
+
let minimum;
|
|
122
|
+
let maximum;
|
|
123
|
+
if (typeof schema.exclusiveMinimum === "number") {
|
|
124
|
+
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
125
|
+
} else if (schema.minimum != null && !schema.exclusiveMinimum) {
|
|
126
|
+
minimum = `\`>= ${schema.minimum}\``;
|
|
127
|
+
} else if (schema.minimum != null && schema.exclusiveMinimum === true) {
|
|
128
|
+
minimum = `\`> ${schema.minimum}\``;
|
|
129
|
+
}
|
|
130
|
+
if (typeof schema.exclusiveMaximum === "number") {
|
|
131
|
+
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
132
|
+
} else if (schema.maximum != null && !schema.exclusiveMaximum) {
|
|
133
|
+
maximum = `\`<= ${schema.maximum}\``;
|
|
134
|
+
} else if (schema.maximum != null && schema.exclusiveMaximum === true) {
|
|
135
|
+
maximum = `\`< ${schema.maximum}\``;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (minimum && !maximum) {
|
|
139
|
+
minmaxQualifier += minimum;
|
|
140
|
+
}
|
|
141
|
+
if (maximum && !minimum) {
|
|
142
|
+
minmaxQualifier += maximum;
|
|
143
|
+
}
|
|
144
|
+
if (minimum && maximum) {
|
|
145
|
+
minmaxQualifier += `${minimum} and ${maximum}`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
qualifierGroups.push(minmaxQualifier);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (schema.pattern) {
|
|
152
|
+
qualifierGroups.push(
|
|
153
|
+
`Value must match regular expression \`${schema.pattern}\``
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Check if discriminator mapping
|
|
158
|
+
const discriminator = schema as any;
|
|
159
|
+
if (discriminator.mapping) {
|
|
160
|
+
const values = Object.keys(discriminator.mapping);
|
|
161
|
+
qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (schema.enum) {
|
|
165
|
+
qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (schema.minItems) {
|
|
169
|
+
qualifierGroups.push(`\`>= ${schema.minItems}\``);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (schema.maxItems) {
|
|
173
|
+
qualifierGroups.push(`\`<= ${schema.maxItems}\``);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (qualifierGroups.length === 0) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return message + qualifierGroups.join(", ");
|
|
181
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { guard } from "./utils";
|
|
9
|
+
|
|
10
|
+
describe("guard", () => {
|
|
11
|
+
it("should guard empty strings", () => {
|
|
12
|
+
const actual = guard("", (_) => {
|
|
13
|
+
throw new Error("Should not be called");
|
|
14
|
+
});
|
|
15
|
+
expect(actual).toBe("");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should guard undefined", () => {
|
|
19
|
+
const actual = guard(undefined, (value) => {
|
|
20
|
+
throw new Error("Should not be called");
|
|
21
|
+
});
|
|
22
|
+
expect(actual).toBe("");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should guard false booleans", () => {
|
|
26
|
+
const actual = guard(false, (value) => `${value}`);
|
|
27
|
+
expect(actual).toBe("");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should not guard strings", () => {
|
|
31
|
+
const actual = guard("hello", (value) => value);
|
|
32
|
+
expect(actual).toBe("hello");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should not guard numbers", () => {
|
|
36
|
+
const actual = guard(1, (value) => `${value}`);
|
|
37
|
+
expect(actual).toBe("1");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should not guard numbers equals to 0", () => {
|
|
41
|
+
const actual = guard(0, (value) => `${value}`);
|
|
42
|
+
expect(actual).toBe("0");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should not guard true booleans", () => {
|
|
46
|
+
const actual = guard(true, (value) => `${value}`);
|
|
47
|
+
expect(actual).toBe("true");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { ReactNode } from "react";
|
|
9
|
+
|
|
10
|
+
/** @deprecated use ReactNode from React instead */
|
|
11
|
+
export type Children = ReactNode;
|
|
12
|
+
|
|
13
|
+
export type Props = Record<string, any> & { children?: ReactNode };
|
|
14
|
+
|
|
15
|
+
export function create(tag: string, props: Props): string {
|
|
16
|
+
const { children, ...rest } = props;
|
|
17
|
+
|
|
18
|
+
let propString = "";
|
|
19
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
20
|
+
propString += ` ${key}={${JSON.stringify(value)}}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return `<${tag}${propString}>${render(children)}</${tag}>`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function guard<T>(
|
|
27
|
+
value: T | undefined | string,
|
|
28
|
+
cb: (value: T) => ReactNode
|
|
29
|
+
) {
|
|
30
|
+
if (!!value || value === 0) {
|
|
31
|
+
const children = cb(value as T);
|
|
32
|
+
return render(children);
|
|
33
|
+
}
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function render(children: ReactNode) {
|
|
38
|
+
if (Array.isArray(children)) {
|
|
39
|
+
return children.filter((c) => c !== undefined).join("");
|
|
40
|
+
}
|
|
41
|
+
return children ?? "";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function toString(value: any): string | undefined {
|
|
45
|
+
// Return as-is if already string
|
|
46
|
+
if (typeof value === "string") {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
// Return undefined if null or undefined
|
|
50
|
+
if (value == null) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
// Return formatted array if Array
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
return `[${value.join(", ")}]`;
|
|
56
|
+
}
|
|
57
|
+
// Coerce to string in all other cases,
|
|
58
|
+
return value + "";
|
|
59
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
/// <reference types="@docusaurus/theme-classic" />
|
|
9
|
+
|
|
10
|
+
declare module "@docusaurus/plugin-content-docs/client" {
|
|
11
|
+
export function DocProvider({
|
|
12
|
+
children,
|
|
13
|
+
content,
|
|
14
|
+
}: {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
content: PropDocContent;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export function useDoc();
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "postman-code-generators";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
+
declare module "react-magic-dropzone";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import FormItem from "@theme/ApiExplorer/FormItem";
|
|
11
|
+
import FormSelect from "@theme/ApiExplorer/FormSelect";
|
|
12
|
+
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
13
|
+
|
|
14
|
+
import { setAccept } from "./slice";
|
|
15
|
+
|
|
16
|
+
function Accept() {
|
|
17
|
+
const value = useTypedSelector((state: any) => state.accept.value);
|
|
18
|
+
const options = useTypedSelector((state: any) => state.accept.options);
|
|
19
|
+
const dispatch = useTypedDispatch();
|
|
20
|
+
|
|
21
|
+
if (options.length <= 1) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<FormItem label="Accept">
|
|
27
|
+
<FormSelect
|
|
28
|
+
value={value}
|
|
29
|
+
options={options}
|
|
30
|
+
onChange={(e: any) => dispatch(setAccept(e.target.value))}
|
|
31
|
+
/>
|
|
32
|
+
</FormItem>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default Accept;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
9
|
+
|
|
10
|
+
export interface State {
|
|
11
|
+
value: string;
|
|
12
|
+
options: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const initialState: State = {} as any;
|
|
16
|
+
|
|
17
|
+
export const slice = createSlice({
|
|
18
|
+
name: "accept",
|
|
19
|
+
initialState,
|
|
20
|
+
reducers: {
|
|
21
|
+
setAccept: (state, action: PayloadAction<string>) => {
|
|
22
|
+
state.value = action.payload;
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const { setAccept } = slice.actions;
|
|
28
|
+
|
|
29
|
+
export default slice.reducer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React, { ComponentProps } from "react";
|
|
9
|
+
|
|
10
|
+
import { ThemeClassNames, usePrismTheme } from "@docusaurus/theme-common";
|
|
11
|
+
import { getPrismCssVariables } from "@docusaurus/theme-common/internal";
|
|
12
|
+
import clsx from "clsx";
|
|
13
|
+
|
|
14
|
+
export default function CodeBlockContainer<T extends "div" | "pre">({
|
|
15
|
+
as: As,
|
|
16
|
+
...props
|
|
17
|
+
}: { as: T } & ComponentProps<T>): React.JSX.Element {
|
|
18
|
+
const prismTheme = usePrismTheme();
|
|
19
|
+
const prismCssVariables = getPrismCssVariables(prismTheme);
|
|
20
|
+
return (
|
|
21
|
+
<As
|
|
22
|
+
// Polymorphic components are hard to type, without `oneOf` generics
|
|
23
|
+
{...(props as any)}
|
|
24
|
+
style={prismCssVariables}
|
|
25
|
+
className={clsx(
|
|
26
|
+
"openapi-explorer__code-block-container",
|
|
27
|
+
props.className,
|
|
28
|
+
ThemeClassNames.common.codeBlock
|
|
29
|
+
)}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import Container from "@theme/ApiExplorer/ApiCodeBlock/Container";
|
|
11
|
+
import type { Props } from "@theme/CodeBlock/Content/Element";
|
|
12
|
+
import clsx from "clsx";
|
|
13
|
+
|
|
14
|
+
// <pre> tags in markdown map to CodeBlocks. They may contain JSX children. When
|
|
15
|
+
// the children is not a simple string, we just return a styled block without
|
|
16
|
+
// actually highlighting.
|
|
17
|
+
export default function CodeBlockJSX({
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
}: Props): React.JSX.Element {
|
|
21
|
+
return (
|
|
22
|
+
<Container
|
|
23
|
+
as="pre"
|
|
24
|
+
tabIndex={0}
|
|
25
|
+
className={clsx(
|
|
26
|
+
"openapi-explorer__code-block-standalone",
|
|
27
|
+
"thin-scrollbar",
|
|
28
|
+
className
|
|
29
|
+
)}
|
|
30
|
+
>
|
|
31
|
+
<code className="openapi-explorer__code-block-lines">{children}</code>
|
|
32
|
+
</Container>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import { useThemeConfig, usePrismTheme } from "@docusaurus/theme-common";
|
|
11
|
+
import {
|
|
12
|
+
parseCodeBlockTitle,
|
|
13
|
+
parseLanguage,
|
|
14
|
+
parseLines,
|
|
15
|
+
containsLineNumbers,
|
|
16
|
+
useCodeWordWrap,
|
|
17
|
+
} from "@docusaurus/theme-common/internal";
|
|
18
|
+
import Container from "@theme/ApiExplorer/ApiCodeBlock/Container";
|
|
19
|
+
import CopyButton from "@theme/ApiExplorer/ApiCodeBlock/CopyButton";
|
|
20
|
+
import ExpandButton from "@theme/ApiExplorer/ApiCodeBlock/ExpandButton";
|
|
21
|
+
import Line from "@theme/ApiExplorer/ApiCodeBlock/Line";
|
|
22
|
+
import WordWrapButton from "@theme/ApiExplorer/ApiCodeBlock/WordWrapButton";
|
|
23
|
+
import type { Props } from "@theme/CodeBlock/Content/String";
|
|
24
|
+
import clsx from "clsx";
|
|
25
|
+
import { Highlight, Language } from "prism-react-renderer";
|
|
26
|
+
|
|
27
|
+
export default function CodeBlockString({
|
|
28
|
+
children,
|
|
29
|
+
className: blockClassName = "",
|
|
30
|
+
metastring,
|
|
31
|
+
title: titleProp,
|
|
32
|
+
showLineNumbers: showLineNumbersProp,
|
|
33
|
+
language: languageProp,
|
|
34
|
+
}: Props): React.JSX.Element {
|
|
35
|
+
const {
|
|
36
|
+
prism: { defaultLanguage, magicComments },
|
|
37
|
+
} = useThemeConfig();
|
|
38
|
+
const language =
|
|
39
|
+
languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage;
|
|
40
|
+
const prismTheme = usePrismTheme();
|
|
41
|
+
const wordWrap = useCodeWordWrap();
|
|
42
|
+
// We still parse the metastring in case we want to support more syntax in the
|
|
43
|
+
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
44
|
+
// "title=\"xyz\"" => title: "\"xyz\""
|
|
45
|
+
const title = parseCodeBlockTitle(metastring) || titleProp;
|
|
46
|
+
const { lineClassNames, code } = parseLines(children, {
|
|
47
|
+
metastring,
|
|
48
|
+
language,
|
|
49
|
+
magicComments,
|
|
50
|
+
});
|
|
51
|
+
const showLineNumbers =
|
|
52
|
+
showLineNumbersProp ?? containsLineNumbers(metastring);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Container
|
|
56
|
+
as="div"
|
|
57
|
+
className={clsx(
|
|
58
|
+
blockClassName,
|
|
59
|
+
language &&
|
|
60
|
+
!blockClassName.includes(`language-${language}`) &&
|
|
61
|
+
`language-${language}`
|
|
62
|
+
)}
|
|
63
|
+
>
|
|
64
|
+
{title && (
|
|
65
|
+
<div className="openapi-explorer__code-block-title">{title}</div>
|
|
66
|
+
)}
|
|
67
|
+
<div className="openapi-explorer__code-block-content">
|
|
68
|
+
<Highlight
|
|
69
|
+
// {...defaultProps}
|
|
70
|
+
theme={prismTheme}
|
|
71
|
+
code={code}
|
|
72
|
+
language={language ?? "text"}
|
|
73
|
+
>
|
|
74
|
+
{({ className, tokens, getLineProps, getTokenProps }) => (
|
|
75
|
+
<pre
|
|
76
|
+
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
77
|
+
tabIndex={0}
|
|
78
|
+
ref={wordWrap.codeBlockRef}
|
|
79
|
+
className={clsx(
|
|
80
|
+
className,
|
|
81
|
+
"openapi-explorer__code-block",
|
|
82
|
+
"thin-scrollbar"
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
<code
|
|
86
|
+
className={clsx(
|
|
87
|
+
"openapi-explorer__code-block-lines",
|
|
88
|
+
showLineNumbers &&
|
|
89
|
+
"openapi-explorer__code-block-lines-numbering"
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
{tokens.map((line, i) => (
|
|
93
|
+
<Line
|
|
94
|
+
key={i}
|
|
95
|
+
line={line}
|
|
96
|
+
getLineProps={getLineProps}
|
|
97
|
+
getTokenProps={getTokenProps}
|
|
98
|
+
classNames={lineClassNames[i]}
|
|
99
|
+
showLineNumbers={showLineNumbers}
|
|
100
|
+
/>
|
|
101
|
+
))}
|
|
102
|
+
</code>
|
|
103
|
+
</pre>
|
|
104
|
+
)}
|
|
105
|
+
</Highlight>
|
|
106
|
+
<div className="openapi-explorer__code-block-btn-group">
|
|
107
|
+
{(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
|
|
108
|
+
<WordWrapButton
|
|
109
|
+
className="openapi-explorer__code-block-code-btn"
|
|
110
|
+
onClick={() => wordWrap.toggle()}
|
|
111
|
+
isEnabled={wordWrap.isEnabled}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
<CopyButton
|
|
115
|
+
className="openapi-explorer__code-block-code-btn"
|
|
116
|
+
code={code}
|
|
117
|
+
/>
|
|
118
|
+
<ExpandButton
|
|
119
|
+
className={clsx(
|
|
120
|
+
"openapi-explorer__code-block-code-btn",
|
|
121
|
+
"openapi-explorer__expand-btn"
|
|
122
|
+
)}
|
|
123
|
+
code={code}
|
|
124
|
+
language={(language ?? "text") as Language}
|
|
125
|
+
showLineNumbers={showLineNumbers}
|
|
126
|
+
blockClassName={blockClassName}
|
|
127
|
+
title={title}
|
|
128
|
+
lineClassNames={lineClassNames}
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</Container>
|
|
133
|
+
);
|
|
134
|
+
}
|