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