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,43 @@
|
|
|
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
|
+
export default function json2xml(o, tab) {
|
|
9
|
+
var toXml = function (v, name, ind) {
|
|
10
|
+
var xml = "";
|
|
11
|
+
if (v instanceof Array) {
|
|
12
|
+
for (var i = 0, n = v.length; i < n; i++)
|
|
13
|
+
xml += ind + toXml(v[i], name, ind + "\t") + "\n";
|
|
14
|
+
} else if (typeof v == "object") {
|
|
15
|
+
var hasChild = false;
|
|
16
|
+
xml += ind + "<" + name;
|
|
17
|
+
for (var m in v) {
|
|
18
|
+
if (m.charAt(0) === "@")
|
|
19
|
+
xml += " " + m.substr(1) + '="' + v[m].toString() + '"';
|
|
20
|
+
else hasChild = true;
|
|
21
|
+
}
|
|
22
|
+
xml += hasChild ? ">" : "/>";
|
|
23
|
+
if (hasChild) {
|
|
24
|
+
for (var m2 in v) {
|
|
25
|
+
if (m2 === "#text") xml += v[m2];
|
|
26
|
+
else if (m2 === "#cdata") xml += "<![CDATA[" + v[m2] + "]]>";
|
|
27
|
+
else if (m2.charAt(0) !== "@") xml += toXml(v[m2], m2, ind + "\t");
|
|
28
|
+
}
|
|
29
|
+
xml +=
|
|
30
|
+
(xml.charAt(xml.length - 1) === "\n" ? ind : "") +
|
|
31
|
+
"</" +
|
|
32
|
+
name +
|
|
33
|
+
">";
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
xml += ind + "<" + name + ">" + v.toString() + "</" + name + ">";
|
|
37
|
+
}
|
|
38
|
+
return xml;
|
|
39
|
+
},
|
|
40
|
+
xml = "";
|
|
41
|
+
for (var m3 in o) xml += toXml(o[m3], m3, "");
|
|
42
|
+
return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
|
|
43
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
export interface FileContent {
|
|
3
|
+
type: "file";
|
|
4
|
+
value: {
|
|
5
|
+
src: string;
|
|
6
|
+
content: Blob;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface StringContent {
|
|
10
|
+
type: "string";
|
|
11
|
+
value?: string;
|
|
12
|
+
}
|
|
13
|
+
export type Content = FileContent | StringContent | undefined;
|
|
14
|
+
export interface FormBody {
|
|
15
|
+
type: "form";
|
|
16
|
+
content: {
|
|
17
|
+
[key: string]: Content;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface RawBody {
|
|
21
|
+
type: "raw";
|
|
22
|
+
content: Content;
|
|
23
|
+
}
|
|
24
|
+
export interface EmptyBody {
|
|
25
|
+
type: "empty";
|
|
26
|
+
}
|
|
27
|
+
export type Body = EmptyBody | FormBody | RawBody;
|
|
28
|
+
export type State = Body;
|
|
29
|
+
export declare const slice: import("@reduxjs/toolkit").Slice<FormBody | RawBody | EmptyBody, {
|
|
30
|
+
clearRawBody: (_state: import("immer/dist/internal").WritableDraft<FormBody> | import("immer/dist/internal").WritableDraft<RawBody> | import("immer/dist/internal").WritableDraft<EmptyBody>) => {
|
|
31
|
+
type: "empty";
|
|
32
|
+
};
|
|
33
|
+
setStringRawBody: (_state: import("immer/dist/internal").WritableDraft<FormBody> | import("immer/dist/internal").WritableDraft<RawBody> | import("immer/dist/internal").WritableDraft<EmptyBody>, action: PayloadAction<string>) => {
|
|
34
|
+
type: "raw";
|
|
35
|
+
content: {
|
|
36
|
+
type: "string";
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
setFileRawBody: (_state: import("immer/dist/internal").WritableDraft<FormBody> | import("immer/dist/internal").WritableDraft<RawBody> | import("immer/dist/internal").WritableDraft<EmptyBody>, action: PayloadAction<FileContent["value"]>) => {
|
|
41
|
+
type: "raw";
|
|
42
|
+
content: {
|
|
43
|
+
type: "file";
|
|
44
|
+
value: {
|
|
45
|
+
src: string;
|
|
46
|
+
content: Blob;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
clearFormBodyKey: (state: import("immer/dist/internal").WritableDraft<FormBody> | import("immer/dist/internal").WritableDraft<RawBody> | import("immer/dist/internal").WritableDraft<EmptyBody>, action: PayloadAction<string>) => void;
|
|
51
|
+
setStringFormBody: (state: import("immer/dist/internal").WritableDraft<FormBody> | import("immer/dist/internal").WritableDraft<RawBody> | import("immer/dist/internal").WritableDraft<EmptyBody>, action: PayloadAction<{
|
|
52
|
+
key: string;
|
|
53
|
+
value: string;
|
|
54
|
+
}>) => import("immer/dist/internal").WritableDraft<FormBody>;
|
|
55
|
+
setFileFormBody: (state: import("immer/dist/internal").WritableDraft<FormBody> | import("immer/dist/internal").WritableDraft<RawBody> | import("immer/dist/internal").WritableDraft<EmptyBody>, action: PayloadAction<{
|
|
56
|
+
key: string;
|
|
57
|
+
value: FileContent["value"];
|
|
58
|
+
}>) => import("immer/dist/internal").WritableDraft<FormBody> | {
|
|
59
|
+
type: "form";
|
|
60
|
+
content: {
|
|
61
|
+
[x: string]: {
|
|
62
|
+
type: "file";
|
|
63
|
+
value: {
|
|
64
|
+
src: string;
|
|
65
|
+
content: Blob;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}, "body">;
|
|
71
|
+
export declare const clearRawBody: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"body/clearRawBody">, setStringRawBody: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "body/setStringRawBody">, setFileRawBody: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
72
|
+
src: string;
|
|
73
|
+
content: Blob;
|
|
74
|
+
}, "body/setFileRawBody">, clearFormBodyKey: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "body/clearFormBodyKey">, setStringFormBody: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
75
|
+
key: string;
|
|
76
|
+
value: string;
|
|
77
|
+
}, "body/setStringFormBody">, setFileFormBody: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
78
|
+
key: string;
|
|
79
|
+
value: FileContent["value"];
|
|
80
|
+
}, "body/setFileFormBody">;
|
|
81
|
+
declare const _default: import("redux").Reducer<FormBody | RawBody | EmptyBody>;
|
|
82
|
+
export default _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var _a;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.setFileFormBody =
|
|
11
|
+
exports.setStringFormBody =
|
|
12
|
+
exports.clearFormBodyKey =
|
|
13
|
+
exports.setFileRawBody =
|
|
14
|
+
exports.setStringRawBody =
|
|
15
|
+
exports.clearRawBody =
|
|
16
|
+
exports.slice =
|
|
17
|
+
void 0;
|
|
18
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
19
|
+
const initialState = {};
|
|
20
|
+
exports.slice = (0, toolkit_1.createSlice)({
|
|
21
|
+
name: "body",
|
|
22
|
+
initialState,
|
|
23
|
+
reducers: {
|
|
24
|
+
clearRawBody: (_state) => {
|
|
25
|
+
return {
|
|
26
|
+
type: "empty",
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
setStringRawBody: (_state, action) => {
|
|
30
|
+
return {
|
|
31
|
+
type: "raw",
|
|
32
|
+
content: {
|
|
33
|
+
type: "string",
|
|
34
|
+
value: action.payload,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
setFileRawBody: (_state, action) => {
|
|
39
|
+
return {
|
|
40
|
+
type: "raw",
|
|
41
|
+
content: {
|
|
42
|
+
type: "file",
|
|
43
|
+
value: action.payload,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
clearFormBodyKey: (state, action) => {
|
|
48
|
+
if (state?.type === "form") {
|
|
49
|
+
delete state.content[action.payload];
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
setStringFormBody: (state, action) => {
|
|
53
|
+
if (state?.type !== "form") {
|
|
54
|
+
return {
|
|
55
|
+
type: "form",
|
|
56
|
+
content: {
|
|
57
|
+
[action.payload.key]: {
|
|
58
|
+
type: "string",
|
|
59
|
+
value: action.payload.value,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
state.content[action.payload.key] = {
|
|
65
|
+
type: "string",
|
|
66
|
+
value: action.payload.value,
|
|
67
|
+
};
|
|
68
|
+
return state;
|
|
69
|
+
},
|
|
70
|
+
setFileFormBody: (state, action) => {
|
|
71
|
+
if (state?.type !== "form") {
|
|
72
|
+
return {
|
|
73
|
+
type: "form",
|
|
74
|
+
content: {
|
|
75
|
+
[action.payload.key]: {
|
|
76
|
+
type: "file",
|
|
77
|
+
value: action.payload.value,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
state.content[action.payload.key] = {
|
|
83
|
+
type: "file",
|
|
84
|
+
value: action.payload.value,
|
|
85
|
+
};
|
|
86
|
+
return state;
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
(_a = exports.slice.actions),
|
|
91
|
+
(exports.clearRawBody = _a.clearRawBody),
|
|
92
|
+
(exports.setStringRawBody = _a.setStringRawBody),
|
|
93
|
+
(exports.setFileRawBody = _a.setFileRawBody),
|
|
94
|
+
(exports.clearFormBodyKey = _a.clearFormBodyKey),
|
|
95
|
+
(exports.setStringFormBody = _a.setStringFormBody),
|
|
96
|
+
(exports.setFileFormBody = _a.setFileFormBody);
|
|
97
|
+
exports.default = exports.slice.reducer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type CodeSampleLanguage = "C" | "C#" | "C++" | "CoffeeScript" | "CSS" | "Dart" | "DM" | "Elixir" | "Go" | "Groovy" | "HTML" | "Java" | "JavaScript" | "Kotlin" | "Objective-C" | "OCaml" | "Perl" | "PHP" | "PowerShell" | "Python" | "R" | "Ruby" | "Rust" | "Scala" | "Shell" | "Swift" | "TypeScript";
|
|
2
|
+
export interface Language {
|
|
3
|
+
highlight: string;
|
|
4
|
+
language: string;
|
|
5
|
+
codeSampleLanguage: CodeSampleLanguage;
|
|
6
|
+
logoClass: string;
|
|
7
|
+
variant: string;
|
|
8
|
+
variants: string[];
|
|
9
|
+
options?: {
|
|
10
|
+
[key: string]: boolean;
|
|
11
|
+
};
|
|
12
|
+
sample?: string;
|
|
13
|
+
samples?: string[];
|
|
14
|
+
samplesSources?: string[];
|
|
15
|
+
samplesLabels?: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface CodeSample {
|
|
18
|
+
source: string;
|
|
19
|
+
lang: CodeSampleLanguage;
|
|
20
|
+
label?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type JSX } from "react";
|
|
2
|
+
import sdk from "postman-collection";
|
|
3
|
+
import { CodeSample, Language } from "./code-snippets-types";
|
|
4
|
+
export declare const languageSet: Language[];
|
|
5
|
+
export interface Props {
|
|
6
|
+
postman: sdk.Request;
|
|
7
|
+
codeSamples: CodeSample[];
|
|
8
|
+
}
|
|
9
|
+
declare function CodeSnippets({ postman, codeSamples }: Props): JSX.Element | null;
|
|
10
|
+
export default CodeSnippets;
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
(function () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
64
|
+
var __importDefault =
|
|
65
|
+
(this && this.__importDefault) ||
|
|
66
|
+
function (mod) {
|
|
67
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.languageSet = void 0;
|
|
71
|
+
const react_1 = __importStar(require("react"));
|
|
72
|
+
const useDocusaurusContext_1 = __importDefault(
|
|
73
|
+
require("@docusaurus/useDocusaurusContext")
|
|
74
|
+
);
|
|
75
|
+
const ApiCodeBlock_1 = __importDefault(
|
|
76
|
+
require("@theme/ApiExplorer/ApiCodeBlock")
|
|
77
|
+
);
|
|
78
|
+
const buildPostmanRequest_1 = __importDefault(
|
|
79
|
+
require("@theme/ApiExplorer/buildPostmanRequest")
|
|
80
|
+
);
|
|
81
|
+
const CodeTabs_1 = __importDefault(require("@theme/ApiExplorer/CodeTabs"));
|
|
82
|
+
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
83
|
+
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
84
|
+
const postman_code_generators_1 = __importDefault(
|
|
85
|
+
require("postman-code-generators")
|
|
86
|
+
);
|
|
87
|
+
const languages_1 = require("./languages");
|
|
88
|
+
exports.languageSet = (0, languages_1.generateLanguageSet)();
|
|
89
|
+
function CodeTab({ children, hidden, className }) {
|
|
90
|
+
return react_1.default.createElement(
|
|
91
|
+
"div",
|
|
92
|
+
{ role: "tabpanel", className: className, hidden },
|
|
93
|
+
children
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function CodeSnippets({ postman, codeSamples }) {
|
|
97
|
+
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
98
|
+
const contentType = (0, hooks_1.useTypedSelector)(
|
|
99
|
+
(state) => state.contentType.value
|
|
100
|
+
);
|
|
101
|
+
const accept = (0, hooks_1.useTypedSelector)((state) => state.accept.value);
|
|
102
|
+
const server = (0, hooks_1.useTypedSelector)((state) => state.server.value);
|
|
103
|
+
const body = (0, hooks_1.useTypedSelector)((state) => state.body);
|
|
104
|
+
const pathParams = (0, hooks_1.useTypedSelector)(
|
|
105
|
+
(state) => state.params.path
|
|
106
|
+
);
|
|
107
|
+
const queryParams = (0, hooks_1.useTypedSelector)(
|
|
108
|
+
(state) => state.params.query
|
|
109
|
+
);
|
|
110
|
+
const cookieParams = (0, hooks_1.useTypedSelector)(
|
|
111
|
+
(state) => state.params.cookie
|
|
112
|
+
);
|
|
113
|
+
const headerParams = (0, hooks_1.useTypedSelector)(
|
|
114
|
+
(state) => state.params.header
|
|
115
|
+
);
|
|
116
|
+
const auth = (0, hooks_1.useTypedSelector)((state) => state.auth);
|
|
117
|
+
const clonedAuth = (0, cloneDeep_1.default)(auth);
|
|
118
|
+
let placeholder;
|
|
119
|
+
function cleanCredentials(obj) {
|
|
120
|
+
for (const key in obj) {
|
|
121
|
+
if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
122
|
+
// use name as placeholder if exists
|
|
123
|
+
const comboAuthId = Object.keys(obj).join(" and ");
|
|
124
|
+
const authOptions =
|
|
125
|
+
clonedAuth?.options?.[key] ?? clonedAuth?.options?.[comboAuthId];
|
|
126
|
+
placeholder = authOptions?.[0]?.name;
|
|
127
|
+
obj[key] = cleanCredentials(obj[key]);
|
|
128
|
+
} else {
|
|
129
|
+
obj[key] = `<${placeholder ?? key}>`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return obj;
|
|
133
|
+
}
|
|
134
|
+
// scrub credentials from code snippets
|
|
135
|
+
const cleanedAuth = {
|
|
136
|
+
...clonedAuth,
|
|
137
|
+
data: cleanCredentials(clonedAuth.data),
|
|
138
|
+
};
|
|
139
|
+
// Create a Postman request object using cleanedAuth
|
|
140
|
+
const cleanedPostmanRequest = (0, buildPostmanRequest_1.default)(postman, {
|
|
141
|
+
queryParams,
|
|
142
|
+
pathParams,
|
|
143
|
+
cookieParams,
|
|
144
|
+
contentType,
|
|
145
|
+
accept,
|
|
146
|
+
headerParams,
|
|
147
|
+
body,
|
|
148
|
+
server,
|
|
149
|
+
auth: cleanedAuth,
|
|
150
|
+
});
|
|
151
|
+
// User-defined languages array
|
|
152
|
+
// Can override languageSet, change order of langs, override options and variants
|
|
153
|
+
const userDefinedLanguageSet =
|
|
154
|
+
siteConfig?.themeConfig?.languageTabs ?? exports.languageSet;
|
|
155
|
+
// Filter languageSet by user-defined langs
|
|
156
|
+
const filteredLanguageSet = exports.languageSet.filter((ls) => {
|
|
157
|
+
return userDefinedLanguageSet?.some((lang) => {
|
|
158
|
+
return lang.language === ls.language;
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
// Merge user-defined langs into languageSet
|
|
162
|
+
const mergedLangs = (0, languages_1.mergeCodeSampleLanguage)(
|
|
163
|
+
(0, languages_1.mergeArraysbyLanguage)(
|
|
164
|
+
userDefinedLanguageSet,
|
|
165
|
+
filteredLanguageSet
|
|
166
|
+
),
|
|
167
|
+
codeSamples
|
|
168
|
+
);
|
|
169
|
+
// Read defaultLang from localStorage
|
|
170
|
+
const defaultLang = mergedLangs.filter(
|
|
171
|
+
(lang) =>
|
|
172
|
+
lang.language === localStorage.getItem("docusaurus.tab.code-samples")
|
|
173
|
+
);
|
|
174
|
+
const [selectedVariant, setSelectedVariant] = (0, react_1.useState)();
|
|
175
|
+
const [selectedSample, setSelectedSample] = (0, react_1.useState)();
|
|
176
|
+
const [language, setLanguage] = (0, react_1.useState)(() => {
|
|
177
|
+
// Return first index if only 1 user-defined language exists
|
|
178
|
+
if (mergedLangs.length === 1) {
|
|
179
|
+
return mergedLangs[0];
|
|
180
|
+
}
|
|
181
|
+
// Fall back to language in localStorage or first user-defined language
|
|
182
|
+
return defaultLang[0] ?? mergedLangs[0];
|
|
183
|
+
});
|
|
184
|
+
const [codeText, setCodeText] = (0, react_1.useState)("");
|
|
185
|
+
const [codeSampleCodeText, setCodeSampleCodeText] = (0, react_1.useState)(
|
|
186
|
+
() => (0, languages_1.getCodeSampleSourceFromLanguage)(language)
|
|
187
|
+
);
|
|
188
|
+
(0, react_1.useEffect)(() => {
|
|
189
|
+
if (language && !!language.sample) {
|
|
190
|
+
setCodeSampleCodeText(
|
|
191
|
+
(0, languages_1.getCodeSampleSourceFromLanguage)(language)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
if (language && !!language.options) {
|
|
195
|
+
postman_code_generators_1.default.convert(
|
|
196
|
+
language.language,
|
|
197
|
+
language.variant,
|
|
198
|
+
cleanedPostmanRequest,
|
|
199
|
+
language.options,
|
|
200
|
+
(error, snippet) => {
|
|
201
|
+
if (error) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
setCodeText(snippet);
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
} else if (language && !language.options) {
|
|
208
|
+
const langSource = mergedLangs.filter(
|
|
209
|
+
(lang) => lang.language === language.language
|
|
210
|
+
);
|
|
211
|
+
// Merges user-defined language with default languageSet
|
|
212
|
+
// This allows users to define only the minimal properties necessary in languageTabs
|
|
213
|
+
// User-defined properties should override languageSet properties
|
|
214
|
+
const mergedLanguage = { ...langSource[0], ...language };
|
|
215
|
+
postman_code_generators_1.default.convert(
|
|
216
|
+
mergedLanguage.language,
|
|
217
|
+
mergedLanguage.variant,
|
|
218
|
+
cleanedPostmanRequest,
|
|
219
|
+
mergedLanguage.options,
|
|
220
|
+
(error, snippet) => {
|
|
221
|
+
if (error) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
setCodeText(snippet);
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
} else {
|
|
228
|
+
setCodeText("");
|
|
229
|
+
}
|
|
230
|
+
}, [
|
|
231
|
+
accept,
|
|
232
|
+
body,
|
|
233
|
+
contentType,
|
|
234
|
+
cookieParams,
|
|
235
|
+
headerParams,
|
|
236
|
+
language,
|
|
237
|
+
pathParams,
|
|
238
|
+
postman,
|
|
239
|
+
queryParams,
|
|
240
|
+
server,
|
|
241
|
+
cleanedPostmanRequest,
|
|
242
|
+
mergedLangs,
|
|
243
|
+
]);
|
|
244
|
+
// no dependencies was intentionally set for this particular hook. it's safe as long as if conditions are set
|
|
245
|
+
(0, react_1.useEffect)(function onSelectedVariantUpdate() {
|
|
246
|
+
if (selectedVariant && selectedVariant !== language?.variant) {
|
|
247
|
+
postman_code_generators_1.default.convert(
|
|
248
|
+
language.language,
|
|
249
|
+
selectedVariant,
|
|
250
|
+
cleanedPostmanRequest,
|
|
251
|
+
language.options,
|
|
252
|
+
(error, snippet) => {
|
|
253
|
+
if (error) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
setCodeText(snippet);
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
// no dependencies was intentionally set for this particular hook. it's safe as long as if conditions are set
|
|
262
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
263
|
+
(0, react_1.useEffect)(function onSelectedSampleUpdate() {
|
|
264
|
+
if (
|
|
265
|
+
language &&
|
|
266
|
+
language.samples &&
|
|
267
|
+
language.samplesSources &&
|
|
268
|
+
selectedSample &&
|
|
269
|
+
selectedSample !== language.sample
|
|
270
|
+
) {
|
|
271
|
+
const sampleIndex = language.samples.findIndex(
|
|
272
|
+
(smp) => smp === selectedSample
|
|
273
|
+
);
|
|
274
|
+
setCodeSampleCodeText(language.samplesSources[sampleIndex]);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
if (language === undefined) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
return react_1.default.createElement(
|
|
281
|
+
react_1.default.Fragment,
|
|
282
|
+
null,
|
|
283
|
+
react_1.default.createElement(
|
|
284
|
+
CodeTabs_1.default,
|
|
285
|
+
{
|
|
286
|
+
groupId: "code-samples",
|
|
287
|
+
action: {
|
|
288
|
+
setLanguage: setLanguage,
|
|
289
|
+
setSelectedVariant: setSelectedVariant,
|
|
290
|
+
setSelectedSample: setSelectedSample,
|
|
291
|
+
},
|
|
292
|
+
languageSet: mergedLangs,
|
|
293
|
+
defaultValue: defaultLang[0]?.language ?? mergedLangs[0].language,
|
|
294
|
+
lazy: true,
|
|
295
|
+
},
|
|
296
|
+
mergedLangs.map((lang) => {
|
|
297
|
+
return react_1.default.createElement(
|
|
298
|
+
CodeTab,
|
|
299
|
+
{
|
|
300
|
+
value: lang.language,
|
|
301
|
+
label: lang.language,
|
|
302
|
+
key: lang.language,
|
|
303
|
+
attributes: {
|
|
304
|
+
className: `openapi-tabs__code-item--${lang.logoClass}`,
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
lang.samples &&
|
|
308
|
+
react_1.default.createElement(
|
|
309
|
+
CodeTabs_1.default,
|
|
310
|
+
{
|
|
311
|
+
className: "openapi-tabs__code-container-inner",
|
|
312
|
+
action: {
|
|
313
|
+
setLanguage: setLanguage,
|
|
314
|
+
setSelectedSample: setSelectedSample,
|
|
315
|
+
},
|
|
316
|
+
includeSample: true,
|
|
317
|
+
currentLanguage: lang.language,
|
|
318
|
+
defaultValue: selectedSample,
|
|
319
|
+
languageSet: mergedLangs,
|
|
320
|
+
lazy: true,
|
|
321
|
+
},
|
|
322
|
+
lang.samples.map((sample, index) => {
|
|
323
|
+
return react_1.default.createElement(
|
|
324
|
+
CodeTab,
|
|
325
|
+
{
|
|
326
|
+
value: sample,
|
|
327
|
+
label: lang.samplesLabels
|
|
328
|
+
? lang.samplesLabels[index]
|
|
329
|
+
: sample,
|
|
330
|
+
key: `${lang.language}-${lang.sample}`,
|
|
331
|
+
attributes: {
|
|
332
|
+
className: `openapi-tabs__code-item--sample`,
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
react_1.default.createElement(
|
|
336
|
+
ApiCodeBlock_1.default,
|
|
337
|
+
{
|
|
338
|
+
language: lang.highlight,
|
|
339
|
+
className: "openapi-explorer__code-block",
|
|
340
|
+
showLineNumbers: true,
|
|
341
|
+
},
|
|
342
|
+
codeSampleCodeText
|
|
343
|
+
)
|
|
344
|
+
);
|
|
345
|
+
})
|
|
346
|
+
),
|
|
347
|
+
react_1.default.createElement(
|
|
348
|
+
CodeTabs_1.default,
|
|
349
|
+
{
|
|
350
|
+
className: "openapi-tabs__code-container-inner",
|
|
351
|
+
action: {
|
|
352
|
+
setLanguage: setLanguage,
|
|
353
|
+
setSelectedVariant: setSelectedVariant,
|
|
354
|
+
},
|
|
355
|
+
includeVariant: true,
|
|
356
|
+
currentLanguage: lang.language,
|
|
357
|
+
defaultValue: selectedVariant,
|
|
358
|
+
languageSet: mergedLangs,
|
|
359
|
+
lazy: true,
|
|
360
|
+
},
|
|
361
|
+
lang.variants.map((variant, index) => {
|
|
362
|
+
return react_1.default.createElement(
|
|
363
|
+
CodeTab,
|
|
364
|
+
{
|
|
365
|
+
value: variant.toLowerCase(),
|
|
366
|
+
label: variant.toUpperCase(),
|
|
367
|
+
key: `${lang.language}-${lang.variant}`,
|
|
368
|
+
attributes: {
|
|
369
|
+
className: `openapi-tabs__code-item--variant`,
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
react_1.default.createElement(
|
|
373
|
+
ApiCodeBlock_1.default,
|
|
374
|
+
{
|
|
375
|
+
language: lang.highlight,
|
|
376
|
+
className: "openapi-explorer__code-block",
|
|
377
|
+
showLineNumbers: true,
|
|
378
|
+
},
|
|
379
|
+
codeText
|
|
380
|
+
)
|
|
381
|
+
);
|
|
382
|
+
})
|
|
383
|
+
)
|
|
384
|
+
);
|
|
385
|
+
})
|
|
386
|
+
)
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
exports.default = CodeSnippets;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CodeSample, Language } from "./code-snippets-types";
|
|
2
|
+
export declare function mergeCodeSampleLanguage(languages: Language[], codeSamples: CodeSample[]): Language[];
|
|
3
|
+
export declare const mergeArraysbyLanguage: (arr1: any, arr2: any) => any[];
|
|
4
|
+
export declare function getCodeSampleSourceFromLanguage(language: Language): string;
|
|
5
|
+
export declare function generateLanguageSet(): Language[];
|