docusaurus-theme-openapi-docs 0.0.0-733 → 0.0.0-736
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/lib/theme/ApiExplorer/CodeSnippets/index.js +13 -7
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +29 -2
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
- package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/lib/theme/ApiExplorer/Request/_Request.scss +4 -2
- package/lib/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/markdown/schema.ts +3 -3
- package/src/markdown/utils.ts +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.js +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.js +4 -4
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +4 -4
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.js +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +1 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +5 -5
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/index.tsx +4 -4
- package/src/theme/ApiExplorer/Body/slice.ts +2 -2
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +22 -16
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +26 -4
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
- package/src/theme/ApiExplorer/CodeTabs/index.js +7 -7
- package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +1 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +1 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +1 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +5 -5
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +1 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +1 -1
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/src/theme/ApiExplorer/Request/_Request.scss +4 -2
- package/src/theme/ApiExplorer/Request/index.tsx +1 -1
- package/src/theme/ApiExplorer/Request/makeRequest.ts +3 -3
- package/src/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/src/theme/ApiExplorer/Response/index.tsx +2 -2
- package/src/theme/ApiExplorer/Server/index.tsx +8 -8
- package/src/theme/ApiExplorer/Server/slice.ts +1 -1
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +3 -3
- package/src/theme/ApiExplorer/persistanceMiddleware.ts +1 -1
- package/src/theme/ApiItem/index.tsx +3 -3
- package/src/theme/ApiItem/store.ts +2 -2
- package/src/theme/ApiTabs/index.js +6 -6
- package/src/theme/DiscriminatorTabs/index.js +4 -4
- package/src/theme/MimeTabs/index.js +4 -4
- package/src/theme/OperationTabs/index.js +4 -4
- package/src/theme/ParamsItem/index.js +3 -3
- package/src/theme/SchemaItem/index.js +1 -1
- package/src/theme/SchemaTabs/index.js +4 -4
- package/src/theme-openapi.d.ts +5 -5
|
@@ -56,6 +56,12 @@ var __importDefault =
|
|
|
56
56
|
};
|
|
57
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
58
|
exports.languageSet = void 0;
|
|
59
|
+
/* ============================================================================
|
|
60
|
+
* Copyright (c) Palo Alto Networks
|
|
61
|
+
*
|
|
62
|
+
* This source code is licensed under the MIT license found in the
|
|
63
|
+
* LICENSE file in the root directory of this source tree.
|
|
64
|
+
* ========================================================================== */
|
|
59
65
|
const react_1 = __importStar(require("react"));
|
|
60
66
|
const useDocusaurusContext_1 = __importDefault(
|
|
61
67
|
require("@docusaurus/useDocusaurusContext")
|
|
@@ -68,7 +74,6 @@ const buildPostmanRequest_1 = __importDefault(
|
|
|
68
74
|
);
|
|
69
75
|
const CodeTabs_1 = __importDefault(require("@theme/ApiExplorer/CodeTabs"));
|
|
70
76
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
71
|
-
const merge_1 = __importDefault(require("lodash/merge"));
|
|
72
77
|
const postman_code_generators_1 = __importDefault(
|
|
73
78
|
require("postman-code-generators")
|
|
74
79
|
);
|
|
@@ -193,7 +198,6 @@ function CodeTab({ children, hidden, className }) {
|
|
|
193
198
|
);
|
|
194
199
|
}
|
|
195
200
|
function CodeSnippets({ postman, codeSamples }) {
|
|
196
|
-
// TODO: match theme for vscode.
|
|
197
201
|
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
198
202
|
const contentType = (0, hooks_1.useTypedSelector)(
|
|
199
203
|
(state) => state.contentType.value
|
|
@@ -216,20 +220,22 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
216
220
|
const auth = (0, hooks_1.useTypedSelector)((state) => state.auth);
|
|
217
221
|
// User-defined languages array
|
|
218
222
|
// Can override languageSet, change order of langs, override options and variants
|
|
219
|
-
const
|
|
220
|
-
...(siteConfig?.themeConfig?.languageTabs ?? exports.languageSet),
|
|
221
|
-
];
|
|
223
|
+
const userDefinedLanguageSet = siteConfig?.themeConfig?.languageTabs;
|
|
222
224
|
// Filter languageSet by user-defined langs
|
|
223
225
|
const filteredLanguageSet = exports.languageSet.filter((ls) => {
|
|
224
|
-
return
|
|
226
|
+
return userDefinedLanguageSet?.some((lang) => {
|
|
225
227
|
return lang.language === ls.language;
|
|
226
228
|
});
|
|
227
229
|
});
|
|
228
230
|
// Merge user-defined langs into languageSet
|
|
229
231
|
const mergedLangs = (0, languages_1.mergeCodeSampleLanguage)(
|
|
230
|
-
(0,
|
|
232
|
+
(0, languages_1.mergeArraysbyLanguage)(
|
|
233
|
+
userDefinedLanguageSet,
|
|
234
|
+
filteredLanguageSet
|
|
235
|
+
),
|
|
231
236
|
codeSamples
|
|
232
237
|
);
|
|
238
|
+
console.log("merged", mergedLangs);
|
|
233
239
|
// Read defaultLang from localStorage
|
|
234
240
|
const defaultLang = mergedLangs.filter(
|
|
235
241
|
(lang) =>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { CodeSample, Language } from "./code-snippets-types";
|
|
2
2
|
export declare function mergeCodeSampleLanguage(languages: Language[], codeSamples: CodeSample[]): Language[];
|
|
3
|
+
export declare const mergeArraysbyLanguage: (arr1: any, arr2: any) => any[];
|
|
3
4
|
export declare function getCodeSampleSourceFromLanguage(language: Language): string;
|
|
@@ -5,9 +5,20 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
8
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.getCodeSampleSourceFromLanguage =
|
|
10
|
-
|
|
14
|
+
exports.getCodeSampleSourceFromLanguage =
|
|
15
|
+
exports.mergeArraysbyLanguage =
|
|
16
|
+
exports.mergeCodeSampleLanguage =
|
|
17
|
+
void 0;
|
|
18
|
+
const find_1 = __importDefault(require("lodash/find"));
|
|
19
|
+
const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
20
|
+
const mergeWith_1 = __importDefault(require("lodash/mergeWith"));
|
|
21
|
+
const unionBy_1 = __importDefault(require("lodash/unionBy"));
|
|
11
22
|
function mergeCodeSampleLanguage(languages, codeSamples) {
|
|
12
23
|
return languages.map((language) => {
|
|
13
24
|
const languageCodeSamples = codeSamples.filter(
|
|
@@ -31,6 +42,22 @@ function mergeCodeSampleLanguage(languages, codeSamples) {
|
|
|
31
42
|
});
|
|
32
43
|
}
|
|
33
44
|
exports.mergeCodeSampleLanguage = mergeCodeSampleLanguage;
|
|
45
|
+
const mergeArraysbyLanguage = (arr1, arr2) => {
|
|
46
|
+
const mergedArray = (0, unionBy_1.default)(arr1, arr2, "language");
|
|
47
|
+
return mergedArray.map((item) => {
|
|
48
|
+
const matchingItems = [
|
|
49
|
+
(0, find_1.default)(arr1, ["language", item["language"]]),
|
|
50
|
+
(0, find_1.default)(arr2, ["language", item["language"]]),
|
|
51
|
+
];
|
|
52
|
+
return (0, mergeWith_1.default)({}, ...matchingItems, (objValue) => {
|
|
53
|
+
if ((0, isArray_1.default)(objValue)) {
|
|
54
|
+
return objValue;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.mergeArraysbyLanguage = mergeArraysbyLanguage;
|
|
34
61
|
function getCodeSampleSourceFromLanguage(language) {
|
|
35
62
|
if (
|
|
36
63
|
language &&
|
|
@@ -18,12 +18,14 @@
|
|
|
18
18
|
background-color: var(--ifm-pre-background);
|
|
19
19
|
border-radius: var(--ifm-global-radius);
|
|
20
20
|
border: 1px solid var(--openapi-explorer-border-color);
|
|
21
|
-
box-shadow:
|
|
21
|
+
box-shadow:
|
|
22
|
+
0 2px 3px hsla(222, 8%, 43%, 0.1),
|
|
22
23
|
0 8px 16px -10px hsla(222, 8%, 43%, 0.2);
|
|
23
24
|
transition: 300ms;
|
|
24
25
|
|
|
25
26
|
&:hover {
|
|
26
|
-
box-shadow:
|
|
27
|
+
box-shadow:
|
|
28
|
+
0 0 0 2px rgba(38, 53, 61, 0.15),
|
|
27
29
|
0 2px 3px hsla(222, 8%, 43%, 0.15),
|
|
28
30
|
0 16px 16px -10px hsla(222, 8%, 43%, 0.2);
|
|
29
31
|
}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
padding: 0.4rem 0.5rem;
|
|
12
12
|
opacity: 0;
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
transition:
|
|
14
|
+
transition:
|
|
15
|
+
opacity 0.2s ease-in-out,
|
|
16
|
+
visibility 0.2s ease-in-out,
|
|
15
17
|
bottom 0.2s ease-in-out;
|
|
16
18
|
position: absolute;
|
|
17
19
|
right: calc(var(--ifm-pre-padding) / 2);
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
background-color: var(--ifm-pre-background);
|
|
3
3
|
border-radius: var(--openapi-card-border-radius);
|
|
4
4
|
border: 1px solid var(--openapi-explorer-border-color);
|
|
5
|
-
box-shadow:
|
|
5
|
+
box-shadow:
|
|
6
|
+
0 2px 3px hsla(222, 8%, 43%, 0.1),
|
|
6
7
|
0 8px 16px -10px hsla(222, 8%, 43%, 0.2);
|
|
7
8
|
color: var(--ifm-pre-color);
|
|
8
9
|
line-height: var(--ifm-pre-line-height);
|
|
@@ -19,7 +20,8 @@
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
&:hover {
|
|
22
|
-
box-shadow:
|
|
23
|
+
box-shadow:
|
|
24
|
+
0 0 0 2px rgba(38, 53, 61, 0.15),
|
|
23
25
|
0 2px 3px hsla(222, 8%, 43%, 0.15),
|
|
24
26
|
0 16px 16px -10px hsla(222, 8%, 43%, 0.2);
|
|
25
27
|
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
background-color: var(--ifm-pre-background);
|
|
3
3
|
border-radius: var(--openapi-card-border-radius);
|
|
4
4
|
border: 1px solid var(--openapi-explorer-border-color);
|
|
5
|
-
box-shadow:
|
|
5
|
+
box-shadow:
|
|
6
|
+
0 2px 3px hsla(222, 8%, 43%, 0.1),
|
|
6
7
|
0 8px 16px -10px hsla(222, 8%, 43%, 0.2);
|
|
7
8
|
color: var(--ifm-pre-color);
|
|
8
9
|
line-height: var(--ifm-pre-line-height);
|
|
@@ -12,7 +13,8 @@
|
|
|
12
13
|
transition: 300ms;
|
|
13
14
|
|
|
14
15
|
&:hover {
|
|
15
|
-
box-shadow:
|
|
16
|
+
box-shadow:
|
|
17
|
+
0 0 0 2px rgba(38, 53, 61, 0.15),
|
|
16
18
|
0 2px 3px hsla(222, 8%, 43%, 0.15),
|
|
17
19
|
0 16px 16px -10px hsla(222, 8%, 43%, 0.2);
|
|
18
20
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-736",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"clsx": "^1.1.1",
|
|
42
42
|
"copy-text-to-clipboard": "^3.1.0",
|
|
43
43
|
"crypto-js": "^4.1.1",
|
|
44
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
44
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-736",
|
|
45
45
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
46
46
|
"file-saver": "^2.0.5",
|
|
47
47
|
"lodash": "^4.17.20",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "ac63a892a690324697897289720d42d4bd3989fa"
|
|
72
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
|
|
|
18
18
|
getClientModules() {
|
|
19
19
|
const modules = [
|
|
20
20
|
require.resolve(
|
|
21
|
-
path.join(__dirname, "..", "lib", "theme", "styles.scss")
|
|
21
|
+
path.join(__dirname, "..", "lib", "theme", "styles.scss"),
|
|
22
22
|
),
|
|
23
23
|
];
|
|
24
24
|
return modules;
|
package/src/markdown/schema.ts
CHANGED
|
@@ -45,7 +45,7 @@ function prettyName(schema: SchemaObject, circular?: boolean) {
|
|
|
45
45
|
|
|
46
46
|
export function getSchemaName(
|
|
47
47
|
schema: SchemaObject,
|
|
48
|
-
circular?: boolean
|
|
48
|
+
circular?: boolean,
|
|
49
49
|
): string {
|
|
50
50
|
if (schema.items) {
|
|
51
51
|
return prettyName(schema.items, circular) + "[]";
|
|
@@ -79,7 +79,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
79
79
|
if (schema.items && schema.items.enum) {
|
|
80
80
|
if (schema.items.enum) {
|
|
81
81
|
qualifierGroups.push(
|
|
82
|
-
`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]
|
|
82
|
+
`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`,
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -150,7 +150,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
150
150
|
|
|
151
151
|
if (schema.pattern) {
|
|
152
152
|
qualifierGroups.push(
|
|
153
|
-
`Value must match regular expression \`${schema.pattern}
|
|
153
|
+
`Value must match regular expression \`${schema.pattern}\``,
|
|
154
154
|
);
|
|
155
155
|
}
|
|
156
156
|
|
package/src/markdown/utils.ts
CHANGED
|
@@ -22,7 +22,7 @@ export function create(tag: string, props: Props): string {
|
|
|
22
22
|
|
|
23
23
|
export function guard<T>(
|
|
24
24
|
value: T | undefined | string,
|
|
25
|
-
cb: (value: T) => Children
|
|
25
|
+
cb: (value: T) => Children,
|
|
26
26
|
): string {
|
|
27
27
|
if (!!value || value === 0) {
|
|
28
28
|
const children = cb(value as T);
|
|
@@ -21,7 +21,7 @@ export default function CodeBlockJSX({ children, className }) {
|
|
|
21
21
|
className={clsx(
|
|
22
22
|
"openapi-explorer__code-block-standalone",
|
|
23
23
|
"thin-scrollbar",
|
|
24
|
-
className
|
|
24
|
+
className,
|
|
25
25
|
)}
|
|
26
26
|
>
|
|
27
27
|
<code className="openapi-explorer__code-block-lines">{children}</code>
|
|
@@ -57,7 +57,7 @@ export default function CodeBlockString({
|
|
|
57
57
|
blockClassName,
|
|
58
58
|
language &&
|
|
59
59
|
!blockClassName.includes(`language-${language}`) &&
|
|
60
|
-
`language-${language}
|
|
60
|
+
`language-${language}`,
|
|
61
61
|
)}
|
|
62
62
|
>
|
|
63
63
|
{title && (
|
|
@@ -78,14 +78,14 @@ export default function CodeBlockString({
|
|
|
78
78
|
className={clsx(
|
|
79
79
|
className,
|
|
80
80
|
"openapi-explorer__code-block",
|
|
81
|
-
"thin-scrollbar"
|
|
81
|
+
"thin-scrollbar",
|
|
82
82
|
)}
|
|
83
83
|
>
|
|
84
84
|
<code
|
|
85
85
|
className={clsx(
|
|
86
86
|
"openapi-explorer__code-block-lines",
|
|
87
87
|
showLineNumbers &&
|
|
88
|
-
"openapi-explorer__code-block-lines-numbering"
|
|
88
|
+
"openapi-explorer__code-block-lines-numbering",
|
|
89
89
|
)}
|
|
90
90
|
>
|
|
91
91
|
{tokens.map((line, i) => (
|
|
@@ -117,7 +117,7 @@ export default function CodeBlockString({
|
|
|
117
117
|
<ExpandButton
|
|
118
118
|
className={clsx(
|
|
119
119
|
"openapi-explorer__code-block-code-btn",
|
|
120
|
-
"openapi-explorer__expand-btn"
|
|
120
|
+
"openapi-explorer__expand-btn",
|
|
121
121
|
)}
|
|
122
122
|
code={code}
|
|
123
123
|
language={language}
|
|
@@ -48,7 +48,7 @@ export default function CopyButton({ code, className }) {
|
|
|
48
48
|
"clean-btn",
|
|
49
49
|
className,
|
|
50
50
|
"openapi-explorer__code-block-copy-btn",
|
|
51
|
-
isCopied && "openapi-explorer__code-block-copy-btn--copied"
|
|
51
|
+
isCopied && "openapi-explorer__code-block-copy-btn--copied",
|
|
52
52
|
)}
|
|
53
53
|
onClick={handleCopyCode}
|
|
54
54
|
>
|
|
@@ -59,7 +59,7 @@ export default function ExpandButton({
|
|
|
59
59
|
"clean-btn",
|
|
60
60
|
className,
|
|
61
61
|
"openapi-explorer__code-block-expand-btn",
|
|
62
|
-
isModalOpen && "openapi-explorer__code-block-expand-btn--copied"
|
|
62
|
+
isModalOpen && "openapi-explorer__code-block-expand-btn--copied",
|
|
63
63
|
)}
|
|
64
64
|
onClick={() => setIsModalOpen(true)}
|
|
65
65
|
>
|
|
@@ -94,7 +94,7 @@ export default function ExpandButton({
|
|
|
94
94
|
"openapi-explorer__code-block-container",
|
|
95
95
|
language &&
|
|
96
96
|
!blockClassName.includes(`language-${language}`) &&
|
|
97
|
-
`language-${language}
|
|
97
|
+
`language-${language}`,
|
|
98
98
|
)}
|
|
99
99
|
>
|
|
100
100
|
{title && (
|
|
@@ -114,14 +114,14 @@ export default function ExpandButton({
|
|
|
114
114
|
className={clsx(
|
|
115
115
|
className,
|
|
116
116
|
"openapi-explorer__code-block",
|
|
117
|
-
"thin-scrollbar"
|
|
117
|
+
"thin-scrollbar",
|
|
118
118
|
)}
|
|
119
119
|
>
|
|
120
120
|
<code
|
|
121
121
|
className={clsx(
|
|
122
122
|
"openapi-explorer__code-block-lines",
|
|
123
123
|
showLineNumbers &&
|
|
124
|
-
"openapi-explorer__code-block-lines-numbers"
|
|
124
|
+
"openapi-explorer__code-block-lines-numbers",
|
|
125
125
|
)}
|
|
126
126
|
>
|
|
127
127
|
{tokens.map((line, i) => (
|
|
@@ -23,7 +23,7 @@ export default function CodeBlockLine({
|
|
|
23
23
|
line,
|
|
24
24
|
className: clsx(
|
|
25
25
|
classNames,
|
|
26
|
-
showLineNumbers && "openapi-explorer__code-block-code-line"
|
|
26
|
+
showLineNumbers && "openapi-explorer__code-block-code-line",
|
|
27
27
|
),
|
|
28
28
|
});
|
|
29
29
|
const lineTokens = line.map((token, key) => (
|
|
@@ -24,7 +24,7 @@ export default function WordWrapButton({ className, onClick, isEnabled }) {
|
|
|
24
24
|
className={clsx(
|
|
25
25
|
"clean-btn",
|
|
26
26
|
className,
|
|
27
|
-
isEnabled && "openapi-explorer__code-block-word-wrap-btn--enabled"
|
|
27
|
+
isEnabled && "openapi-explorer__code-block-word-wrap-btn--enabled",
|
|
28
28
|
)}
|
|
29
29
|
aria-label={title}
|
|
30
30
|
title={title}
|
|
@@ -56,7 +56,7 @@ function Authorization() {
|
|
|
56
56
|
scheme: a.key,
|
|
57
57
|
key: "token",
|
|
58
58
|
value: value ? value : undefined,
|
|
59
|
-
})
|
|
59
|
+
}),
|
|
60
60
|
);
|
|
61
61
|
}}
|
|
62
62
|
/>
|
|
@@ -77,7 +77,7 @@ function Authorization() {
|
|
|
77
77
|
scheme: a.key,
|
|
78
78
|
key: "token",
|
|
79
79
|
value: value ? value : undefined,
|
|
80
|
-
})
|
|
80
|
+
}),
|
|
81
81
|
);
|
|
82
82
|
}}
|
|
83
83
|
/>
|
|
@@ -99,7 +99,7 @@ function Authorization() {
|
|
|
99
99
|
scheme: a.key,
|
|
100
100
|
key: "username",
|
|
101
101
|
value: value ? value : undefined,
|
|
102
|
-
})
|
|
102
|
+
}),
|
|
103
103
|
);
|
|
104
104
|
}}
|
|
105
105
|
/>
|
|
@@ -116,7 +116,7 @@ function Authorization() {
|
|
|
116
116
|
scheme: a.key,
|
|
117
117
|
key: "password",
|
|
118
118
|
value: value ? value : undefined,
|
|
119
|
-
})
|
|
119
|
+
}),
|
|
120
120
|
);
|
|
121
121
|
}}
|
|
122
122
|
/>
|
|
@@ -138,7 +138,7 @@ function Authorization() {
|
|
|
138
138
|
scheme: a.key,
|
|
139
139
|
key: "apiKey",
|
|
140
140
|
value: value ? value : undefined,
|
|
141
|
-
})
|
|
141
|
+
}),
|
|
142
142
|
);
|
|
143
143
|
}}
|
|
144
144
|
/>
|
|
@@ -130,7 +130,7 @@ export const slice = createSlice({
|
|
|
130
130
|
reducers: {
|
|
131
131
|
setAuthData: (
|
|
132
132
|
state,
|
|
133
|
-
action: PayloadAction<{ scheme: string; key: string; value?: string }
|
|
133
|
+
action: PayloadAction<{ scheme: string; key: string; value?: string }>,
|
|
134
134
|
) => {
|
|
135
135
|
const { scheme, key, value } = action.payload;
|
|
136
136
|
state.data[scheme][key] = value;
|
|
@@ -108,7 +108,7 @@ function Body({
|
|
|
108
108
|
setFileRawBody({
|
|
109
109
|
src: `/path/to/${file.name}`,
|
|
110
110
|
content: file,
|
|
111
|
-
})
|
|
111
|
+
}),
|
|
112
112
|
);
|
|
113
113
|
}}
|
|
114
114
|
/>
|
|
@@ -148,7 +148,7 @@ function Body({
|
|
|
148
148
|
src: `/path/to/${file.name}`,
|
|
149
149
|
content: file,
|
|
150
150
|
},
|
|
151
|
-
})
|
|
151
|
+
}),
|
|
152
152
|
);
|
|
153
153
|
}}
|
|
154
154
|
/>
|
|
@@ -177,7 +177,7 @@ function Body({
|
|
|
177
177
|
setStringFormBody({
|
|
178
178
|
key: key,
|
|
179
179
|
value: val,
|
|
180
|
-
})
|
|
180
|
+
}),
|
|
181
181
|
);
|
|
182
182
|
}
|
|
183
183
|
}}
|
|
@@ -204,7 +204,7 @@ function Body({
|
|
|
204
204
|
placeholder={val.description || key}
|
|
205
205
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
206
206
|
dispatch(
|
|
207
|
-
setStringFormBody({ key: key, value: e.target.value })
|
|
207
|
+
setStringFormBody({ key: key, value: e.target.value }),
|
|
208
208
|
);
|
|
209
209
|
}}
|
|
210
210
|
/>
|
|
@@ -78,7 +78,7 @@ export const slice = createSlice({
|
|
|
78
78
|
},
|
|
79
79
|
setStringFormBody: (
|
|
80
80
|
state,
|
|
81
|
-
action: PayloadAction<{ key: string; value: string }
|
|
81
|
+
action: PayloadAction<{ key: string; value: string }>,
|
|
82
82
|
) => {
|
|
83
83
|
if (state?.type !== "form") {
|
|
84
84
|
return {
|
|
@@ -99,7 +99,7 @@ export const slice = createSlice({
|
|
|
99
99
|
},
|
|
100
100
|
setFileFormBody: (
|
|
101
101
|
state,
|
|
102
|
-
action: PayloadAction<{ key: string; value: FileContent["value"] }
|
|
102
|
+
action: PayloadAction<{ key: string; value: FileContent["value"] }>,
|
|
103
103
|
) => {
|
|
104
104
|
if (state?.type !== "form") {
|
|
105
105
|
return {
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
/* ============================================================================
|
|
9
|
+
* Copyright (c) Palo Alto Networks
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
* ========================================================================== */
|
|
14
|
+
|
|
8
15
|
import React, { useState, useEffect } from "react";
|
|
9
16
|
|
|
10
17
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
@@ -12,13 +19,13 @@ import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
|
|
12
19
|
import buildPostmanRequest from "@theme/ApiExplorer/buildPostmanRequest";
|
|
13
20
|
import CodeTabs from "@theme/ApiExplorer/CodeTabs";
|
|
14
21
|
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
15
|
-
import merge from "lodash/merge";
|
|
16
22
|
import codegen from "postman-code-generators";
|
|
17
23
|
import sdk from "postman-collection";
|
|
18
24
|
|
|
19
25
|
import { CodeSample, Language } from "./code-snippets-types";
|
|
20
26
|
import {
|
|
21
27
|
getCodeSampleSourceFromLanguage,
|
|
28
|
+
mergeArraysbyLanguage,
|
|
22
29
|
mergeCodeSampleLanguage,
|
|
23
30
|
} from "./languages";
|
|
24
31
|
|
|
@@ -149,8 +156,6 @@ function CodeTab({ children, hidden, className }: any): JSX.Element {
|
|
|
149
156
|
}
|
|
150
157
|
|
|
151
158
|
function CodeSnippets({ postman, codeSamples }: Props) {
|
|
152
|
-
// TODO: match theme for vscode.
|
|
153
|
-
|
|
154
159
|
const { siteConfig } = useDocusaurusContext();
|
|
155
160
|
|
|
156
161
|
const contentType = useTypedSelector((state: any) => state.contentType.value);
|
|
@@ -167,28 +172,29 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
167
172
|
|
|
168
173
|
// User-defined languages array
|
|
169
174
|
// Can override languageSet, change order of langs, override options and variants
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
];
|
|
175
|
+
const userDefinedLanguageSet = siteConfig?.themeConfig?.languageTabs as
|
|
176
|
+
| Language[]
|
|
177
|
+
| undefined;
|
|
174
178
|
|
|
175
179
|
// Filter languageSet by user-defined langs
|
|
176
180
|
const filteredLanguageSet = languageSet.filter((ls) => {
|
|
177
|
-
return
|
|
181
|
+
return userDefinedLanguageSet?.some((lang) => {
|
|
178
182
|
return lang.language === ls.language;
|
|
179
183
|
});
|
|
180
184
|
});
|
|
181
185
|
|
|
182
186
|
// Merge user-defined langs into languageSet
|
|
183
187
|
const mergedLangs = mergeCodeSampleLanguage(
|
|
184
|
-
|
|
185
|
-
codeSamples
|
|
188
|
+
mergeArraysbyLanguage(userDefinedLanguageSet, filteredLanguageSet),
|
|
189
|
+
codeSamples,
|
|
186
190
|
);
|
|
187
191
|
|
|
192
|
+
console.log("merged", mergedLangs);
|
|
193
|
+
|
|
188
194
|
// Read defaultLang from localStorage
|
|
189
195
|
const defaultLang: Language[] = mergedLangs.filter(
|
|
190
196
|
(lang) =>
|
|
191
|
-
lang.language === localStorage.getItem("docusaurus.tab.code-samples")
|
|
197
|
+
lang.language === localStorage.getItem("docusaurus.tab.code-samples"),
|
|
192
198
|
);
|
|
193
199
|
const [selectedVariant, setSelectedVariant] = useState<string | undefined>();
|
|
194
200
|
const [selectedSample, setSelectedSample] = useState<string | undefined>();
|
|
@@ -232,11 +238,11 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
232
238
|
return;
|
|
233
239
|
}
|
|
234
240
|
setCodeText(snippet);
|
|
235
|
-
}
|
|
241
|
+
},
|
|
236
242
|
);
|
|
237
243
|
} else if (language && !language.options) {
|
|
238
244
|
const langSource = mergedLangs.filter(
|
|
239
|
-
(lang) => lang.language === language.language
|
|
245
|
+
(lang) => lang.language === language.language,
|
|
240
246
|
);
|
|
241
247
|
|
|
242
248
|
// Merges user-defined language with default languageSet
|
|
@@ -265,7 +271,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
265
271
|
return;
|
|
266
272
|
}
|
|
267
273
|
setCodeText(snippet);
|
|
268
|
-
}
|
|
274
|
+
},
|
|
269
275
|
);
|
|
270
276
|
} else {
|
|
271
277
|
setCodeText("");
|
|
@@ -308,7 +314,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
308
314
|
return;
|
|
309
315
|
}
|
|
310
316
|
setCodeText(snippet);
|
|
311
|
-
}
|
|
317
|
+
},
|
|
312
318
|
);
|
|
313
319
|
}
|
|
314
320
|
});
|
|
@@ -323,7 +329,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
323
329
|
selectedSample !== language.sample
|
|
324
330
|
) {
|
|
325
331
|
const sampleIndex = language.samples.findIndex(
|
|
326
|
-
(smp) => smp === selectedSample
|
|
332
|
+
(smp) => smp === selectedSample,
|
|
327
333
|
);
|
|
328
334
|
setCodeSampleCodeText(language.samplesSources[sampleIndex]);
|
|
329
335
|
}
|