docusaurus-theme-openapi-docs 0.0.0-960 → 0.0.0-962
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.
|
@@ -56,12 +56,6 @@ 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
|
-
* ========================================================================== */
|
|
65
59
|
const react_1 = __importStar(require("react"));
|
|
66
60
|
const useDocusaurusContext_1 = __importDefault(
|
|
67
61
|
require("@docusaurus/useDocusaurusContext")
|
|
@@ -74,6 +68,7 @@ const buildPostmanRequest_1 = __importDefault(
|
|
|
74
68
|
);
|
|
75
69
|
const CodeTabs_1 = __importDefault(require("@theme/ApiExplorer/CodeTabs"));
|
|
76
70
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
71
|
+
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
77
72
|
const postman_code_generators_1 = __importDefault(
|
|
78
73
|
require("postman-code-generators")
|
|
79
74
|
);
|
|
@@ -107,6 +102,37 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
107
102
|
(state) => state.params.header
|
|
108
103
|
);
|
|
109
104
|
const auth = (0, hooks_1.useTypedSelector)((state) => state.auth);
|
|
105
|
+
const clonedAuth = (0, cloneDeep_1.default)(auth);
|
|
106
|
+
let placeholder;
|
|
107
|
+
function cleanCredentials(obj) {
|
|
108
|
+
for (const key in obj) {
|
|
109
|
+
if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
110
|
+
// use name as placeholder if exists
|
|
111
|
+
placeholder = clonedAuth?.options?.[key]?.[0]?.name;
|
|
112
|
+
obj[key] = cleanCredentials(obj[key]);
|
|
113
|
+
} else {
|
|
114
|
+
obj[key] = `<${placeholder ?? key}>`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return obj;
|
|
118
|
+
}
|
|
119
|
+
// scrub credentials from code snippets
|
|
120
|
+
const cleanedAuth = {
|
|
121
|
+
...clonedAuth,
|
|
122
|
+
data: cleanCredentials(clonedAuth.data),
|
|
123
|
+
};
|
|
124
|
+
// Create a Postman request object using cleanedAuth
|
|
125
|
+
const cleanedPostmanRequest = (0, buildPostmanRequest_1.default)(postman, {
|
|
126
|
+
queryParams,
|
|
127
|
+
pathParams,
|
|
128
|
+
cookieParams,
|
|
129
|
+
contentType,
|
|
130
|
+
accept,
|
|
131
|
+
headerParams,
|
|
132
|
+
body,
|
|
133
|
+
server,
|
|
134
|
+
auth: cleanedAuth,
|
|
135
|
+
});
|
|
110
136
|
// User-defined languages array
|
|
111
137
|
// Can override languageSet, change order of langs, override options and variants
|
|
112
138
|
const userDefinedLanguageSet =
|
|
@@ -151,21 +177,10 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
151
177
|
);
|
|
152
178
|
}
|
|
153
179
|
if (language && !!language.options) {
|
|
154
|
-
const postmanRequest = (0, buildPostmanRequest_1.default)(postman, {
|
|
155
|
-
queryParams,
|
|
156
|
-
pathParams,
|
|
157
|
-
cookieParams,
|
|
158
|
-
contentType,
|
|
159
|
-
accept,
|
|
160
|
-
headerParams,
|
|
161
|
-
body,
|
|
162
|
-
server,
|
|
163
|
-
auth,
|
|
164
|
-
});
|
|
165
180
|
postman_code_generators_1.default.convert(
|
|
166
181
|
language.language,
|
|
167
182
|
language.variant,
|
|
168
|
-
|
|
183
|
+
cleanedPostmanRequest,
|
|
169
184
|
language.options,
|
|
170
185
|
(error, snippet) => {
|
|
171
186
|
if (error) {
|
|
@@ -182,21 +197,10 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
182
197
|
// This allows users to define only the minimal properties necessary in languageTabs
|
|
183
198
|
// User-defined properties should override languageSet properties
|
|
184
199
|
const mergedLanguage = { ...langSource[0], ...language };
|
|
185
|
-
const postmanRequest = (0, buildPostmanRequest_1.default)(postman, {
|
|
186
|
-
queryParams,
|
|
187
|
-
pathParams,
|
|
188
|
-
cookieParams,
|
|
189
|
-
contentType,
|
|
190
|
-
accept,
|
|
191
|
-
headerParams,
|
|
192
|
-
body,
|
|
193
|
-
server,
|
|
194
|
-
auth,
|
|
195
|
-
});
|
|
196
200
|
postman_code_generators_1.default.convert(
|
|
197
201
|
mergedLanguage.language,
|
|
198
202
|
mergedLanguage.variant,
|
|
199
|
-
|
|
203
|
+
cleanedPostmanRequest,
|
|
200
204
|
mergedLanguage.options,
|
|
201
205
|
(error, snippet) => {
|
|
202
206
|
if (error) {
|
|
@@ -219,27 +223,16 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
219
223
|
postman,
|
|
220
224
|
queryParams,
|
|
221
225
|
server,
|
|
222
|
-
|
|
226
|
+
cleanedPostmanRequest,
|
|
223
227
|
mergedLangs,
|
|
224
228
|
]);
|
|
225
|
-
// no dependencies was
|
|
229
|
+
// no dependencies was intentionally set for this particular hook. it's safe as long as if conditions are set
|
|
226
230
|
(0, react_1.useEffect)(function onSelectedVariantUpdate() {
|
|
227
231
|
if (selectedVariant && selectedVariant !== language?.variant) {
|
|
228
|
-
const postmanRequest = (0, buildPostmanRequest_1.default)(postman, {
|
|
229
|
-
queryParams,
|
|
230
|
-
pathParams,
|
|
231
|
-
cookieParams,
|
|
232
|
-
contentType,
|
|
233
|
-
accept,
|
|
234
|
-
headerParams,
|
|
235
|
-
body,
|
|
236
|
-
server,
|
|
237
|
-
auth,
|
|
238
|
-
});
|
|
239
232
|
postman_code_generators_1.default.convert(
|
|
240
233
|
language.language,
|
|
241
234
|
selectedVariant,
|
|
242
|
-
|
|
235
|
+
cleanedPostmanRequest,
|
|
243
236
|
language.options,
|
|
244
237
|
(error, snippet) => {
|
|
245
238
|
if (error) {
|
|
@@ -250,7 +243,7 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
250
243
|
);
|
|
251
244
|
}
|
|
252
245
|
});
|
|
253
|
-
// no dependencies was
|
|
246
|
+
// no dependencies was intentionally set for this particular hook. it's safe as long as if conditions are set
|
|
254
247
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
255
248
|
(0, react_1.useEffect)(function onSelectedSampleUpdate() {
|
|
256
249
|
if (
|
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-962",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@types/file-saver": "^2.0.5",
|
|
35
35
|
"@types/lodash": "^4.14.176",
|
|
36
36
|
"concurrently": "^5.2.0",
|
|
37
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
37
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-962",
|
|
38
38
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
39
39
|
"eslint-plugin-prettier": "^5.0.1"
|
|
40
40
|
},
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=14"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "bc481c3e684c6a00f2c361436c0de9ac8a28c9e4"
|
|
79
79
|
}
|
|
@@ -5,13 +5,6 @@
|
|
|
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
|
-
|
|
15
8
|
import React, { useState, useEffect } from "react";
|
|
16
9
|
|
|
17
10
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
@@ -19,6 +12,7 @@ import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
|
|
19
12
|
import buildPostmanRequest from "@theme/ApiExplorer/buildPostmanRequest";
|
|
20
13
|
import CodeTabs from "@theme/ApiExplorer/CodeTabs";
|
|
21
14
|
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
15
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
22
16
|
import codegen from "postman-code-generators";
|
|
23
17
|
import sdk from "postman-collection";
|
|
24
18
|
|
|
@@ -59,6 +53,41 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
59
53
|
const headerParams = useTypedSelector((state: any) => state.params.header);
|
|
60
54
|
|
|
61
55
|
const auth = useTypedSelector((state: any) => state.auth);
|
|
56
|
+
const clonedAuth = cloneDeep(auth);
|
|
57
|
+
let placeholder: string;
|
|
58
|
+
|
|
59
|
+
function cleanCredentials(obj: any) {
|
|
60
|
+
for (const key in obj) {
|
|
61
|
+
if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
62
|
+
// use name as placeholder if exists
|
|
63
|
+
placeholder = clonedAuth?.options?.[key]?.[0]?.name;
|
|
64
|
+
obj[key] = cleanCredentials(obj[key]);
|
|
65
|
+
} else {
|
|
66
|
+
obj[key] = `<${placeholder ?? key}>`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return obj;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// scrub credentials from code snippets
|
|
74
|
+
const cleanedAuth = {
|
|
75
|
+
...clonedAuth,
|
|
76
|
+
data: cleanCredentials(clonedAuth.data),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Create a Postman request object using cleanedAuth
|
|
80
|
+
const cleanedPostmanRequest = buildPostmanRequest(postman, {
|
|
81
|
+
queryParams,
|
|
82
|
+
pathParams,
|
|
83
|
+
cookieParams,
|
|
84
|
+
contentType,
|
|
85
|
+
accept,
|
|
86
|
+
headerParams,
|
|
87
|
+
body,
|
|
88
|
+
server,
|
|
89
|
+
auth: cleanedAuth,
|
|
90
|
+
});
|
|
62
91
|
|
|
63
92
|
// User-defined languages array
|
|
64
93
|
// Can override languageSet, change order of langs, override options and variants
|
|
@@ -105,21 +134,10 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
105
134
|
}
|
|
106
135
|
|
|
107
136
|
if (language && !!language.options) {
|
|
108
|
-
const postmanRequest = buildPostmanRequest(postman, {
|
|
109
|
-
queryParams,
|
|
110
|
-
pathParams,
|
|
111
|
-
cookieParams,
|
|
112
|
-
contentType,
|
|
113
|
-
accept,
|
|
114
|
-
headerParams,
|
|
115
|
-
body,
|
|
116
|
-
server,
|
|
117
|
-
auth,
|
|
118
|
-
});
|
|
119
137
|
codegen.convert(
|
|
120
138
|
language.language,
|
|
121
139
|
language.variant,
|
|
122
|
-
|
|
140
|
+
cleanedPostmanRequest,
|
|
123
141
|
language.options,
|
|
124
142
|
(error: any, snippet: string) => {
|
|
125
143
|
if (error) {
|
|
@@ -137,22 +155,10 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
137
155
|
// This allows users to define only the minimal properties necessary in languageTabs
|
|
138
156
|
// User-defined properties should override languageSet properties
|
|
139
157
|
const mergedLanguage = { ...langSource[0], ...language };
|
|
140
|
-
const postmanRequest = buildPostmanRequest(postman, {
|
|
141
|
-
queryParams,
|
|
142
|
-
pathParams,
|
|
143
|
-
cookieParams,
|
|
144
|
-
contentType,
|
|
145
|
-
accept,
|
|
146
|
-
headerParams,
|
|
147
|
-
body,
|
|
148
|
-
server,
|
|
149
|
-
auth,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
158
|
codegen.convert(
|
|
153
159
|
mergedLanguage.language,
|
|
154
160
|
mergedLanguage.variant,
|
|
155
|
-
|
|
161
|
+
cleanedPostmanRequest,
|
|
156
162
|
mergedLanguage.options,
|
|
157
163
|
(error: any, snippet: string) => {
|
|
158
164
|
if (error) {
|
|
@@ -175,27 +181,16 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
175
181
|
postman,
|
|
176
182
|
queryParams,
|
|
177
183
|
server,
|
|
178
|
-
|
|
184
|
+
cleanedPostmanRequest,
|
|
179
185
|
mergedLangs,
|
|
180
186
|
]);
|
|
181
|
-
// no dependencies was
|
|
187
|
+
// no dependencies was intentionally set for this particular hook. it's safe as long as if conditions are set
|
|
182
188
|
useEffect(function onSelectedVariantUpdate() {
|
|
183
189
|
if (selectedVariant && selectedVariant !== language?.variant) {
|
|
184
|
-
const postmanRequest = buildPostmanRequest(postman, {
|
|
185
|
-
queryParams,
|
|
186
|
-
pathParams,
|
|
187
|
-
cookieParams,
|
|
188
|
-
contentType,
|
|
189
|
-
accept,
|
|
190
|
-
headerParams,
|
|
191
|
-
body,
|
|
192
|
-
server,
|
|
193
|
-
auth,
|
|
194
|
-
});
|
|
195
190
|
codegen.convert(
|
|
196
191
|
language.language,
|
|
197
192
|
selectedVariant,
|
|
198
|
-
|
|
193
|
+
cleanedPostmanRequest,
|
|
199
194
|
language.options,
|
|
200
195
|
(error: any, snippet: string) => {
|
|
201
196
|
if (error) {
|
|
@@ -207,7 +202,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
207
202
|
}
|
|
208
203
|
});
|
|
209
204
|
|
|
210
|
-
// no dependencies was
|
|
205
|
+
// no dependencies was intentionally set for this particular hook. it's safe as long as if conditions are set
|
|
211
206
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
212
207
|
useEffect(function onSelectedSampleUpdate() {
|
|
213
208
|
if (
|