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,526 @@
|
|
|
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 { AuthState, Scheme } from "@theme/ApiExplorer/Authorization/slice";
|
|
9
|
+
import { Body, Content } from "@theme/ApiExplorer/Body/slice";
|
|
10
|
+
import {
|
|
11
|
+
ParameterObject,
|
|
12
|
+
ServerObject,
|
|
13
|
+
} from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
14
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
15
|
+
import sdk from "postman-collection";
|
|
16
|
+
|
|
17
|
+
type Param = {
|
|
18
|
+
value?: string | string[];
|
|
19
|
+
} & ParameterObject;
|
|
20
|
+
|
|
21
|
+
function setQueryParams(postman: sdk.Request, queryParams: Param[]) {
|
|
22
|
+
postman.url.query.clear();
|
|
23
|
+
|
|
24
|
+
const qp = queryParams
|
|
25
|
+
.map((param) => {
|
|
26
|
+
if (!param.value) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Handle array values
|
|
31
|
+
if (Array.isArray(param.value)) {
|
|
32
|
+
if (param.style === "spaceDelimited") {
|
|
33
|
+
return new sdk.QueryParam({
|
|
34
|
+
key: param.name,
|
|
35
|
+
value: param.value.join(" "),
|
|
36
|
+
});
|
|
37
|
+
} else if (param.style === "pipeDelimited") {
|
|
38
|
+
return new sdk.QueryParam({
|
|
39
|
+
key: param.name,
|
|
40
|
+
value: param.value.join("|"),
|
|
41
|
+
});
|
|
42
|
+
} else if (param.explode) {
|
|
43
|
+
return param.value.map(
|
|
44
|
+
(val) =>
|
|
45
|
+
new sdk.QueryParam({
|
|
46
|
+
key: param.name,
|
|
47
|
+
value: val,
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
return new sdk.QueryParam({
|
|
52
|
+
key: param.name,
|
|
53
|
+
value: param.value.join(","),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const decodedValue = decodeURI(param.value);
|
|
59
|
+
const tryJson = () => {
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(decodedValue);
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const jsonResult = tryJson();
|
|
68
|
+
|
|
69
|
+
// Handle object values
|
|
70
|
+
if (jsonResult && typeof jsonResult === "object") {
|
|
71
|
+
if (param.style === "deepObject") {
|
|
72
|
+
return Object.entries(jsonResult).map(
|
|
73
|
+
([key, val]) =>
|
|
74
|
+
new sdk.QueryParam({
|
|
75
|
+
key: `${param.name}[${key}]`,
|
|
76
|
+
value: val,
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
} else if (param.explode) {
|
|
80
|
+
return Object.entries(jsonResult).map(
|
|
81
|
+
([key, val]) =>
|
|
82
|
+
new sdk.QueryParam({
|
|
83
|
+
key: key,
|
|
84
|
+
value: val,
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
} else {
|
|
88
|
+
return new sdk.QueryParam({
|
|
89
|
+
key: param.name,
|
|
90
|
+
value: Object.entries(jsonResult)
|
|
91
|
+
.map(([key, val]) => `${key},${val}`)
|
|
92
|
+
.join(","),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Handle boolean values
|
|
98
|
+
if (typeof decodedValue === "boolean") {
|
|
99
|
+
return new sdk.QueryParam({
|
|
100
|
+
key: param.name,
|
|
101
|
+
value: decodedValue ? "true" : "false",
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Parameter allows empty value: "/hello?extended"
|
|
106
|
+
if (param.allowEmptyValue) {
|
|
107
|
+
if (decodedValue === "true") {
|
|
108
|
+
return new sdk.QueryParam({
|
|
109
|
+
key: param.name,
|
|
110
|
+
value: null,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return new sdk.QueryParam({
|
|
117
|
+
key: param.name,
|
|
118
|
+
value: param.value,
|
|
119
|
+
});
|
|
120
|
+
})
|
|
121
|
+
.flat() // Flatten the array in case of nested arrays from map
|
|
122
|
+
.filter((item) => item !== undefined);
|
|
123
|
+
|
|
124
|
+
if (qp.length > 0) {
|
|
125
|
+
postman.addQueryParams(qp);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function setPathParams(postman: sdk.Request, pathParams: Param[]) {
|
|
130
|
+
// Map through the path parameters
|
|
131
|
+
const source = pathParams.map((param) => {
|
|
132
|
+
if (!param.value) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let serializedValue;
|
|
137
|
+
|
|
138
|
+
// Handle different styles
|
|
139
|
+
if (Array.isArray(param.value)) {
|
|
140
|
+
if (param.style === "label") {
|
|
141
|
+
serializedValue = `.${param.value.join(".")}`;
|
|
142
|
+
} else if (param.style === "matrix") {
|
|
143
|
+
serializedValue = `;${param.name}=${param.value.join(";")}`;
|
|
144
|
+
} else {
|
|
145
|
+
serializedValue = param.value.join(",");
|
|
146
|
+
}
|
|
147
|
+
return new sdk.Variable({
|
|
148
|
+
key: param.name,
|
|
149
|
+
value: serializedValue,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const decodedValue = decodeURI(param.value);
|
|
154
|
+
const tryJson = () => {
|
|
155
|
+
try {
|
|
156
|
+
return JSON.parse(decodedValue);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const jsonResult = tryJson();
|
|
163
|
+
|
|
164
|
+
if (typeof jsonResult === "object") {
|
|
165
|
+
if (param.style === "matrix") {
|
|
166
|
+
serializedValue = Object.entries(jsonResult)
|
|
167
|
+
.map(([key, val]) => `;${key}=${val}`)
|
|
168
|
+
.join("");
|
|
169
|
+
} else {
|
|
170
|
+
serializedValue = Object.entries(jsonResult)
|
|
171
|
+
.map(([key, val]) => `${key}=${val}`)
|
|
172
|
+
.join(",");
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
serializedValue = decodedValue || `:${param.name}`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return new sdk.Variable({
|
|
179
|
+
key: param.name,
|
|
180
|
+
value: serializedValue,
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
postman.url.variables.assimilate(source, false);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function buildCookie(cookieParams: Param[]) {
|
|
188
|
+
const cookies = cookieParams
|
|
189
|
+
.map((param) => {
|
|
190
|
+
if (param.value) {
|
|
191
|
+
const decodedValue = decodeURI(param.value as string);
|
|
192
|
+
const tryJson = () => {
|
|
193
|
+
try {
|
|
194
|
+
return JSON.parse(decodedValue);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const jsonResult = tryJson();
|
|
201
|
+
if (typeof jsonResult === "object") {
|
|
202
|
+
if (param.style === "form") {
|
|
203
|
+
// Handle form style
|
|
204
|
+
if (param.explode) {
|
|
205
|
+
// Serialize each key-value pair as a separate cookie
|
|
206
|
+
return Object.entries(jsonResult).map(
|
|
207
|
+
([key, val]) =>
|
|
208
|
+
new sdk.Cookie({
|
|
209
|
+
key: key,
|
|
210
|
+
value: val,
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
} else {
|
|
214
|
+
// Serialize the object as a single cookie with key-value pairs joined by commas
|
|
215
|
+
return new sdk.Cookie({
|
|
216
|
+
key: param.name,
|
|
217
|
+
value: Object.entries(jsonResult)
|
|
218
|
+
.map(([key, val]) => `${key},${val}`)
|
|
219
|
+
.join(","),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
// Handle scalar values
|
|
225
|
+
return new sdk.Cookie({
|
|
226
|
+
key: param.name,
|
|
227
|
+
value: param.value,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return undefined;
|
|
232
|
+
})
|
|
233
|
+
.flat() // Flatten the array in case of nested arrays from map
|
|
234
|
+
.filter((item) => item !== undefined);
|
|
235
|
+
|
|
236
|
+
const list = new sdk.CookieList(null, cookies);
|
|
237
|
+
return list.toString();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function setHeaders(
|
|
241
|
+
postman: sdk.Request,
|
|
242
|
+
contentType: string,
|
|
243
|
+
accept: string,
|
|
244
|
+
cookie: string,
|
|
245
|
+
headerParams: Param[],
|
|
246
|
+
other: { key: string; value: string }[]
|
|
247
|
+
) {
|
|
248
|
+
postman.headers.clear();
|
|
249
|
+
|
|
250
|
+
if (contentType) {
|
|
251
|
+
postman.addHeader({ key: "Content-Type", value: contentType });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (accept) {
|
|
255
|
+
postman.addHeader({ key: "Accept", value: accept });
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
headerParams.forEach((param) => {
|
|
259
|
+
if (param.value) {
|
|
260
|
+
const decodedValue = decodeURI(param.value as string);
|
|
261
|
+
const tryJson = () => {
|
|
262
|
+
try {
|
|
263
|
+
return JSON.parse(decodedValue);
|
|
264
|
+
} catch (e) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const jsonResult = tryJson();
|
|
270
|
+
if (Array.isArray(param.value)) {
|
|
271
|
+
if (param.style === "simple") {
|
|
272
|
+
if (param.explode) {
|
|
273
|
+
// Each item in the array is a separate header
|
|
274
|
+
jsonResult.forEach((val: any) => {
|
|
275
|
+
postman.addHeader({ key: param.name, value: val });
|
|
276
|
+
});
|
|
277
|
+
} else {
|
|
278
|
+
// Array values are joined by commas
|
|
279
|
+
postman.addHeader({
|
|
280
|
+
key: param.name,
|
|
281
|
+
value: param.value.join(","),
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
} else if (typeof jsonResult === "object") {
|
|
286
|
+
if (param.style === "simple") {
|
|
287
|
+
if (param.explode) {
|
|
288
|
+
// Each key-value pair in the object is a separate header
|
|
289
|
+
Object.entries(jsonResult).forEach(([key, val]) => {
|
|
290
|
+
postman.addHeader({ key: param.name, value: `${key}=${val}` });
|
|
291
|
+
});
|
|
292
|
+
} else {
|
|
293
|
+
// Object is serialized as a single header with key-value pairs joined by commas
|
|
294
|
+
postman.addHeader({
|
|
295
|
+
key: param.name,
|
|
296
|
+
value: Object.entries(jsonResult)
|
|
297
|
+
.map(([key, val]) => `${key},${val}`)
|
|
298
|
+
.join(","),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
// Handle scalar values
|
|
304
|
+
postman.addHeader({ key: param.name, value: param.value });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
other.forEach((header) => {
|
|
310
|
+
postman.addHeader(header);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
if (cookie) {
|
|
314
|
+
postman.addHeader({ key: "Cookie", value: cookie });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// TODO: this is all a bit hacky
|
|
319
|
+
function setBody(clonedPostman: sdk.Request, body: Body) {
|
|
320
|
+
if (clonedPostman.body === undefined) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (body.type === "empty") {
|
|
325
|
+
clonedPostman.body = undefined;
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (body.type === "raw" && body.content?.type === "file") {
|
|
330
|
+
// treat it like file.
|
|
331
|
+
clonedPostman.body.mode = "file";
|
|
332
|
+
clonedPostman.body.file = { src: body.content.value.src };
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
switch (clonedPostman.body.mode) {
|
|
337
|
+
case "raw": {
|
|
338
|
+
// check file even though it should already be set from above
|
|
339
|
+
if (body.type !== "raw" || body.content?.type === "file") {
|
|
340
|
+
clonedPostman.body = undefined;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
clonedPostman.body.raw = body.content?.value ?? "";
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
case "formdata": {
|
|
347
|
+
clonedPostman.body.formdata?.clear();
|
|
348
|
+
if (body.type !== "form") {
|
|
349
|
+
// treat it like raw.
|
|
350
|
+
clonedPostman.body.mode = "raw";
|
|
351
|
+
clonedPostman.body.raw = `${body.content?.value}`;
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const params = Object.entries(body.content)
|
|
355
|
+
.filter((entry): entry is [string, NonNullable<Content>] => !!entry[1])
|
|
356
|
+
.map(([key, content]) => {
|
|
357
|
+
if (content.type === "file") {
|
|
358
|
+
return new sdk.FormParam({ key: key, ...content });
|
|
359
|
+
}
|
|
360
|
+
return new sdk.FormParam({ key: key, value: content.value });
|
|
361
|
+
});
|
|
362
|
+
clonedPostman.body.formdata?.assimilate(params, false);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
case "urlencoded": {
|
|
366
|
+
clonedPostman.body.urlencoded?.clear();
|
|
367
|
+
if (body.type !== "form") {
|
|
368
|
+
// treat it like raw.
|
|
369
|
+
clonedPostman.body.mode = "raw";
|
|
370
|
+
clonedPostman.body.raw = `${body.content?.value}`;
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const params = Object.entries(body.content)
|
|
374
|
+
.filter((entry): entry is [string, NonNullable<Content>] => !!entry[1])
|
|
375
|
+
.map(([key, content]) => {
|
|
376
|
+
if (content.type !== "file" && content.value) {
|
|
377
|
+
return new sdk.QueryParam({ key: key, value: content.value });
|
|
378
|
+
}
|
|
379
|
+
return undefined;
|
|
380
|
+
})
|
|
381
|
+
.filter((item): item is sdk.QueryParam => item !== undefined);
|
|
382
|
+
clonedPostman.body.urlencoded?.assimilate(params, false);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
default:
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// TODO: finish these types
|
|
391
|
+
interface Options {
|
|
392
|
+
server?: ServerObject;
|
|
393
|
+
queryParams: Param[];
|
|
394
|
+
pathParams: Param[];
|
|
395
|
+
cookieParams: Param[];
|
|
396
|
+
headerParams: Param[];
|
|
397
|
+
contentType: string;
|
|
398
|
+
accept: string;
|
|
399
|
+
body: Body;
|
|
400
|
+
auth: AuthState;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function buildPostmanRequest(
|
|
404
|
+
postman: sdk.Request,
|
|
405
|
+
{
|
|
406
|
+
queryParams,
|
|
407
|
+
pathParams,
|
|
408
|
+
cookieParams,
|
|
409
|
+
contentType,
|
|
410
|
+
accept,
|
|
411
|
+
headerParams,
|
|
412
|
+
body,
|
|
413
|
+
server,
|
|
414
|
+
auth,
|
|
415
|
+
}: Options
|
|
416
|
+
) {
|
|
417
|
+
const clonedPostman = cloneDeep(postman);
|
|
418
|
+
|
|
419
|
+
clonedPostman.url.protocol = undefined;
|
|
420
|
+
clonedPostman.url.host = [window.location.origin];
|
|
421
|
+
|
|
422
|
+
if (server) {
|
|
423
|
+
let url = server.url.replace(/\/$/, "");
|
|
424
|
+
const variables = server.variables;
|
|
425
|
+
if (variables) {
|
|
426
|
+
Object.keys(variables).forEach((variable) => {
|
|
427
|
+
url = url.replace(`{${variable}}`, variables[variable].default);
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
clonedPostman.url.host = [url];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
setQueryParams(clonedPostman, queryParams);
|
|
434
|
+
setPathParams(clonedPostman, pathParams);
|
|
435
|
+
|
|
436
|
+
const cookie = buildCookie(cookieParams);
|
|
437
|
+
let otherHeaders = [];
|
|
438
|
+
|
|
439
|
+
let selectedAuth: Scheme[] = [];
|
|
440
|
+
if (auth.selected !== undefined) {
|
|
441
|
+
selectedAuth = auth.options[auth.selected];
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
for (const a of selectedAuth) {
|
|
445
|
+
// Bearer Auth
|
|
446
|
+
if (a.type === "http" && a.scheme === "bearer") {
|
|
447
|
+
const { token } = auth.data[a.key];
|
|
448
|
+
if (token === undefined) {
|
|
449
|
+
otherHeaders.push({
|
|
450
|
+
key: "Authorization",
|
|
451
|
+
value: "Bearer <TOKEN>",
|
|
452
|
+
});
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
otherHeaders.push({
|
|
456
|
+
key: "Authorization",
|
|
457
|
+
value: `Bearer ${token}`,
|
|
458
|
+
});
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (a.type === "oauth2") {
|
|
463
|
+
let token;
|
|
464
|
+
if (auth.data[a.key]) {
|
|
465
|
+
token = auth.data[a.key].token;
|
|
466
|
+
}
|
|
467
|
+
if (token === undefined) {
|
|
468
|
+
otherHeaders.push({
|
|
469
|
+
key: "Authorization",
|
|
470
|
+
value: "Bearer <TOKEN>",
|
|
471
|
+
});
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
otherHeaders.push({
|
|
475
|
+
key: "Authorization",
|
|
476
|
+
value: `Bearer ${token}`,
|
|
477
|
+
});
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Basic Auth
|
|
482
|
+
if (a.type === "http" && a.scheme === "basic") {
|
|
483
|
+
const { username, password } = auth.data[a.key];
|
|
484
|
+
if (username === undefined || password === undefined) {
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
otherHeaders.push({
|
|
488
|
+
key: "Authorization",
|
|
489
|
+
value: `Basic ${window.btoa(`${username}:${password}`)}`,
|
|
490
|
+
});
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// API Key
|
|
495
|
+
if (a.type === "apiKey" && a.in === "header") {
|
|
496
|
+
const { apiKey } = auth.data[a.key];
|
|
497
|
+
if (apiKey === undefined) {
|
|
498
|
+
otherHeaders.push({
|
|
499
|
+
key: a.name,
|
|
500
|
+
value: `<${a.name ?? a.type}>`,
|
|
501
|
+
});
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
otherHeaders.push({
|
|
505
|
+
key: a.name,
|
|
506
|
+
value: apiKey,
|
|
507
|
+
});
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
setHeaders(
|
|
513
|
+
clonedPostman,
|
|
514
|
+
contentType,
|
|
515
|
+
accept,
|
|
516
|
+
cookie,
|
|
517
|
+
headerParams,
|
|
518
|
+
otherHeaders
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
setBody(clonedPostman, body);
|
|
522
|
+
|
|
523
|
+
return clonedPostman;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export default buildPostmanRequest;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 CodeSnippets from "@theme/ApiExplorer/CodeSnippets";
|
|
11
|
+
import Request from "@theme/ApiExplorer/Request";
|
|
12
|
+
import Response from "@theme/ApiExplorer/Response";
|
|
13
|
+
import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";
|
|
14
|
+
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
15
|
+
import sdk from "postman-collection";
|
|
16
|
+
|
|
17
|
+
function ApiExplorer({
|
|
18
|
+
item,
|
|
19
|
+
infoPath,
|
|
20
|
+
}: {
|
|
21
|
+
item: NonNullable<ApiItem>;
|
|
22
|
+
infoPath: string;
|
|
23
|
+
}) {
|
|
24
|
+
const postman = new sdk.Request(item.postman);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<SecuritySchemes infoPath={infoPath} />
|
|
29
|
+
{item.method !== "event" && (
|
|
30
|
+
<CodeSnippets
|
|
31
|
+
postman={postman}
|
|
32
|
+
codeSamples={(item as any)["x-codeSamples"] ?? []}
|
|
33
|
+
/>
|
|
34
|
+
)}
|
|
35
|
+
<Request item={item} />
|
|
36
|
+
<Response item={item} />
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default ApiExplorer;
|
|
@@ -0,0 +1,71 @@
|
|
|
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 { Middleware } from "@reduxjs/toolkit";
|
|
9
|
+
import {
|
|
10
|
+
setAuthData,
|
|
11
|
+
setSelectedAuth,
|
|
12
|
+
} from "@theme/ApiExplorer/Authorization/slice";
|
|
13
|
+
import { AppDispatch, RootState } from "@theme/ApiItem/store";
|
|
14
|
+
/* eslint-disable import/no-extraneous-dependencies*/
|
|
15
|
+
import { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
|
|
16
|
+
|
|
17
|
+
import { createStorage, hashArray } from "./storage-utils";
|
|
18
|
+
|
|
19
|
+
export function createPersistanceMiddleware(options: ThemeConfig["api"]) {
|
|
20
|
+
const persistanceMiddleware: Middleware<{}, RootState, AppDispatch> =
|
|
21
|
+
(storeAPI) => (next) => (action) => {
|
|
22
|
+
const result = next(action);
|
|
23
|
+
|
|
24
|
+
const state = storeAPI.getState();
|
|
25
|
+
|
|
26
|
+
const storage = createStorage("sessionStorage");
|
|
27
|
+
|
|
28
|
+
if (action.type === setAuthData.type) {
|
|
29
|
+
for (const [key, value] of Object.entries(state.auth.data)) {
|
|
30
|
+
if (Object.values(value as any).filter(Boolean).length > 0) {
|
|
31
|
+
storage.setItem(key, JSON.stringify(value));
|
|
32
|
+
} else {
|
|
33
|
+
storage.removeItem(key);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (action.type === setSelectedAuth.type) {
|
|
39
|
+
if (state.auth.selected) {
|
|
40
|
+
storage.setItem(
|
|
41
|
+
hashArray(Object.keys(state.auth.options)),
|
|
42
|
+
state.auth.selected
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// TODO: determine way to rehydrate without flashing
|
|
48
|
+
if (action.type === "contentType/setContentType") {
|
|
49
|
+
storage.setItem("contentType", action.payload);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (action.type === "accept/setAccept") {
|
|
53
|
+
storage.setItem("accept", action.payload);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (action.type === "server/setServer") {
|
|
57
|
+
storage.setItem("server", action.payload);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (action.type === "server/setServerVariable") {
|
|
61
|
+
const server = storage.getItem("server") ?? "{}";
|
|
62
|
+
const variables = JSON.parse(action.payload);
|
|
63
|
+
let serverObject = JSON.parse(server);
|
|
64
|
+
serverObject.variables[variables.key].default = variables.value;
|
|
65
|
+
storage.setItem("server", JSON.stringify(serverObject));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return result;
|
|
69
|
+
};
|
|
70
|
+
return persistanceMiddleware;
|
|
71
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
declare module "postman-collection" {
|
|
9
|
+
export = Request.sdk;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
declare module "react-modal";
|
|
@@ -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 crypto from "crypto-js";
|
|
9
|
+
|
|
10
|
+
export function hashArray(arr: string[]) {
|
|
11
|
+
function hash(message: string) {
|
|
12
|
+
return crypto.SHA1(message).toString();
|
|
13
|
+
}
|
|
14
|
+
const hashed = arr.map((item) => hash(item));
|
|
15
|
+
hashed.sort();
|
|
16
|
+
const res = hashed.join();
|
|
17
|
+
return hash(res);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Persistance = false | "localStorage" | "sessionStorage" | undefined;
|
|
21
|
+
|
|
22
|
+
export function createStorage(persistance: Persistance): Storage {
|
|
23
|
+
if (persistance === false) {
|
|
24
|
+
return {
|
|
25
|
+
getItem: () => null,
|
|
26
|
+
setItem: () => {},
|
|
27
|
+
clear: () => {},
|
|
28
|
+
key: () => null,
|
|
29
|
+
removeItem: () => {},
|
|
30
|
+
length: 0,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (persistance === "sessionStorage") {
|
|
35
|
+
return sessionStorage;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return localStorage;
|
|
39
|
+
}
|