docusaurus-theme-openapi-docs 3.0.0-beta.9 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/theme/ApiExplorer/Body/slice.d.ts +8 -8
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +16 -10
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +29 -2
- package/lib/theme/ApiExplorer/Request/index.js +1 -3
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +1 -1
- package/lib/theme/ApiExplorer/Response/index.js +4 -1
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +1 -3
- package/lib/theme/ApiExplorer/index.js +1 -3
- package/lib/theme/ApiExplorer/persistanceMiddleware.js +6 -6
- package/lib/theme/ApiItem/Layout/index.js +19 -6
- package/lib/theme/ApiItem/index.js +6 -4
- package/lib/theme/ApiTabs/_ApiTabs.scss +1 -0
- package/lib/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +1 -0
- package/lib/theme/MimeTabs/_MimeTabs.scss +1 -0
- package/lib/theme/MimeTabs/index.js +2 -2
- package/lib/theme/OperationTabs/_OperationTabs.scss +1 -0
- package/lib/theme/SchemaTabs/_SchemaTabs.scss +1 -0
- package/lib/theme/SchemaTabs/index.js +10 -4
- package/lib/theme/styles.scss +15 -15
- package/package.json +5 -5
- package/src/postman-code-generators.d.ts +1 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +15 -11
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +22 -0
- package/src/theme/ApiExplorer/Request/index.tsx +1 -1
- package/src/theme/ApiExplorer/Request/makeRequest.ts +1 -1
- package/src/theme/ApiExplorer/Response/index.tsx +4 -1
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +1 -1
- package/src/theme/ApiExplorer/index.tsx +1 -1
- package/src/theme/ApiExplorer/persistanceMiddleware.ts +6 -6
- package/src/theme/ApiExplorer/postman-collection.d.ts +1 -1
- package/src/theme/ApiItem/Layout/index.tsx +8 -4
- package/src/theme/ApiItem/index.tsx +6 -5
- package/src/theme/ApiTabs/_ApiTabs.scss +1 -0
- package/src/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +1 -0
- package/src/theme/MimeTabs/_MimeTabs.scss +1 -0
- package/src/theme/MimeTabs/index.tsx +1 -1
- package/src/theme/OperationTabs/_OperationTabs.scss +1 -0
- package/src/theme/SchemaTabs/_SchemaTabs.scss +1 -0
- package/src/theme/SchemaTabs/index.tsx +12 -5
- package/src/theme/styles.scss +15 -15
- package/src/theme-openapi.d.ts +1 -0
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.d.ts +0 -13
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +0 -240
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +0 -46
- package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.tsx +0 -178
- package/src/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +0 -46
|
@@ -26,18 +26,18 @@ export interface EmptyBody {
|
|
|
26
26
|
}
|
|
27
27
|
export type Body = EmptyBody | FormBody | RawBody;
|
|
28
28
|
export type State = Body;
|
|
29
|
-
export declare const slice: import("@reduxjs/toolkit").Slice<
|
|
30
|
-
clearRawBody: (_state: import("immer/dist/internal").WritableDraft<
|
|
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
31
|
type: "empty";
|
|
32
32
|
};
|
|
33
|
-
setStringRawBody: (_state: import("immer/dist/internal").WritableDraft<
|
|
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
34
|
type: "raw";
|
|
35
35
|
content: {
|
|
36
36
|
type: "string";
|
|
37
37
|
value: string;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
-
setFileRawBody: (_state: import("immer/dist/internal").WritableDraft<
|
|
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
41
|
type: "raw";
|
|
42
42
|
content: {
|
|
43
43
|
type: "file";
|
|
@@ -47,12 +47,12 @@ export declare const slice: import("@reduxjs/toolkit").Slice<EmptyBody | FormBod
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
-
clearFormBodyKey: (state: import("immer/dist/internal").WritableDraft<
|
|
51
|
-
setStringFormBody: (state: import("immer/dist/internal").WritableDraft<
|
|
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
52
|
key: string;
|
|
53
53
|
value: string;
|
|
54
54
|
}>) => import("immer/dist/internal").WritableDraft<FormBody>;
|
|
55
|
-
setFileFormBody: (state: import("immer/dist/internal").WritableDraft<
|
|
55
|
+
setFileFormBody: (state: import("immer/dist/internal").WritableDraft<FormBody> | import("immer/dist/internal").WritableDraft<RawBody> | import("immer/dist/internal").WritableDraft<EmptyBody>, action: PayloadAction<{
|
|
56
56
|
key: string;
|
|
57
57
|
value: FileContent["value"];
|
|
58
58
|
}>) => import("immer/dist/internal").WritableDraft<FormBody> | {
|
|
@@ -78,5 +78,5 @@ export declare const clearRawBody: import("@reduxjs/toolkit").ActionCreatorWitho
|
|
|
78
78
|
key: string;
|
|
79
79
|
value: FileContent["value"];
|
|
80
80
|
}, "body/setFileFormBody">;
|
|
81
|
-
declare const _default: import("redux").Reducer<
|
|
81
|
+
declare const _default: import("redux").Reducer<FormBody | RawBody | EmptyBody, import("redux").AnyAction>;
|
|
82
82
|
export default _default;
|
|
@@ -56,13 +56,16 @@ 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")
|
|
62
68
|
);
|
|
63
|
-
const postman_code_generators_1 = __importDefault(
|
|
64
|
-
require("@paloaltonetworks/postman-code-generators")
|
|
65
|
-
);
|
|
66
69
|
const ApiCodeBlock_1 = __importDefault(
|
|
67
70
|
require("@theme/ApiExplorer/ApiCodeBlock")
|
|
68
71
|
);
|
|
@@ -71,7 +74,9 @@ const buildPostmanRequest_1 = __importDefault(
|
|
|
71
74
|
);
|
|
72
75
|
const CodeTabs_1 = __importDefault(require("@theme/ApiExplorer/CodeTabs"));
|
|
73
76
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
74
|
-
const
|
|
77
|
+
const postman_code_generators_1 = __importDefault(
|
|
78
|
+
require("postman-code-generators")
|
|
79
|
+
);
|
|
75
80
|
const languages_1 = require("./languages");
|
|
76
81
|
exports.languageSet = [
|
|
77
82
|
{
|
|
@@ -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,18 +220,20 @@ 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
|
-
|
|
221
|
-
];
|
|
223
|
+
const userDefinedLanguageSet =
|
|
224
|
+
siteConfig?.themeConfig?.languageTabs ?? exports.languageSet;
|
|
222
225
|
// Filter languageSet by user-defined langs
|
|
223
226
|
const filteredLanguageSet = exports.languageSet.filter((ls) => {
|
|
224
|
-
return
|
|
227
|
+
return userDefinedLanguageSet?.some((lang) => {
|
|
225
228
|
return lang.language === ls.language;
|
|
226
229
|
});
|
|
227
230
|
});
|
|
228
231
|
// Merge user-defined langs into languageSet
|
|
229
232
|
const mergedLangs = (0, languages_1.mergeCodeSampleLanguage)(
|
|
230
|
-
(0,
|
|
233
|
+
(0, languages_1.mergeArraysbyLanguage)(
|
|
234
|
+
userDefinedLanguageSet,
|
|
235
|
+
filteredLanguageSet
|
|
236
|
+
),
|
|
231
237
|
codeSamples
|
|
232
238
|
);
|
|
233
239
|
// Read defaultLang from localStorage
|
|
@@ -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 &&
|
|
@@ -58,9 +58,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
58
58
|
// @ts-nocheck
|
|
59
59
|
const react_1 = __importStar(require("react"));
|
|
60
60
|
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
61
|
-
const postman_collection_1 = __importDefault(
|
|
62
|
-
require("@paloaltonetworks/postman-collection")
|
|
63
|
-
);
|
|
64
61
|
const Accept_1 = __importDefault(require("@theme/ApiExplorer/Accept"));
|
|
65
62
|
const Authorization_1 = __importDefault(
|
|
66
63
|
require("@theme/ApiExplorer/Authorization")
|
|
@@ -78,6 +75,7 @@ const ParamOptions_1 = __importDefault(
|
|
|
78
75
|
const slice_1 = require("@theme/ApiExplorer/Response/slice");
|
|
79
76
|
const Server_1 = __importDefault(require("@theme/ApiExplorer/Server"));
|
|
80
77
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
78
|
+
const postman_collection_1 = __importDefault(require("postman-collection"));
|
|
81
79
|
const react_hook_form_1 = require("react-hook-form");
|
|
82
80
|
const makeRequest_1 = __importDefault(require("./makeRequest"));
|
|
83
81
|
function Request({ item }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
2
1
|
import { Body } from "@theme/ApiExplorer/Body/slice";
|
|
2
|
+
import sdk from "postman-collection";
|
|
3
3
|
declare function makeRequest(request: sdk.Request, proxy: string | undefined, _body: Body): Promise<any>;
|
|
4
4
|
export default makeRequest;
|
|
@@ -101,7 +101,10 @@ function Response({ item }) {
|
|
|
101
101
|
"div",
|
|
102
102
|
{
|
|
103
103
|
style: {
|
|
104
|
-
backgroundColor:
|
|
104
|
+
backgroundColor:
|
|
105
|
+
code && prettyResponse !== "Fetching..."
|
|
106
|
+
? prismTheme.plain.backgroundColor
|
|
107
|
+
: "transparent",
|
|
105
108
|
paddingLeft: "1rem",
|
|
106
109
|
paddingTop: "1rem",
|
|
107
110
|
...((prettyResponse === "Fetching..." || !code) && {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
2
1
|
import { AuthState } from "@theme/ApiExplorer/Authorization/slice";
|
|
3
2
|
import { Body } from "@theme/ApiExplorer/Body/slice";
|
|
4
3
|
import { ParameterObject, ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
4
|
+
import sdk from "postman-collection";
|
|
5
5
|
type Param = {
|
|
6
6
|
value?: string | string[];
|
|
7
7
|
} & ParameterObject;
|
|
@@ -11,10 +11,8 @@ var __importDefault =
|
|
|
11
11
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const postman_collection_1 = __importDefault(
|
|
15
|
-
require("@paloaltonetworks/postman-collection")
|
|
16
|
-
);
|
|
17
14
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
15
|
+
const postman_collection_1 = __importDefault(require("postman-collection"));
|
|
18
16
|
function setQueryParams(postman, queryParams) {
|
|
19
17
|
postman.url.query.clear();
|
|
20
18
|
const qp = queryParams
|
|
@@ -12,14 +12,12 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
-
const postman_collection_1 = __importDefault(
|
|
16
|
-
require("@paloaltonetworks/postman-collection")
|
|
17
|
-
);
|
|
18
15
|
const CodeSnippets_1 = __importDefault(
|
|
19
16
|
require("@theme/ApiExplorer/CodeSnippets")
|
|
20
17
|
);
|
|
21
18
|
const Request_1 = __importDefault(require("@theme/ApiExplorer/Request"));
|
|
22
19
|
const Response_1 = __importDefault(require("@theme/ApiExplorer/Response"));
|
|
20
|
+
const postman_collection_1 = __importDefault(require("postman-collection"));
|
|
23
21
|
function ApiExplorer({ item, infoPath }) {
|
|
24
22
|
const postman = new postman_collection_1.default.Request(item.postman);
|
|
25
23
|
return react_1.default.createElement(
|
|
@@ -32,12 +32,12 @@ function createPersistanceMiddleware(options) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
// TODO: determine way to rehydrate without flashing
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
if (action.type === "contentType/setContentType") {
|
|
36
|
+
storage.setItem("contentType", action.payload);
|
|
37
|
+
}
|
|
38
|
+
if (action.type === "accept/setAccept") {
|
|
39
|
+
storage.setItem("accept", action.payload);
|
|
40
|
+
}
|
|
41
41
|
if (action.type === "server/setServer") {
|
|
42
42
|
storage.setItem("server", action.payload);
|
|
43
43
|
}
|
|
@@ -77,16 +77,29 @@ function DocItemLayout({ children }) {
|
|
|
77
77
|
react_1.default.createElement(Content_1.default, null, children),
|
|
78
78
|
react_1.default.createElement(
|
|
79
79
|
"div",
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
{ className: "row" },
|
|
81
|
+
react_1.default.createElement(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
className: (0, clsx_1.default)(
|
|
85
|
+
"col",
|
|
86
|
+
api ? "col--7" : "col--12"
|
|
87
|
+
),
|
|
88
|
+
},
|
|
89
|
+
react_1.default.createElement(Footer_1.default, null)
|
|
90
|
+
)
|
|
84
91
|
)
|
|
85
92
|
),
|
|
86
93
|
react_1.default.createElement(
|
|
87
94
|
"div",
|
|
88
|
-
{ className:
|
|
89
|
-
react_1.default.createElement(
|
|
95
|
+
{ className: "row" },
|
|
96
|
+
react_1.default.createElement(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
className: (0, clsx_1.default)("col", api ? "col--7" : "col--12"),
|
|
100
|
+
},
|
|
101
|
+
react_1.default.createElement(Paginator_1.default, null)
|
|
102
|
+
)
|
|
90
103
|
)
|
|
91
104
|
)
|
|
92
105
|
),
|
|
@@ -44,9 +44,11 @@ function ApiItem(props) {
|
|
|
44
44
|
const { schema } = frontMatter;
|
|
45
45
|
// decompress and parse
|
|
46
46
|
if (api) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
try {
|
|
48
|
+
api = JSON.parse(
|
|
49
|
+
zlib_1.default.inflateSync(Buffer.from(api, "base64")).toString()
|
|
50
|
+
);
|
|
51
|
+
} catch {}
|
|
50
52
|
}
|
|
51
53
|
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
52
54
|
const themeConfig = siteConfig.themeConfig;
|
|
@@ -205,7 +207,7 @@ function ApiItem(props) {
|
|
|
205
207
|
{ className: "row" },
|
|
206
208
|
react_1.default.createElement(
|
|
207
209
|
"div",
|
|
208
|
-
{ className: "col col--12" },
|
|
210
|
+
{ className: "col col--12 markdown" },
|
|
209
211
|
react_1.default.createElement(MDXComponent, null)
|
|
210
212
|
)
|
|
211
213
|
)
|
|
@@ -58,7 +58,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
58
58
|
const react_1 = __importStar(require("react"));
|
|
59
59
|
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
60
60
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
61
|
-
const slice_1 =
|
|
61
|
+
const slice_1 = require("@theme/ApiExplorer/Accept/slice");
|
|
62
62
|
const slice_2 = require("@theme/ApiExplorer/ContentType/slice");
|
|
63
63
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
64
64
|
const clsx_1 = __importDefault(require("clsx"));
|
|
@@ -105,7 +105,7 @@ function TabList({
|
|
|
105
105
|
if (isRequestSchema) {
|
|
106
106
|
dispatch((0, slice_2.setContentType)(newTabValue));
|
|
107
107
|
} else {
|
|
108
|
-
dispatch((0, slice_1.
|
|
108
|
+
dispatch((0, slice_1.setAccept)(newTabValue));
|
|
109
109
|
}
|
|
110
110
|
blockElementScrollPositionUntilNextRender(newTab);
|
|
111
111
|
selectValue(newTabValue);
|
|
@@ -114,11 +114,17 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
114
114
|
resizeObserver.disconnect();
|
|
115
115
|
};
|
|
116
116
|
}, []);
|
|
117
|
-
const handleRightClick = () => {
|
|
118
|
-
|
|
117
|
+
const handleRightClick = (e) => {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
if (tabItemListContainerRef.current) {
|
|
120
|
+
tabItemListContainerRef.current.scrollLeft += 90;
|
|
121
|
+
}
|
|
119
122
|
};
|
|
120
|
-
const handleLeftClick = () => {
|
|
121
|
-
|
|
123
|
+
const handleLeftClick = (e) => {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
if (tabItemListContainerRef.current) {
|
|
126
|
+
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
127
|
+
}
|
|
122
128
|
};
|
|
123
129
|
return react_1.default.createElement(
|
|
124
130
|
"div",
|
package/lib/theme/styles.scss
CHANGED
|
@@ -130,22 +130,22 @@
|
|
|
130
130
|
|
|
131
131
|
/* Version button */
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
.version-button div {
|
|
134
|
+
display: block;
|
|
135
|
+
}
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
.version-button div > button > span::after {
|
|
138
|
+
border-color: currentcolor transparent;
|
|
139
|
+
border-style: solid;
|
|
140
|
+
border-width: 0.4em 0.4em 0;
|
|
141
|
+
content: "";
|
|
142
|
+
margin-left: 0.3em;
|
|
143
|
+
position: relative;
|
|
144
|
+
transform: translateY(-50%);
|
|
145
|
+
display: inline-block;
|
|
146
|
+
font-size: 0.8rem;
|
|
147
|
+
top: 1px;
|
|
148
|
+
}
|
|
149
149
|
|
|
150
150
|
.openapi__logo {
|
|
151
151
|
width: 250px;
|
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": "3.0.
|
|
4
|
+
"version": "3.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@docusaurus/theme-common": "^3.0.1",
|
|
40
40
|
"@hookform/error-message": "^2.0.1",
|
|
41
|
-
"@paloaltonetworks/postman-code-generators": "1.1.15-patch.2",
|
|
42
|
-
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
43
41
|
"@reduxjs/toolkit": "^1.7.1",
|
|
44
42
|
"clsx": "^1.1.1",
|
|
45
43
|
"copy-text-to-clipboard": "^3.1.0",
|
|
46
44
|
"crypto-js": "^4.1.1",
|
|
47
|
-
"docusaurus-plugin-openapi-docs": "^3.0.
|
|
45
|
+
"docusaurus-plugin-openapi-docs": "^3.0.1",
|
|
48
46
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
49
47
|
"file-saver": "^2.0.5",
|
|
50
48
|
"lodash": "^4.17.20",
|
|
51
49
|
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
50
|
+
"postman-code-generators": "^1.10.1",
|
|
51
|
+
"postman-collection": "^4.4.0",
|
|
52
52
|
"prism-react-renderer": "^2.3.0",
|
|
53
53
|
"react-hook-form": "^7.43.8",
|
|
54
54
|
"react-live": "^4.0.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=14"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "5f6e43a2b1fcc1c266941879cb73365eb3d68e5a"
|
|
73
73
|
}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
8
|
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
-
declare module "
|
|
9
|
+
declare module "postman-code-generators";
|
|
@@ -5,20 +5,27 @@
|
|
|
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";
|
|
11
|
-
import codegen from "@paloaltonetworks/postman-code-generators";
|
|
12
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
13
18
|
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
|
14
19
|
import buildPostmanRequest from "@theme/ApiExplorer/buildPostmanRequest";
|
|
15
20
|
import CodeTabs from "@theme/ApiExplorer/CodeTabs";
|
|
16
21
|
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
17
|
-
import
|
|
22
|
+
import codegen from "postman-code-generators";
|
|
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,21 +172,20 @@ 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 =
|
|
176
|
+
(siteConfig?.themeConfig?.languageTabs as Language[] | undefined) ??
|
|
177
|
+
languageSet;
|
|
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
|
-
|
|
188
|
+
mergeArraysbyLanguage(userDefinedLanguageSet, filteredLanguageSet),
|
|
185
189
|
codeSamples
|
|
186
190
|
);
|
|
187
191
|
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import find from "lodash/find";
|
|
9
|
+
import isArray from "lodash/isArray";
|
|
10
|
+
import mergeWith from "lodash/mergeWith";
|
|
11
|
+
import unionBy from "lodash/unionBy";
|
|
12
|
+
|
|
8
13
|
import { CodeSample, Language } from "./code-snippets-types";
|
|
9
14
|
|
|
10
15
|
export function mergeCodeSampleLanguage(
|
|
@@ -36,6 +41,23 @@ export function mergeCodeSampleLanguage(
|
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
export const mergeArraysbyLanguage = (arr1: any, arr2: any) => {
|
|
45
|
+
const mergedArray = unionBy(arr1, arr2, "language");
|
|
46
|
+
|
|
47
|
+
return mergedArray.map((item: any) => {
|
|
48
|
+
const matchingItems = [
|
|
49
|
+
find(arr1, ["language", item["language"]]),
|
|
50
|
+
find(arr2, ["language", item["language"]]),
|
|
51
|
+
];
|
|
52
|
+
return mergeWith({}, ...matchingItems, (objValue: any) => {
|
|
53
|
+
if (isArray(objValue)) {
|
|
54
|
+
return objValue;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
39
61
|
export function getCodeSampleSourceFromLanguage(language: Language) {
|
|
40
62
|
if (
|
|
41
63
|
language &&
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import React, { useState } from "react";
|
|
10
10
|
|
|
11
11
|
import { useDoc } from "@docusaurus/theme-common/internal";
|
|
12
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
13
12
|
import Accept from "@theme/ApiExplorer/Accept";
|
|
14
13
|
import Authorization from "@theme/ApiExplorer/Authorization";
|
|
15
14
|
import Body from "@theme/ApiExplorer/Body";
|
|
@@ -27,6 +26,7 @@ import Server from "@theme/ApiExplorer/Server";
|
|
|
27
26
|
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
28
27
|
import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
29
28
|
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
29
|
+
import sdk from "postman-collection";
|
|
30
30
|
import { FormProvider, useForm } from "react-hook-form";
|
|
31
31
|
|
|
32
32
|
import makeRequest from "./makeRequest";
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
9
8
|
import { Body } from "@theme/ApiExplorer/Body/slice";
|
|
9
|
+
import sdk from "postman-collection";
|
|
10
10
|
|
|
11
11
|
function fetchWithtimeout(
|
|
12
12
|
url: string,
|
|
@@ -88,7 +88,10 @@ function Response({ item }: { item: NonNullable<ApiItem> }) {
|
|
|
88
88
|
</div>
|
|
89
89
|
<div
|
|
90
90
|
style={{
|
|
91
|
-
backgroundColor:
|
|
91
|
+
backgroundColor:
|
|
92
|
+
code && prettyResponse !== "Fetching..."
|
|
93
|
+
? prismTheme.plain.backgroundColor
|
|
94
|
+
: "transparent",
|
|
92
95
|
paddingLeft: "1rem",
|
|
93
96
|
paddingTop: "1rem",
|
|
94
97
|
...((prettyResponse === "Fetching..." || !code) && {
|