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,157 @@
|
|
|
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 { useDoc } from "@docusaurus/plugin-content-docs/client";
|
|
11
|
+
import { usePrismTheme } from "@docusaurus/theme-common";
|
|
12
|
+
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
|
13
|
+
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
14
|
+
import SchemaTabs from "@theme/SchemaTabs";
|
|
15
|
+
import TabItem from "@theme/TabItem";
|
|
16
|
+
import clsx from "clsx";
|
|
17
|
+
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
18
|
+
|
|
19
|
+
import { clearResponse, clearCode, clearHeaders } from "./slice";
|
|
20
|
+
|
|
21
|
+
// TODO: We probably shouldn't attempt to format XML...
|
|
22
|
+
function formatXml(xml: string) {
|
|
23
|
+
const tab = " ";
|
|
24
|
+
let formatted = "";
|
|
25
|
+
let indent = "";
|
|
26
|
+
|
|
27
|
+
xml.split(/>\s*</).forEach((node) => {
|
|
28
|
+
if (node.match(/^\/\w/)) {
|
|
29
|
+
// decrease indent by one 'tab'
|
|
30
|
+
indent = indent.substring(tab.length);
|
|
31
|
+
}
|
|
32
|
+
formatted += indent + "<" + node + ">\r\n";
|
|
33
|
+
if (node.match(/^<?\w[^>]*[^/]$/)) {
|
|
34
|
+
// increase indent
|
|
35
|
+
indent += tab;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return formatted.substring(1, formatted.length - 3);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function Response({ item }: { item: ApiItem }) {
|
|
42
|
+
const metadata = useDoc();
|
|
43
|
+
const hideSendButton = metadata.frontMatter.hide_send_button;
|
|
44
|
+
const prismTheme = usePrismTheme();
|
|
45
|
+
const code = useTypedSelector((state: any) => state.response.code);
|
|
46
|
+
const headers = useTypedSelector((state: any) => state.response.headers);
|
|
47
|
+
const response = useTypedSelector((state: any) => state.response.value);
|
|
48
|
+
const dispatch = useTypedDispatch();
|
|
49
|
+
const responseStatusClass =
|
|
50
|
+
code &&
|
|
51
|
+
"openapi-response__dot " +
|
|
52
|
+
(parseInt(code) >= 400
|
|
53
|
+
? "openapi-response__dot--danger"
|
|
54
|
+
: parseInt(code) >= 200 && parseInt(code) < 300
|
|
55
|
+
? "openapi-response__dot--success"
|
|
56
|
+
: "openapi-response__dot--info");
|
|
57
|
+
|
|
58
|
+
if (!item.servers || hideSendButton) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let prettyResponse: string = response;
|
|
63
|
+
|
|
64
|
+
if (prettyResponse) {
|
|
65
|
+
try {
|
|
66
|
+
prettyResponse = JSON.stringify(JSON.parse(response), null, 2);
|
|
67
|
+
} catch {
|
|
68
|
+
if (response.startsWith("<")) {
|
|
69
|
+
prettyResponse = formatXml(response);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div className="openapi-explorer__response-container">
|
|
76
|
+
<div className="openapi-explorer__response-title-container">
|
|
77
|
+
<span className="openapi-explorer__response-title">Response</span>
|
|
78
|
+
<span
|
|
79
|
+
className="openapi-explorer__response-clear-btn"
|
|
80
|
+
onClick={() => {
|
|
81
|
+
dispatch(clearResponse());
|
|
82
|
+
dispatch(clearCode());
|
|
83
|
+
dispatch(clearHeaders());
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
Clear
|
|
87
|
+
</span>
|
|
88
|
+
</div>
|
|
89
|
+
<div
|
|
90
|
+
style={{
|
|
91
|
+
backgroundColor:
|
|
92
|
+
code && prettyResponse !== "Fetching..."
|
|
93
|
+
? prismTheme.plain.backgroundColor
|
|
94
|
+
: "transparent",
|
|
95
|
+
paddingLeft: "1rem",
|
|
96
|
+
paddingTop: "1rem",
|
|
97
|
+
...((prettyResponse === "Fetching..." || !code) && {
|
|
98
|
+
paddingBottom: "1rem",
|
|
99
|
+
}),
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
{code && prettyResponse !== "Fetching..." ? (
|
|
103
|
+
<SchemaTabs lazy>
|
|
104
|
+
{/* @ts-ignore */}
|
|
105
|
+
<TabItem
|
|
106
|
+
label={` ${code}`}
|
|
107
|
+
value="body"
|
|
108
|
+
attributes={{
|
|
109
|
+
className: clsx("openapi-response__dot", responseStatusClass),
|
|
110
|
+
}}
|
|
111
|
+
default
|
|
112
|
+
>
|
|
113
|
+
{/* @ts-ignore */}
|
|
114
|
+
<ApiCodeBlock
|
|
115
|
+
className="openapi-explorer__code-block openapi-response__status-code"
|
|
116
|
+
language={response.startsWith("<") ? `xml` : `json`}
|
|
117
|
+
>
|
|
118
|
+
{prettyResponse || (
|
|
119
|
+
<p className="openapi-explorer__response-placeholder-message">
|
|
120
|
+
Click the <code>Send API Request</code> button above and see
|
|
121
|
+
the response here!
|
|
122
|
+
</p>
|
|
123
|
+
)}
|
|
124
|
+
</ApiCodeBlock>
|
|
125
|
+
</TabItem>
|
|
126
|
+
{/* @ts-ignore */}
|
|
127
|
+
<TabItem label="Headers" value="headers">
|
|
128
|
+
{/* @ts-ignore */}
|
|
129
|
+
<ApiCodeBlock
|
|
130
|
+
className="openapi-explorer__code-block openapi-response__status-headers"
|
|
131
|
+
language={response.startsWith("<") ? `xml` : `json`}
|
|
132
|
+
>
|
|
133
|
+
{JSON.stringify(headers, undefined, 2)}
|
|
134
|
+
</ApiCodeBlock>
|
|
135
|
+
</TabItem>
|
|
136
|
+
</SchemaTabs>
|
|
137
|
+
) : prettyResponse === "Fetching..." ? (
|
|
138
|
+
<div className="openapi-explorer__loading-container">
|
|
139
|
+
<div className="openapi-response__lds-ring">
|
|
140
|
+
<div></div>
|
|
141
|
+
<div></div>
|
|
142
|
+
<div></div>
|
|
143
|
+
<div></div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
) : (
|
|
147
|
+
<p className="openapi-explorer__response-placeholder-message">
|
|
148
|
+
Click the <code>Send API Request</code> button above and see the
|
|
149
|
+
response here!
|
|
150
|
+
</p>
|
|
151
|
+
)}
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export default Response;
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
code?: string;
|
|
13
|
+
headers?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const initialState: State = {} as any;
|
|
17
|
+
|
|
18
|
+
export const slice = createSlice({
|
|
19
|
+
name: "response",
|
|
20
|
+
initialState,
|
|
21
|
+
reducers: {
|
|
22
|
+
setResponse: (state, action: PayloadAction<string>) => {
|
|
23
|
+
state.value = action.payload;
|
|
24
|
+
},
|
|
25
|
+
setCode: (state, action: PayloadAction<string>) => {
|
|
26
|
+
state.code = action.payload;
|
|
27
|
+
},
|
|
28
|
+
setHeaders: (state, action: PayloadAction<string>) => {
|
|
29
|
+
state.headers = action.payload;
|
|
30
|
+
},
|
|
31
|
+
clearResponse: (state) => {
|
|
32
|
+
state.value = undefined;
|
|
33
|
+
},
|
|
34
|
+
clearCode: (state) => {
|
|
35
|
+
state.code = undefined;
|
|
36
|
+
},
|
|
37
|
+
clearHeaders: (state) => {
|
|
38
|
+
state.headers = undefined;
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const {
|
|
44
|
+
setResponse,
|
|
45
|
+
clearResponse,
|
|
46
|
+
setCode,
|
|
47
|
+
clearCode,
|
|
48
|
+
setHeaders,
|
|
49
|
+
clearHeaders,
|
|
50
|
+
} = slice.actions;
|
|
51
|
+
|
|
52
|
+
export default slice.reducer;
|
|
@@ -0,0 +1,287 @@
|
|
|
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 Link from "@docusaurus/Link";
|
|
11
|
+
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
12
|
+
|
|
13
|
+
function SecuritySchemes(props: any) {
|
|
14
|
+
const options = useTypedSelector((state: any) => state.auth.options);
|
|
15
|
+
const selected = useTypedSelector((state: any) => state.auth.selected);
|
|
16
|
+
const infoAuthPath = `/${props.infoPath}#authentication`;
|
|
17
|
+
|
|
18
|
+
if (selected === undefined) return null;
|
|
19
|
+
|
|
20
|
+
if (options[selected]?.[0]?.type === undefined) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const selectedAuth = options[selected];
|
|
25
|
+
return (
|
|
26
|
+
<details className="openapi-security__details" open={false}>
|
|
27
|
+
<summary className="openapi-security__summary-container">
|
|
28
|
+
<h4 className="openapi-security__summary-header">
|
|
29
|
+
Authorization: {selectedAuth[0].name ?? selectedAuth[0].type}
|
|
30
|
+
</h4>
|
|
31
|
+
</summary>
|
|
32
|
+
{selectedAuth.map((auth: any) => {
|
|
33
|
+
const isHttp = auth.type === "http";
|
|
34
|
+
const isApiKey = auth.type === "apiKey";
|
|
35
|
+
const isOauth2 = auth.type === "oauth2";
|
|
36
|
+
const isOpenId = auth.type === "openIdConnect";
|
|
37
|
+
|
|
38
|
+
if (isHttp) {
|
|
39
|
+
if (auth.scheme === "bearer") {
|
|
40
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
41
|
+
return (
|
|
42
|
+
<React.Fragment key={auth.key}>
|
|
43
|
+
<pre
|
|
44
|
+
style={{
|
|
45
|
+
display: "flex",
|
|
46
|
+
flexDirection: "column",
|
|
47
|
+
background: "var(--openapi-card-background-color)",
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<span>
|
|
51
|
+
<strong>name:</strong>{" "}
|
|
52
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
53
|
+
</span>
|
|
54
|
+
<span>
|
|
55
|
+
<strong>type: </strong>
|
|
56
|
+
{type}
|
|
57
|
+
</span>
|
|
58
|
+
{scopes && scopes.length > 0 && (
|
|
59
|
+
<span>
|
|
60
|
+
<strong>scopes: </strong>
|
|
61
|
+
<code>
|
|
62
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
63
|
+
</code>
|
|
64
|
+
</span>
|
|
65
|
+
)}
|
|
66
|
+
{Object.keys(rest).map((k, i) => {
|
|
67
|
+
return (
|
|
68
|
+
<span key={k}>
|
|
69
|
+
<strong>{k}: </strong>
|
|
70
|
+
{typeof rest[k] === "object"
|
|
71
|
+
? JSON.stringify(rest[k], null, 2)
|
|
72
|
+
: String(rest[k])}
|
|
73
|
+
</span>
|
|
74
|
+
);
|
|
75
|
+
})}
|
|
76
|
+
</pre>
|
|
77
|
+
</React.Fragment>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
if (auth.scheme === "basic") {
|
|
81
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
82
|
+
return (
|
|
83
|
+
<React.Fragment key={auth.key}>
|
|
84
|
+
<pre
|
|
85
|
+
style={{
|
|
86
|
+
display: "flex",
|
|
87
|
+
flexDirection: "column",
|
|
88
|
+
background: "var(--openapi-card-background-color)",
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<span>
|
|
92
|
+
<strong>name:</strong>{" "}
|
|
93
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
94
|
+
</span>
|
|
95
|
+
<span>
|
|
96
|
+
<strong>type: </strong>
|
|
97
|
+
{type}
|
|
98
|
+
</span>
|
|
99
|
+
{scopes && scopes.length > 0 && (
|
|
100
|
+
<span>
|
|
101
|
+
<strong>scopes: </strong>
|
|
102
|
+
<code>
|
|
103
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
104
|
+
</code>
|
|
105
|
+
</span>
|
|
106
|
+
)}
|
|
107
|
+
{Object.keys(rest).map((k, i) => {
|
|
108
|
+
return (
|
|
109
|
+
<span key={k}>
|
|
110
|
+
<strong>{k}: </strong>
|
|
111
|
+
{typeof rest[k] === "object"
|
|
112
|
+
? JSON.stringify(rest[k], null, 2)
|
|
113
|
+
: String(rest[k])}
|
|
114
|
+
</span>
|
|
115
|
+
);
|
|
116
|
+
})}
|
|
117
|
+
</pre>
|
|
118
|
+
</React.Fragment>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return (
|
|
122
|
+
<React.Fragment key={auth.key}>
|
|
123
|
+
<pre
|
|
124
|
+
style={{
|
|
125
|
+
display: "flex",
|
|
126
|
+
flexDirection: "column",
|
|
127
|
+
background: "var(--openapi-card-background-color)",
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
<span>
|
|
131
|
+
<strong>name:</strong>{" "}
|
|
132
|
+
<Link to={infoAuthPath}>{auth.name ?? auth.key}</Link>
|
|
133
|
+
</span>
|
|
134
|
+
<span>
|
|
135
|
+
<strong>type: </strong>
|
|
136
|
+
{auth.type}
|
|
137
|
+
</span>
|
|
138
|
+
<span>
|
|
139
|
+
<strong>in: </strong>
|
|
140
|
+
{auth.in}
|
|
141
|
+
</span>
|
|
142
|
+
</pre>
|
|
143
|
+
</React.Fragment>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (isApiKey) {
|
|
148
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
149
|
+
return (
|
|
150
|
+
<React.Fragment key={auth.key}>
|
|
151
|
+
<pre
|
|
152
|
+
style={{
|
|
153
|
+
display: "flex",
|
|
154
|
+
flexDirection: "column",
|
|
155
|
+
background: "var(--openapi-card-background-color)",
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
<span>
|
|
159
|
+
<strong>name:</strong>{" "}
|
|
160
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
161
|
+
</span>
|
|
162
|
+
<span>
|
|
163
|
+
<strong>type: </strong>
|
|
164
|
+
{type}
|
|
165
|
+
</span>
|
|
166
|
+
{scopes && scopes.length > 0 && (
|
|
167
|
+
<span>
|
|
168
|
+
<strong>scopes: </strong>
|
|
169
|
+
<code>
|
|
170
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
171
|
+
</code>
|
|
172
|
+
</span>
|
|
173
|
+
)}
|
|
174
|
+
{Object.keys(rest).map((k, i) => {
|
|
175
|
+
return (
|
|
176
|
+
<span key={k}>
|
|
177
|
+
<strong>{k}: </strong>
|
|
178
|
+
{typeof rest[k] === "object"
|
|
179
|
+
? JSON.stringify(rest[k], null, 2)
|
|
180
|
+
: String(rest[k])}
|
|
181
|
+
</span>
|
|
182
|
+
);
|
|
183
|
+
})}
|
|
184
|
+
</pre>
|
|
185
|
+
</React.Fragment>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (isOauth2) {
|
|
190
|
+
const { name, key, type, scopes, flows, ...rest } = auth;
|
|
191
|
+
return (
|
|
192
|
+
<React.Fragment key={selected}>
|
|
193
|
+
<pre
|
|
194
|
+
style={{
|
|
195
|
+
display: "flex",
|
|
196
|
+
flexDirection: "column",
|
|
197
|
+
background: "var(--openapi-card-background-color)",
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
<span>
|
|
201
|
+
<strong>name:</strong>{" "}
|
|
202
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
203
|
+
</span>
|
|
204
|
+
<span>
|
|
205
|
+
<strong>type: </strong>
|
|
206
|
+
{type}
|
|
207
|
+
</span>
|
|
208
|
+
{scopes && scopes.length > 0 && (
|
|
209
|
+
<span>
|
|
210
|
+
<strong>scopes: </strong>
|
|
211
|
+
<code>
|
|
212
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
213
|
+
</code>
|
|
214
|
+
</span>
|
|
215
|
+
)}
|
|
216
|
+
{Object.keys(rest).map((k, i) => {
|
|
217
|
+
return (
|
|
218
|
+
<span key={k}>
|
|
219
|
+
<strong>{k}: </strong>
|
|
220
|
+
{typeof rest[k] === "object"
|
|
221
|
+
? JSON.stringify(rest[k], null, 2)
|
|
222
|
+
: String(rest[k])}
|
|
223
|
+
</span>
|
|
224
|
+
);
|
|
225
|
+
})}
|
|
226
|
+
{flows && (
|
|
227
|
+
<span>
|
|
228
|
+
<code>
|
|
229
|
+
<strong>flows: </strong>
|
|
230
|
+
{JSON.stringify(flows, null, 2)}
|
|
231
|
+
</code>
|
|
232
|
+
</span>
|
|
233
|
+
)}
|
|
234
|
+
</pre>
|
|
235
|
+
</React.Fragment>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (isOpenId) {
|
|
240
|
+
const { name, key, scopes, type, ...rest } = auth;
|
|
241
|
+
return (
|
|
242
|
+
<React.Fragment key={auth.key}>
|
|
243
|
+
<pre
|
|
244
|
+
style={{
|
|
245
|
+
display: "flex",
|
|
246
|
+
flexDirection: "column",
|
|
247
|
+
background: "var(--openapi-card-background-color)",
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
<span>
|
|
251
|
+
<strong>name:</strong>{" "}
|
|
252
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
253
|
+
</span>
|
|
254
|
+
<span>
|
|
255
|
+
<strong>type: </strong>
|
|
256
|
+
{type}
|
|
257
|
+
</span>
|
|
258
|
+
{scopes && scopes.length > 0 && (
|
|
259
|
+
<span>
|
|
260
|
+
<strong>scopes: </strong>
|
|
261
|
+
<code>
|
|
262
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
263
|
+
</code>
|
|
264
|
+
</span>
|
|
265
|
+
)}
|
|
266
|
+
{Object.keys(rest).map((k, i) => {
|
|
267
|
+
return (
|
|
268
|
+
<span key={k}>
|
|
269
|
+
<strong>{k}: </strong>
|
|
270
|
+
{typeof rest[k] === "object"
|
|
271
|
+
? JSON.stringify(rest[k], null, 2)
|
|
272
|
+
: String(rest[k])}
|
|
273
|
+
</span>
|
|
274
|
+
);
|
|
275
|
+
})}
|
|
276
|
+
</pre>
|
|
277
|
+
</React.Fragment>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return undefined;
|
|
282
|
+
})}
|
|
283
|
+
</details>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export default SecuritySchemes;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.openapi-explorer__server-container {
|
|
2
|
+
background: var(--openapi-card-background-color);
|
|
3
|
+
border-radius: var(--openapi-card-border-radius);
|
|
4
|
+
color: var(--ifm-pre-color);
|
|
5
|
+
line-height: var(--ifm-pre-line-height);
|
|
6
|
+
margin-bottom: var(--ifm-spacing-vertical);
|
|
7
|
+
margin-top: 0;
|
|
8
|
+
overflow: auto;
|
|
9
|
+
|
|
10
|
+
/* hack for view calculation when monaco is hidden */
|
|
11
|
+
position: relative;
|
|
12
|
+
|
|
13
|
+
&:empty {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.openapi-explorer__server-url {
|
|
19
|
+
font-size: var(--openapi-explorer-font-size-input);
|
|
20
|
+
font-family: var(--ifm-font-family-monospace);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.openapi-explorer__server-description {
|
|
24
|
+
padding-left: 0.5rem;
|
|
25
|
+
font-weight: var(--ifm-font-weight-bold);
|
|
26
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
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, { useState } from "react";
|
|
9
|
+
|
|
10
|
+
import FloatingButton from "@theme/ApiExplorer/FloatingButton";
|
|
11
|
+
import FormItem from "@theme/ApiExplorer/FormItem";
|
|
12
|
+
import FormSelect from "@theme/ApiExplorer/FormSelect";
|
|
13
|
+
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
|
|
14
|
+
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
15
|
+
|
|
16
|
+
import { setServer, setServerVariable } from "./slice";
|
|
17
|
+
|
|
18
|
+
function Server() {
|
|
19
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
20
|
+
const value = useTypedSelector((state: any) => state.server.value);
|
|
21
|
+
const options = useTypedSelector((state: any) => state.server.options);
|
|
22
|
+
const dispatch = useTypedDispatch();
|
|
23
|
+
|
|
24
|
+
if (options.length <= 0) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (options.length < 1 && value?.variables === undefined) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!value) {
|
|
33
|
+
const defaultOption = options[0];
|
|
34
|
+
dispatch(setServer(JSON.stringify(defaultOption)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Default to first option when existing server state is mismatched
|
|
38
|
+
if (value) {
|
|
39
|
+
const urlExists = options.find((s: any) => s.url === value.url);
|
|
40
|
+
if (!urlExists) {
|
|
41
|
+
const defaultOption = options[0];
|
|
42
|
+
dispatch(setServer(JSON.stringify(defaultOption)));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!isEditing) {
|
|
47
|
+
let url = "";
|
|
48
|
+
if (value) {
|
|
49
|
+
url = value.url.replace(/\/$/, "");
|
|
50
|
+
if (value.variables) {
|
|
51
|
+
Object.keys(value.variables).forEach((variable) => {
|
|
52
|
+
url = url.replace(
|
|
53
|
+
`{${variable}}`,
|
|
54
|
+
value.variables?.[variable].default ?? ""
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return (
|
|
60
|
+
<FloatingButton onClick={() => setIsEditing(true)} label="Edit">
|
|
61
|
+
<FormItem>
|
|
62
|
+
<span className="openapi-explorer__server-url" title={url}>
|
|
63
|
+
{url}
|
|
64
|
+
</span>
|
|
65
|
+
</FormItem>
|
|
66
|
+
</FloatingButton>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return (
|
|
70
|
+
<div className="openapi-explorer__server-container">
|
|
71
|
+
<FloatingButton onClick={() => setIsEditing(false)} label="Hide">
|
|
72
|
+
<FormItem>
|
|
73
|
+
<FormSelect
|
|
74
|
+
options={options.map((s: any) => s.url)}
|
|
75
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
76
|
+
dispatch(
|
|
77
|
+
setServer(
|
|
78
|
+
JSON.stringify(
|
|
79
|
+
options.filter((s: any) => s.url === e.target.value)[0]
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
}}
|
|
84
|
+
value={value?.url}
|
|
85
|
+
/>
|
|
86
|
+
<small className="openapi-explorer__server-description">
|
|
87
|
+
{value?.description}
|
|
88
|
+
</small>
|
|
89
|
+
</FormItem>
|
|
90
|
+
{value?.variables &&
|
|
91
|
+
Object.keys(value.variables).map((key) => {
|
|
92
|
+
if (value.variables?.[key].enum !== undefined) {
|
|
93
|
+
return (
|
|
94
|
+
<FormItem label={key}>
|
|
95
|
+
<FormSelect
|
|
96
|
+
options={value.variables[key].enum}
|
|
97
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
98
|
+
dispatch(
|
|
99
|
+
setServerVariable(
|
|
100
|
+
JSON.stringify({ key, value: e.target.value })
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
}}
|
|
104
|
+
value={value?.variables[key].default}
|
|
105
|
+
/>
|
|
106
|
+
</FormItem>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return (
|
|
110
|
+
<FormItem label={key}>
|
|
111
|
+
<FormTextInput
|
|
112
|
+
placeholder={value.variables?.[key].default}
|
|
113
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
114
|
+
dispatch(
|
|
115
|
+
setServerVariable(
|
|
116
|
+
JSON.stringify({ key, value: e.target.value })
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
}}
|
|
120
|
+
value={value?.variables?.[key].default}
|
|
121
|
+
/>
|
|
122
|
+
</FormItem>
|
|
123
|
+
);
|
|
124
|
+
})}
|
|
125
|
+
</FloatingButton>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export default Server;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
10
|
+
// TODO: we might want to export this
|
|
11
|
+
|
|
12
|
+
export interface State {
|
|
13
|
+
value?: ServerObject;
|
|
14
|
+
options: ServerObject[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const initialState: State = {} as any;
|
|
18
|
+
|
|
19
|
+
export const slice = createSlice({
|
|
20
|
+
name: "server",
|
|
21
|
+
initialState,
|
|
22
|
+
reducers: {
|
|
23
|
+
setServer: (state, action: PayloadAction<string>) => {
|
|
24
|
+
state.value = state.options.find(
|
|
25
|
+
(s) => s.url === JSON.parse(action.payload).url
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
setServerVariable: (state, action: PayloadAction<string>) => {
|
|
29
|
+
if (state.value?.variables) {
|
|
30
|
+
const parsedPayload = JSON.parse(action.payload);
|
|
31
|
+
state.value.variables[parsedPayload.key].default = parsedPayload.value;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const { setServer, setServerVariable } = slice.actions;
|
|
38
|
+
|
|
39
|
+
export default slice.reducer;
|