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,57 @@
|
|
|
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 clsx from "clsx";
|
|
11
|
+
|
|
12
|
+
export interface Props {
|
|
13
|
+
value?: string;
|
|
14
|
+
options: string[];
|
|
15
|
+
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
16
|
+
showErrors?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function FormMultiSelect({ value, options, onChange, showErrors }: Props) {
|
|
20
|
+
if (options.length === 0) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let height;
|
|
25
|
+
if (options.length < 6) {
|
|
26
|
+
const selectPadding = 12 * 2;
|
|
27
|
+
const rawHeight = options.length * 29;
|
|
28
|
+
const innerMargins = 4 * options.length - 1;
|
|
29
|
+
const outerMargins = 4 * 2;
|
|
30
|
+
const mysteryScroll = 1;
|
|
31
|
+
height =
|
|
32
|
+
rawHeight + innerMargins + outerMargins + selectPadding + mysteryScroll;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<select
|
|
37
|
+
style={{ height: height }}
|
|
38
|
+
className={clsx("openapi-explorer__multi-select-input", {
|
|
39
|
+
error: showErrors,
|
|
40
|
+
})}
|
|
41
|
+
value={value}
|
|
42
|
+
onChange={onChange}
|
|
43
|
+
size={Math.min(6, options.length + 1)}
|
|
44
|
+
multiple
|
|
45
|
+
>
|
|
46
|
+
{options.map((option) => {
|
|
47
|
+
return (
|
|
48
|
+
<option key={option} value={option}>
|
|
49
|
+
{option}
|
|
50
|
+
</option>
|
|
51
|
+
);
|
|
52
|
+
})}
|
|
53
|
+
</select>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default FormMultiSelect;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
html[data-theme="dark"] .openapi-explorer__select-input {
|
|
2
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
3
|
+
background-color: var(--openapi-input-background);
|
|
4
|
+
border: none;
|
|
5
|
+
outline: none;
|
|
6
|
+
width: 100%;
|
|
7
|
+
color: var(--ifm-pre-color);
|
|
8
|
+
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
-moz-appearance: none;
|
|
11
|
+
-webkit-appearance: none;
|
|
12
|
+
appearance: none;
|
|
13
|
+
|
|
14
|
+
background-image: url('data:image/svg+xml;charset=US-ASCII,<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" fill="white"><path d="M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z"></path></svg>');
|
|
15
|
+
background-repeat: no-repeat;
|
|
16
|
+
background-position: right var(--ifm-pre-padding) top 50%;
|
|
17
|
+
background-size: auto auto;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.openapi-explorer__select-input {
|
|
21
|
+
width: 100%;
|
|
22
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
23
|
+
padding: var(--openapi-explorer-padding-input);
|
|
24
|
+
border: none;
|
|
25
|
+
outline: none;
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
background-color: var(--openapi-input-background);
|
|
28
|
+
font-size: var(--openapi-explorer-font-size-input);
|
|
29
|
+
font-family: var(--ifm-font-family-monospace);
|
|
30
|
+
color: var(--ifm-pre-color);
|
|
31
|
+
-moz-appearance: none;
|
|
32
|
+
-webkit-appearance: none;
|
|
33
|
+
appearance: none;
|
|
34
|
+
|
|
35
|
+
background-image: url('data:image/svg+xml;charset=US-ASCII,<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z"></path></svg>');
|
|
36
|
+
background-repeat: no-repeat;
|
|
37
|
+
background-position: right var(--ifm-pre-padding) top 50%;
|
|
38
|
+
background-size: auto auto;
|
|
39
|
+
|
|
40
|
+
&:focus {
|
|
41
|
+
box-shadow: inset 0px 0px 0px 2px var(--openapi-input-border);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
export interface Props {
|
|
11
|
+
value?: string;
|
|
12
|
+
options?: string[];
|
|
13
|
+
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function FormSelect({ value, options, onChange }: Props) {
|
|
17
|
+
if (!Array.isArray(options) || options.length === 0) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<select
|
|
23
|
+
className="openapi-explorer__select-input"
|
|
24
|
+
value={value}
|
|
25
|
+
onChange={onChange}
|
|
26
|
+
>
|
|
27
|
+
{options.map((option) => {
|
|
28
|
+
return (
|
|
29
|
+
<option key={option} value={option}>
|
|
30
|
+
{option}
|
|
31
|
+
</option>
|
|
32
|
+
);
|
|
33
|
+
})}
|
|
34
|
+
</select>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default FormSelect;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.openapi-explorer__form-item-input {
|
|
2
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
3
|
+
background-color: var(--openapi-input-background);
|
|
4
|
+
border: 1px solid transparent;
|
|
5
|
+
outline: none;
|
|
6
|
+
width: 100%;
|
|
7
|
+
color: var(--ifm-pre-color);
|
|
8
|
+
padding: var(--openapi-explorer-padding-input);
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
|
|
11
|
+
&:hover {
|
|
12
|
+
border: 1px solid var(--ifm-toc-border-color);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&:focus {
|
|
16
|
+
border: 1px solid var(--ifm-color-primary);
|
|
17
|
+
box-shadow: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.error {
|
|
21
|
+
border: 1px solid var(--openapi-required);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.openapi-explorer__input-error {
|
|
26
|
+
font-size: var(--openapi-explorer-font-size-input);
|
|
27
|
+
color: var(--openapi-required);
|
|
28
|
+
padding-top: var(--openapi-explorer-padding-input);
|
|
29
|
+
|
|
30
|
+
&::before {
|
|
31
|
+
display: inline;
|
|
32
|
+
content: "⚠ ";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
// @ts-nocheck
|
|
9
|
+
import React from "react";
|
|
10
|
+
|
|
11
|
+
import { ErrorMessage } from "@hookform/error-message";
|
|
12
|
+
import clsx from "clsx";
|
|
13
|
+
import { useFormContext } from "react-hook-form";
|
|
14
|
+
|
|
15
|
+
export interface Props {
|
|
16
|
+
value?: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
password?: boolean;
|
|
19
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function FormTextInput({
|
|
23
|
+
isRequired,
|
|
24
|
+
value,
|
|
25
|
+
placeholder,
|
|
26
|
+
password,
|
|
27
|
+
onChange,
|
|
28
|
+
paramName,
|
|
29
|
+
}: Props) {
|
|
30
|
+
placeholder = placeholder?.split("\n")[0];
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
register,
|
|
34
|
+
formState: { errors },
|
|
35
|
+
} = useFormContext();
|
|
36
|
+
|
|
37
|
+
const showErrorMessage = errors?.[paramName]?.message;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
{paramName ? (
|
|
42
|
+
<input
|
|
43
|
+
{...register(paramName, {
|
|
44
|
+
required: isRequired ? "This field is required" : false,
|
|
45
|
+
})}
|
|
46
|
+
className={clsx("openapi-explorer__form-item-input", {
|
|
47
|
+
error: showErrorMessage,
|
|
48
|
+
})}
|
|
49
|
+
type={password ? "password" : "text"}
|
|
50
|
+
placeholder={placeholder}
|
|
51
|
+
title={placeholder}
|
|
52
|
+
value={value}
|
|
53
|
+
onChange={onChange}
|
|
54
|
+
autoComplete="off"
|
|
55
|
+
/>
|
|
56
|
+
) : (
|
|
57
|
+
<input
|
|
58
|
+
className="openapi-explorer__form-item-input"
|
|
59
|
+
type={password ? "password" : "text"}
|
|
60
|
+
placeholder={placeholder}
|
|
61
|
+
title={placeholder}
|
|
62
|
+
value={value}
|
|
63
|
+
onChange={onChange}
|
|
64
|
+
autoComplete="off"
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
{showErrorMessage && (
|
|
68
|
+
<ErrorMessage
|
|
69
|
+
errors={errors}
|
|
70
|
+
name={paramName}
|
|
71
|
+
render={({ message }) => (
|
|
72
|
+
<div className="openapi-explorer__input-error">{message}</div>
|
|
73
|
+
)}
|
|
74
|
+
/>
|
|
75
|
+
)}
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default FormTextInput;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.openapi-explorer__playground-container {
|
|
2
|
+
margin-top: 1rem;
|
|
3
|
+
margin-bottom: var(--ifm-leading);
|
|
4
|
+
border-radius: var(--ifm-global-radius);
|
|
5
|
+
box-shadow: var(--ifm-global-shadow-lw);
|
|
6
|
+
overflow: auto;
|
|
7
|
+
max-height: 500px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.openapi-explorer__playground-editor {
|
|
11
|
+
font: var(--ifm-code-font-size) / var(--ifm-pre-line-height)
|
|
12
|
+
var(--ifm-font-family-monospace) !important;
|
|
13
|
+
/* rtl:ignore */
|
|
14
|
+
direction: ltr;
|
|
15
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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, { type JSX, useEffect, useState } from "react";
|
|
9
|
+
|
|
10
|
+
import { usePrismTheme } from "@docusaurus/theme-common";
|
|
11
|
+
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
12
|
+
import { ErrorMessage } from "@hookform/error-message";
|
|
13
|
+
import { setStringRawBody } from "@theme/ApiExplorer/Body/slice";
|
|
14
|
+
import clsx from "clsx";
|
|
15
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
16
|
+
import { LiveProvider, LiveEditor, withLive } from "react-live";
|
|
17
|
+
|
|
18
|
+
function Live({ onEdit, showErrors }: any) {
|
|
19
|
+
const isBrowser = useIsBrowser();
|
|
20
|
+
const [editorDisabled, setEditorDisabled] = useState(false);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
onClick={() => setEditorDisabled(false)}
|
|
25
|
+
onBlur={() => setEditorDisabled(true)}
|
|
26
|
+
>
|
|
27
|
+
<LiveEditor
|
|
28
|
+
key={String(isBrowser)}
|
|
29
|
+
className={clsx({
|
|
30
|
+
"openapi-explorer__playground-editor": true,
|
|
31
|
+
"openapi-explorer__form-item-input": showErrors,
|
|
32
|
+
error: showErrors,
|
|
33
|
+
})}
|
|
34
|
+
onChange={onEdit}
|
|
35
|
+
disabled={editorDisabled}
|
|
36
|
+
tabMode="focus"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const LiveComponent = withLive(Live);
|
|
43
|
+
|
|
44
|
+
function App({
|
|
45
|
+
children,
|
|
46
|
+
transformCode,
|
|
47
|
+
value,
|
|
48
|
+
language,
|
|
49
|
+
action,
|
|
50
|
+
required: isRequired,
|
|
51
|
+
...props
|
|
52
|
+
}: any): JSX.Element {
|
|
53
|
+
const prismTheme = usePrismTheme();
|
|
54
|
+
const [code, setCode] = React.useState(children.replace(/\n$/, ""));
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
action(setStringRawBody(code));
|
|
58
|
+
}, [action, code]);
|
|
59
|
+
|
|
60
|
+
const {
|
|
61
|
+
control,
|
|
62
|
+
formState: { errors },
|
|
63
|
+
} = useFormContext();
|
|
64
|
+
|
|
65
|
+
const showErrorMessage = errors?.requestBody;
|
|
66
|
+
|
|
67
|
+
const handleChange = (snippet: string, onChange: any) => {
|
|
68
|
+
setCode(snippet);
|
|
69
|
+
onChange(snippet);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
className={clsx({
|
|
75
|
+
"openapi-explorer__playground-container": true,
|
|
76
|
+
})}
|
|
77
|
+
>
|
|
78
|
+
<LiveProvider
|
|
79
|
+
code={code}
|
|
80
|
+
transformCode={transformCode ?? ((code) => `${code};`)}
|
|
81
|
+
theme={prismTheme}
|
|
82
|
+
language={language}
|
|
83
|
+
{...props}
|
|
84
|
+
>
|
|
85
|
+
<Controller
|
|
86
|
+
control={control}
|
|
87
|
+
rules={{
|
|
88
|
+
required: isRequired && !code ? "This field is required" : false,
|
|
89
|
+
}}
|
|
90
|
+
name="requestBody"
|
|
91
|
+
render={({ field: { onChange, name } }) => (
|
|
92
|
+
<LiveComponent
|
|
93
|
+
onEdit={(e: any) => handleChange(e, onChange)}
|
|
94
|
+
name={name}
|
|
95
|
+
showErrors={showErrorMessage}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
/>
|
|
99
|
+
{showErrorMessage && (
|
|
100
|
+
<ErrorMessage
|
|
101
|
+
errors={errors}
|
|
102
|
+
name="requestBody"
|
|
103
|
+
render={({ message }) => (
|
|
104
|
+
<div className="openapi-explorer__input-error">{message}</div>
|
|
105
|
+
)}
|
|
106
|
+
/>
|
|
107
|
+
)}
|
|
108
|
+
</LiveProvider>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const LiveApp = withLive(App);
|
|
114
|
+
export default LiveApp;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.openapi__method-endpoint {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
max-width: 100%;
|
|
5
|
+
width: fit-content;
|
|
6
|
+
padding: 0.65rem;
|
|
7
|
+
border: 1px solid var(--ifm-toc-border-color);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.openapi__method-endpoint-path {
|
|
11
|
+
margin-bottom: 0;
|
|
12
|
+
margin-left: 0.5rem;
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
font-weight: normal;
|
|
15
|
+
font-family: var(--ifm-font-family-monospace);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.openapi__divider {
|
|
19
|
+
width: 100%;
|
|
20
|
+
margin: 1.5rem 0;
|
|
21
|
+
border-bottom: 1px solid var(--ifm-toc-border-color);
|
|
22
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 BrowserOnly from "@docusaurus/BrowserOnly";
|
|
11
|
+
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
12
|
+
|
|
13
|
+
function colorForMethod(method: string) {
|
|
14
|
+
switch (method.toLowerCase()) {
|
|
15
|
+
case "get":
|
|
16
|
+
return "primary";
|
|
17
|
+
case "post":
|
|
18
|
+
return "success";
|
|
19
|
+
case "delete":
|
|
20
|
+
return "danger";
|
|
21
|
+
case "put":
|
|
22
|
+
return "info";
|
|
23
|
+
case "patch":
|
|
24
|
+
return "warning";
|
|
25
|
+
case "head":
|
|
26
|
+
return "secondary";
|
|
27
|
+
case "event":
|
|
28
|
+
return "secondary";
|
|
29
|
+
default:
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Props {
|
|
35
|
+
method: string;
|
|
36
|
+
path: string;
|
|
37
|
+
context?: "endpoint" | "callback";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function MethodEndpoint({ method, path, context }: Props) {
|
|
41
|
+
let serverValue = useTypedSelector((state: any) => state.server.value);
|
|
42
|
+
let serverUrlWithVariables = "";
|
|
43
|
+
|
|
44
|
+
const renderServerUrl = () => {
|
|
45
|
+
if (context === "callback") {
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (serverValue && serverValue.variables) {
|
|
50
|
+
serverUrlWithVariables = serverValue.url.replace(/\/$/, "");
|
|
51
|
+
|
|
52
|
+
Object.keys(serverValue.variables).forEach((variable) => {
|
|
53
|
+
serverUrlWithVariables = serverUrlWithVariables.replace(
|
|
54
|
+
`{${variable}}`,
|
|
55
|
+
serverValue.variables?.[variable].default ?? ""
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<BrowserOnly>
|
|
62
|
+
{() => {
|
|
63
|
+
if (serverUrlWithVariables.length) {
|
|
64
|
+
return serverUrlWithVariables;
|
|
65
|
+
} else if (serverValue && serverValue.url) {
|
|
66
|
+
return serverValue.url;
|
|
67
|
+
}
|
|
68
|
+
}}
|
|
69
|
+
</BrowserOnly>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<pre className="openapi__method-endpoint">
|
|
76
|
+
<span className={"badge badge--" + colorForMethod(method)}>
|
|
77
|
+
{method === "event" ? "Webhook" : method.toUpperCase()}
|
|
78
|
+
</span>{" "}
|
|
79
|
+
{method !== "event" && (
|
|
80
|
+
<h2 className="openapi__method-endpoint-path">
|
|
81
|
+
{renderServerUrl()}
|
|
82
|
+
{`${path.replace(/{([a-z0-9-_]+)}/gi, ":$1")}`}
|
|
83
|
+
</h2>
|
|
84
|
+
)}
|
|
85
|
+
</pre>
|
|
86
|
+
<div className="openapi__divider" />
|
|
87
|
+
</>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default MethodEndpoint;
|
|
@@ -0,0 +1,175 @@
|
|
|
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, { useEffect, useState } from "react";
|
|
9
|
+
|
|
10
|
+
import { ErrorMessage } from "@hookform/error-message";
|
|
11
|
+
import { nanoid } from "@reduxjs/toolkit";
|
|
12
|
+
import FormSelect from "@theme/ApiExplorer/FormSelect";
|
|
13
|
+
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
|
|
14
|
+
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
|
|
15
|
+
import { useTypedDispatch } from "@theme/ApiItem/hooks";
|
|
16
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
17
|
+
|
|
18
|
+
export interface ParamProps {
|
|
19
|
+
param: Param;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function ArrayItem({
|
|
23
|
+
param,
|
|
24
|
+
onChange,
|
|
25
|
+
initialValue,
|
|
26
|
+
}: ParamProps & { onChange(value?: string): any; initialValue?: string }) {
|
|
27
|
+
const [value, setValue] = useState(initialValue || "");
|
|
28
|
+
|
|
29
|
+
if (param.schema?.items?.type === "boolean") {
|
|
30
|
+
return (
|
|
31
|
+
<FormSelect
|
|
32
|
+
options={["---", "true", "false"]}
|
|
33
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
34
|
+
const val = e.target.value;
|
|
35
|
+
onChange(val === "---" ? undefined : val);
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<FormTextInput
|
|
43
|
+
placeholder={param.description || param.name}
|
|
44
|
+
value={value}
|
|
45
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
46
|
+
setValue(e.target.value);
|
|
47
|
+
onChange(e.target.value);
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default function ParamArrayFormItem({ param }: ParamProps) {
|
|
54
|
+
const [items, setItems] = useState<{ id: string; value?: string }[]>([]);
|
|
55
|
+
const dispatch = useTypedDispatch();
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
control,
|
|
59
|
+
formState: { errors },
|
|
60
|
+
} = useFormContext();
|
|
61
|
+
|
|
62
|
+
const showErrorMessage = errors?.paramArray?.message;
|
|
63
|
+
|
|
64
|
+
function handleAddItem(e: any) {
|
|
65
|
+
e.preventDefault(); // prevent form from submitting
|
|
66
|
+
setItems((i) => [
|
|
67
|
+
...i,
|
|
68
|
+
{
|
|
69
|
+
id: nanoid(),
|
|
70
|
+
},
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const values = items
|
|
76
|
+
.map((item) => item.value)
|
|
77
|
+
.filter((item): item is string => !!item);
|
|
78
|
+
|
|
79
|
+
dispatch(
|
|
80
|
+
setParam({
|
|
81
|
+
...param,
|
|
82
|
+
value: values.length > 0 ? values : undefined,
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
|
+
}, [items]);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (param.schema?.example?.length > 0) {
|
|
91
|
+
const examplesWithIds = param.schema.example.map((item: any) => ({
|
|
92
|
+
id: nanoid(),
|
|
93
|
+
value: item.toString(),
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
setItems(examplesWithIds);
|
|
97
|
+
}
|
|
98
|
+
}, [param.schema.example, param.schema.length]);
|
|
99
|
+
|
|
100
|
+
function handleDeleteItem(itemToDelete: { id: string }) {
|
|
101
|
+
return () => {
|
|
102
|
+
const newItems = items.filter((i) => i.id !== itemToDelete.id);
|
|
103
|
+
setItems(newItems);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function handleChangeItem(itemToUpdate: { id: string }, onChange: any) {
|
|
108
|
+
return (value: string) => {
|
|
109
|
+
const newItems = items.map((i) => {
|
|
110
|
+
if (i.id === itemToUpdate.id) {
|
|
111
|
+
return { ...i, value: value };
|
|
112
|
+
}
|
|
113
|
+
return i;
|
|
114
|
+
});
|
|
115
|
+
setItems(newItems);
|
|
116
|
+
onChange(newItems);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<>
|
|
122
|
+
<Controller
|
|
123
|
+
control={control}
|
|
124
|
+
rules={{ required: param.required ? "This field is required" : false }}
|
|
125
|
+
name="paramArray"
|
|
126
|
+
render={({ field: { onChange, name } }) => (
|
|
127
|
+
<>
|
|
128
|
+
{items.map((item) => (
|
|
129
|
+
<div key={item.id} style={{ display: "flex" }}>
|
|
130
|
+
<ArrayItem
|
|
131
|
+
param={param}
|
|
132
|
+
onChange={handleChangeItem(item, onChange)}
|
|
133
|
+
initialValue={item.value}
|
|
134
|
+
/>
|
|
135
|
+
<button
|
|
136
|
+
className="openapi-explorer__delete-btn"
|
|
137
|
+
onClick={handleDeleteItem(item)}
|
|
138
|
+
>
|
|
139
|
+
<svg
|
|
140
|
+
focusable="false"
|
|
141
|
+
preserveAspectRatio="xMidYMid meet"
|
|
142
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
143
|
+
fill="currentColor"
|
|
144
|
+
width="16"
|
|
145
|
+
height="16"
|
|
146
|
+
viewBox="0 0 32 32"
|
|
147
|
+
aria-hidden="true"
|
|
148
|
+
>
|
|
149
|
+
<path d="M24 9.4L22.6 8 16 14.6 9.4 8 8 9.4 14.6 16 8 22.6 9.4 24 16 17.4 22.6 24 24 22.6 17.4 16 24 9.4z"></path>
|
|
150
|
+
<title>Delete</title>
|
|
151
|
+
</svg>
|
|
152
|
+
</button>
|
|
153
|
+
</div>
|
|
154
|
+
))}
|
|
155
|
+
<button
|
|
156
|
+
className="openapi-explorer__thin-btn"
|
|
157
|
+
onClick={handleAddItem}
|
|
158
|
+
>
|
|
159
|
+
Add item
|
|
160
|
+
</button>
|
|
161
|
+
</>
|
|
162
|
+
)}
|
|
163
|
+
/>
|
|
164
|
+
{showErrorMessage && (
|
|
165
|
+
<ErrorMessage
|
|
166
|
+
errors={errors}
|
|
167
|
+
name="paramArray"
|
|
168
|
+
render={({ message }) => (
|
|
169
|
+
<div className="openapi-explorer__input-error">{message}</div>
|
|
170
|
+
)}
|
|
171
|
+
/>
|
|
172
|
+
)}
|
|
173
|
+
</>
|
|
174
|
+
);
|
|
175
|
+
}
|