docusaurus-theme-openapi-docs 1.1.9 → 1.1.10
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/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
- package/lib/theme/ApiDemoPanel/Curl/index.js +80 -22
- package/lib/theme/ApiDemoPanel/Curl/languages.json +1386 -0
- package/lib/theme/ApiItem/Layout/styles.module.css +118 -20
- package/lib-next/theme/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +85 -17
- package/lib-next/theme/ApiDemoPanel/Curl/languages.json +1386 -0
- package/lib-next/theme/ApiItem/Layout/styles.module.css +118 -20
- package/package.json +3 -3
- package/src/theme/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
- package/src/theme/ApiDemoPanel/Curl/index.tsx +89 -22
- package/src/theme/ApiDemoPanel/Curl/languages.json +1386 -0
- package/src/theme/ApiItem/Layout/styles.module.css +118 -20
- package/lib/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
- package/lib/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
- package/lib/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
- package/lib/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
- package/lib/theme/ApiItem/Layout/icons/python-original.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/python-original.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/python-original.svg +0 -1
|
@@ -161,18 +161,20 @@
|
|
|
161
161
|
padding-left: 2px;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
/* CodeTabs */
|
|
165
|
+
|
|
164
166
|
:global(.code__tab--python::after) {
|
|
165
167
|
content: "";
|
|
166
|
-
width:
|
|
167
|
-
height:
|
|
168
|
-
background: url(
|
|
168
|
+
width: 28px;
|
|
169
|
+
height: 28px;
|
|
170
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/python/python-original.svg");
|
|
169
171
|
margin-block: auto;
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
:global(.code__tab--python) {
|
|
173
175
|
color: var(--ifm-color-success);
|
|
174
|
-
padding-left:
|
|
175
|
-
padding-right:
|
|
176
|
+
padding-left: 1.4rem;
|
|
177
|
+
padding-right: 1.4rem;
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
:global(.code__tab--python.tabs__item--active) {
|
|
@@ -187,16 +189,16 @@
|
|
|
187
189
|
|
|
188
190
|
:global(.code__tab--go::after) {
|
|
189
191
|
content: "";
|
|
190
|
-
width:
|
|
191
|
-
height:
|
|
192
|
-
background: url(
|
|
192
|
+
width: 28px;
|
|
193
|
+
height: 28px;
|
|
194
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/go/go-original-wordmark.svg");
|
|
193
195
|
margin-block: auto;
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
:global(.code__tab--go) {
|
|
197
199
|
color: var(--ifm-color-info);
|
|
198
|
-
padding-left:
|
|
199
|
-
padding-right:
|
|
200
|
+
padding-left: 1.4rem;
|
|
201
|
+
padding-right: 1.4rem;
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
:global(.code__tab--go.tabs__item--active) {
|
|
@@ -211,16 +213,16 @@
|
|
|
211
213
|
|
|
212
214
|
:global(.code__tab--javascript::after) {
|
|
213
215
|
content: "";
|
|
214
|
-
width:
|
|
215
|
-
height:
|
|
216
|
-
background: url(
|
|
216
|
+
width: 28px;
|
|
217
|
+
height: 28px;
|
|
218
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/javascript/javascript-original.svg");
|
|
217
219
|
margin-block: auto;
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
:global(.code__tab--javascript) {
|
|
221
223
|
color: var(--ifm-color-warning);
|
|
222
|
-
padding-left:
|
|
223
|
-
padding-right:
|
|
224
|
+
padding-left: 1.4rem;
|
|
225
|
+
padding-right: 1.4rem;
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
:global(.code__tab--javascript.tabs__item--active) {
|
|
@@ -235,16 +237,16 @@
|
|
|
235
237
|
|
|
236
238
|
:global(.code__tab--bash::after) {
|
|
237
239
|
content: "";
|
|
238
|
-
width:
|
|
239
|
-
height:
|
|
240
|
-
background: url(
|
|
240
|
+
width: 28px;
|
|
241
|
+
height: 28px;
|
|
242
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/linux/linux-original.svg");
|
|
241
243
|
margin-block: auto;
|
|
242
244
|
}
|
|
243
245
|
|
|
244
246
|
:global(.code__tab--bash) {
|
|
245
247
|
color: var(--ifm-color-danger);
|
|
246
|
-
padding-left:
|
|
247
|
-
padding-right:
|
|
248
|
+
padding-left: 1.4rem;
|
|
249
|
+
padding-right: 1.4rem;
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
:global(.code__tab--bash.tabs__item--active) {
|
|
@@ -256,3 +258,99 @@
|
|
|
256
258
|
max-height: 500px;
|
|
257
259
|
overflow: auto;
|
|
258
260
|
}
|
|
261
|
+
|
|
262
|
+
:global(.code__tab--ruby::after) {
|
|
263
|
+
content: "";
|
|
264
|
+
width: 28px;
|
|
265
|
+
height: 28px;
|
|
266
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/ruby/ruby-plain.svg");
|
|
267
|
+
margin-block: auto;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
:global(.code__tab--ruby) {
|
|
271
|
+
color: var(--ifm-color-danger);
|
|
272
|
+
padding-left: 1.4rem;
|
|
273
|
+
padding-right: 1.4rem;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
:global(.code__tab--ruby.tabs__item--active) {
|
|
277
|
+
border-bottom-color: var(--ifm-color-danger);
|
|
278
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
:global(.language-ruby) {
|
|
282
|
+
max-height: 500px;
|
|
283
|
+
overflow: auto;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
:global(.code__tab--csharp::after) {
|
|
287
|
+
content: "";
|
|
288
|
+
width: 28px;
|
|
289
|
+
height: 28px;
|
|
290
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/csharp/csharp-original.svg");
|
|
291
|
+
margin-block: auto;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
:global(.code__tab--csharp) {
|
|
295
|
+
color: var(--ifm-color-gray-500);
|
|
296
|
+
padding-left: 1.4rem;
|
|
297
|
+
padding-right: 1.4rem;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
:global(.code__tab--csharp.tabs__item--active) {
|
|
301
|
+
border-bottom-color: var(--ifm-color-gray-500);
|
|
302
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
:global(.language-csharp) {
|
|
306
|
+
max-height: 500px;
|
|
307
|
+
overflow: auto;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
:global(.code__tab--nodejs::after) {
|
|
311
|
+
content: "";
|
|
312
|
+
width: 28px;
|
|
313
|
+
height: 28px;
|
|
314
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/nodejs/nodejs-original.svg");
|
|
315
|
+
margin-block: auto;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
:global(.code__tab--nodejs) {
|
|
319
|
+
color: var(--ifm-color-success);
|
|
320
|
+
padding-left: 1.4rem;
|
|
321
|
+
padding-right: 1.4rem;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
:global(.code__tab--nodejs.tabs__item--active) {
|
|
325
|
+
border-bottom-color: var(--ifm-color-success);
|
|
326
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
:global(.language-nodejs) {
|
|
330
|
+
max-height: 500px;
|
|
331
|
+
overflow: auto;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
:global(.code__tab--php::after) {
|
|
335
|
+
content: "";
|
|
336
|
+
width: 28px;
|
|
337
|
+
height: 28px;
|
|
338
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/php/php-original.svg");
|
|
339
|
+
margin-block: auto;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
:global(.code__tab--php) {
|
|
343
|
+
color: var(--ifm-color-gray-500);
|
|
344
|
+
padding-left: 1.4rem;
|
|
345
|
+
padding-right: 1.4rem;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
:global(.code__tab--php.tabs__item--active) {
|
|
349
|
+
border-bottom-color: var(--ifm-color-gray-500);
|
|
350
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
:global(.language-php) {
|
|
354
|
+
max-height: 500px;
|
|
355
|
+
overflow: auto;
|
|
356
|
+
}
|
|
@@ -15,50 +15,76 @@ import buildPostmanRequest from "./../buildPostmanRequest";
|
|
|
15
15
|
import styles from "./styles.module.css";
|
|
16
16
|
export const languageSet = [
|
|
17
17
|
{
|
|
18
|
-
tabName: "cURL",
|
|
19
18
|
highlight: "bash",
|
|
20
19
|
language: "curl",
|
|
21
|
-
|
|
22
|
-
variant: "curl",
|
|
20
|
+
logoClass: "bash",
|
|
23
21
|
options: {
|
|
24
22
|
longFormat: false,
|
|
25
23
|
followRedirect: true,
|
|
26
24
|
trimRequestBody: true,
|
|
27
25
|
},
|
|
26
|
+
variant: "cURL",
|
|
28
27
|
},
|
|
29
28
|
{
|
|
30
|
-
tabName: "Python",
|
|
31
29
|
highlight: "python",
|
|
32
30
|
language: "python",
|
|
33
|
-
|
|
34
|
-
variant: "requests",
|
|
31
|
+
logoClass: "python",
|
|
35
32
|
options: {
|
|
36
33
|
followRedirect: true,
|
|
37
34
|
trimRequestBody: true,
|
|
38
35
|
},
|
|
36
|
+
variant: "requests",
|
|
39
37
|
},
|
|
40
38
|
{
|
|
41
|
-
tabName: "Go",
|
|
42
39
|
highlight: "go",
|
|
43
40
|
language: "go",
|
|
44
|
-
|
|
45
|
-
variant: "native",
|
|
41
|
+
logoClass: "go",
|
|
46
42
|
options: {
|
|
47
43
|
followRedirect: true,
|
|
48
44
|
trimRequestBody: true,
|
|
49
45
|
},
|
|
46
|
+
variant: "native",
|
|
50
47
|
},
|
|
51
48
|
{
|
|
52
|
-
tabName: "Node",
|
|
53
49
|
highlight: "javascript",
|
|
54
50
|
language: "nodejs",
|
|
55
|
-
|
|
56
|
-
variant: "axios",
|
|
51
|
+
logoClass: "nodejs",
|
|
57
52
|
options: {
|
|
58
53
|
ES6_enabled: true,
|
|
59
54
|
followRedirect: true,
|
|
60
55
|
trimRequestBody: true,
|
|
61
56
|
},
|
|
57
|
+
variant: "axios",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
highlight: "ruby",
|
|
61
|
+
language: "ruby",
|
|
62
|
+
logoClass: "ruby",
|
|
63
|
+
options: {
|
|
64
|
+
followRedirect: true,
|
|
65
|
+
trimRequestBody: true,
|
|
66
|
+
},
|
|
67
|
+
variant: "Net::HTTP",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
highlight: "csharp",
|
|
71
|
+
language: "csharp",
|
|
72
|
+
logoClass: "csharp",
|
|
73
|
+
options: {
|
|
74
|
+
followRedirect: true,
|
|
75
|
+
trimRequestBody: true,
|
|
76
|
+
},
|
|
77
|
+
variant: "RestSharp",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
highlight: "php",
|
|
81
|
+
language: "php",
|
|
82
|
+
logoClass: "php",
|
|
83
|
+
options: {
|
|
84
|
+
followRedirect: true,
|
|
85
|
+
trimRequestBody: true,
|
|
86
|
+
},
|
|
87
|
+
variant: "cURL",
|
|
62
88
|
},
|
|
63
89
|
];
|
|
64
90
|
|
|
@@ -95,9 +121,15 @@ function Curl({ postman, codeSamples }) {
|
|
|
95
121
|
];
|
|
96
122
|
const defaultLang = languageSet.filter(
|
|
97
123
|
(lang) =>
|
|
98
|
-
lang.
|
|
124
|
+
lang.language === localStorage.getItem("docusaurus.tab.code-samples")
|
|
99
125
|
);
|
|
100
|
-
const [language, setLanguage] = useState(
|
|
126
|
+
const [language, setLanguage] = useState(() => {
|
|
127
|
+
if (langs.length === 1) {
|
|
128
|
+
return langs[0];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return defaultLang[0] ?? langs[0];
|
|
132
|
+
});
|
|
101
133
|
const [codeText, setCodeText] = useState("");
|
|
102
134
|
useEffect(() => {
|
|
103
135
|
if (language && !!language.options) {
|
|
@@ -127,6 +159,38 @@ function Curl({ postman, codeSamples }) {
|
|
|
127
159
|
);
|
|
128
160
|
} else if (language && !!language.source) {
|
|
129
161
|
setCodeText(language.source);
|
|
162
|
+
} else if (language && !language.options) {
|
|
163
|
+
const langSource = languageSet.filter(
|
|
164
|
+
(lang) => lang.language === language.language
|
|
165
|
+
); // Merges user-defined language with default languageSet
|
|
166
|
+
// This allows users to define only the minimal properties necessary in languageTabs
|
|
167
|
+
// User-defined properties should override languageSet properties
|
|
168
|
+
|
|
169
|
+
const mergedLanguage = { ...langSource[0], ...language };
|
|
170
|
+
const postmanRequest = buildPostmanRequest(postman, {
|
|
171
|
+
queryParams,
|
|
172
|
+
pathParams,
|
|
173
|
+
cookieParams,
|
|
174
|
+
contentType,
|
|
175
|
+
accept,
|
|
176
|
+
headerParams,
|
|
177
|
+
body,
|
|
178
|
+
server,
|
|
179
|
+
auth,
|
|
180
|
+
});
|
|
181
|
+
codegen.convert(
|
|
182
|
+
mergedLanguage.language,
|
|
183
|
+
mergedLanguage.variant,
|
|
184
|
+
postmanRequest,
|
|
185
|
+
mergedLanguage.options,
|
|
186
|
+
(error, snippet) => {
|
|
187
|
+
if (error) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
setCodeText(snippet);
|
|
192
|
+
}
|
|
193
|
+
);
|
|
130
194
|
} else {
|
|
131
195
|
setCodeText("");
|
|
132
196
|
}
|
|
@@ -156,12 +220,16 @@ function Curl({ postman, codeSamples }) {
|
|
|
156
220
|
<CodeTab
|
|
157
221
|
value={lang.language}
|
|
158
222
|
label={""}
|
|
159
|
-
key={
|
|
223
|
+
key={
|
|
224
|
+
lang.variant
|
|
225
|
+
? `${lang.language}-${lang.variant}`
|
|
226
|
+
: lang.language
|
|
227
|
+
}
|
|
160
228
|
attributes={{
|
|
161
|
-
className: `code__tab--${lang.
|
|
229
|
+
className: `code__tab--${lang.logoClass}`,
|
|
162
230
|
}}
|
|
163
231
|
>
|
|
164
|
-
<CodeBlock language={lang.
|
|
232
|
+
<CodeBlock language={lang.highlight}>{codeText}</CodeBlock>
|
|
165
233
|
</CodeTab>
|
|
166
234
|
);
|
|
167
235
|
})}
|