docusaurus-theme-openapi-docs 4.0.1 → 4.2.0
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/markdown/utils.d.ts +5 -4
- package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -113
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +30 -6
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +196 -2
- package/lib/theme/ApiExplorer/CodeTabs/index.js +34 -8
- package/lib/theme/ApiExplorer/MethodEndpoint/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/MethodEndpoint/index.js +5 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +1 -0
- package/lib/theme/ApiExplorer/Request/_Request.scss +5 -0
- package/lib/theme/ApiExplorer/index.js +6 -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/index.js +16 -5
- package/lib/theme/ApiTabs/_ApiTabs.scss +0 -1
- package/lib/theme/ArrayBrackets/index.d.ts +3 -0
- package/lib/theme/ArrayBrackets/index.js +50 -0
- package/lib/theme/ParamsDetails/index.d.ts +6 -0
- package/lib/theme/ParamsDetails/index.js +134 -0
- package/lib/theme/ParamsItem/index.d.ts +3 -1
- package/lib/theme/ParamsItem/index.js +77 -16
- package/lib/theme/RequestSchema/index.d.ts +15 -0
- package/lib/theme/RequestSchema/index.js +235 -0
- package/lib/theme/ResponseExamples/index.d.ts +48 -0
- package/lib/theme/ResponseExamples/index.js +290 -0
- package/lib/theme/ResponseSchema/index.d.ts +15 -0
- package/lib/theme/ResponseSchema/index.js +206 -0
- package/lib/theme/Schema/index.d.ts +8 -0
- package/lib/theme/Schema/index.js +879 -0
- package/lib/theme/SchemaItem/index.d.ts +9 -9
- package/lib/theme/SchemaItem/index.js +110 -20
- 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 +78 -0
- package/lib/theme/styles.scss +56 -9
- package/package.json +9 -7
- package/src/markdown/utils.ts +7 -6
- package/src/plugin-content-docs.d.ts +2 -0
- package/src/theme/ApiExplorer/CodeSnippets/code-snippets-types.ts +2 -0
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +8 -113
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +26 -5
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +196 -2
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +40 -9
- package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +7 -3
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +1 -0
- package/src/theme/ApiExplorer/Request/_Request.scss +5 -0
- package/src/theme/ApiExplorer/index.tsx +2 -0
- package/src/theme/ApiItem/Layout/index.tsx +85 -0
- package/src/theme/ApiItem/Layout/styles.module.css +17 -0
- package/src/theme/ApiItem/index.tsx +15 -3
- package/src/theme/ApiTabs/_ApiTabs.scss +0 -1
- package/src/theme/ArrayBrackets/index.tsx +37 -0
- package/src/theme/ParamsDetails/index.tsx +88 -0
- package/src/theme/ParamsItem/index.tsx +80 -17
- package/src/theme/RequestSchema/index.tsx +164 -0
- package/src/theme/ResponseExamples/index.tsx +290 -0
- package/src/theme/ResponseSchema/index.tsx +151 -0
- package/src/theme/Schema/index.tsx +928 -0
- package/src/theme/SchemaItem/index.tsx +116 -25
- package/src/theme/SkeletonLoader/index.tsx +18 -0
- package/src/theme/StatusCodes/index.tsx +72 -0
- package/src/theme/styles.scss +56 -9
- package/src/theme-classic.d.ts +0 -2
- package/src/theme-openapi.d.ts +4 -0
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
8
|
import find from "lodash/find";
|
|
9
|
-
import isArray from "lodash/isArray";
|
|
10
9
|
import mergeWith from "lodash/mergeWith";
|
|
11
10
|
import unionBy from "lodash/unionBy";
|
|
11
|
+
import codegen from "postman-code-generators";
|
|
12
12
|
|
|
13
13
|
import { CodeSample, Language } from "./code-snippets-types";
|
|
14
14
|
|
|
@@ -50,10 +50,7 @@ export const mergeArraysbyLanguage = (arr1: any, arr2: any) => {
|
|
|
50
50
|
find(arr2, ["language", item["language"]]),
|
|
51
51
|
];
|
|
52
52
|
return mergeWith({}, ...matchingItems, (objValue: any) => {
|
|
53
|
-
|
|
54
|
-
return objValue;
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
53
|
+
return objValue;
|
|
57
54
|
});
|
|
58
55
|
});
|
|
59
56
|
};
|
|
@@ -73,3 +70,27 @@ export function getCodeSampleSourceFromLanguage(language: Language) {
|
|
|
73
70
|
|
|
74
71
|
return "";
|
|
75
72
|
}
|
|
73
|
+
|
|
74
|
+
export function generateLanguageSet() {
|
|
75
|
+
const languageSet: Language[] = [];
|
|
76
|
+
codegen.getLanguageList().forEach((language: any) => {
|
|
77
|
+
const variants: any = [];
|
|
78
|
+
language.variants.forEach((variant: any) => {
|
|
79
|
+
variants.push(variant.key);
|
|
80
|
+
});
|
|
81
|
+
languageSet.push({
|
|
82
|
+
highlight: language.syntax_mode,
|
|
83
|
+
language: language.key,
|
|
84
|
+
codeSampleLanguage: language.label,
|
|
85
|
+
logoClass: language.key,
|
|
86
|
+
options: {
|
|
87
|
+
longFormat: false,
|
|
88
|
+
followRedirect: true,
|
|
89
|
+
trimRequestBody: true,
|
|
90
|
+
},
|
|
91
|
+
variant: variants[0],
|
|
92
|
+
variants: variants,
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
return languageSet;
|
|
96
|
+
}
|
|
@@ -146,6 +146,24 @@ body[class="ReactModal__Body--open"] {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
.openapi-tabs__code-item--dart {
|
|
150
|
+
color: var(--ifm-color-info);
|
|
151
|
+
|
|
152
|
+
&::after {
|
|
153
|
+
content: "";
|
|
154
|
+
width: var(--code-tab-logo-width);
|
|
155
|
+
height: var(--code-tab-logo-height);
|
|
156
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/dart/dart-original.svg")
|
|
157
|
+
no-repeat;
|
|
158
|
+
margin-block: auto;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&.active {
|
|
162
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-dart);
|
|
163
|
+
border-color: var(--openapi-code-tab-border-color-dart);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
149
167
|
.openapi-tabs__code-item--javascript {
|
|
150
168
|
color: var(--ifm-color-warning);
|
|
151
169
|
|
|
@@ -164,7 +182,7 @@ body[class="ReactModal__Body--open"] {
|
|
|
164
182
|
}
|
|
165
183
|
}
|
|
166
184
|
|
|
167
|
-
.openapi-tabs__code-item--
|
|
185
|
+
.openapi-tabs__code-item--curl {
|
|
168
186
|
color: var(--ifm-color-danger);
|
|
169
187
|
|
|
170
188
|
&::after {
|
|
@@ -179,7 +197,7 @@ body[class="ReactModal__Body--open"] {
|
|
|
179
197
|
}
|
|
180
198
|
|
|
181
199
|
&.active {
|
|
182
|
-
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-
|
|
200
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-curl);
|
|
183
201
|
border-color: var(--ifm-color-danger);
|
|
184
202
|
}
|
|
185
203
|
}
|
|
@@ -220,6 +238,96 @@ body[class="ReactModal__Body--open"] {
|
|
|
220
238
|
}
|
|
221
239
|
}
|
|
222
240
|
|
|
241
|
+
.openapi-tabs__code-item--r {
|
|
242
|
+
color: var(--ifm-color-gray-500);
|
|
243
|
+
|
|
244
|
+
&::after {
|
|
245
|
+
content: "";
|
|
246
|
+
width: var(--code-tab-logo-width);
|
|
247
|
+
height: var(--code-tab-logo-height);
|
|
248
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/r/r-original.svg")
|
|
249
|
+
no-repeat;
|
|
250
|
+
margin-block: auto;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
&.active {
|
|
254
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-r);
|
|
255
|
+
border-color: var(--openapi-code-tab-border-color-r);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.openapi-tabs__code-item--swift {
|
|
260
|
+
color: var(--ifm-color-danger);
|
|
261
|
+
|
|
262
|
+
&::after {
|
|
263
|
+
content: "";
|
|
264
|
+
width: var(--code-tab-logo-width);
|
|
265
|
+
height: var(--code-tab-logo-height);
|
|
266
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/swift/swift-original.svg")
|
|
267
|
+
no-repeat;
|
|
268
|
+
margin-block: auto;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
&.active {
|
|
272
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-swift);
|
|
273
|
+
border-color: var(--openapi-code-tab-border-color-swift);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.openapi-tabs__code-item--c {
|
|
278
|
+
color: var(--ifm-color-info);
|
|
279
|
+
|
|
280
|
+
&::after {
|
|
281
|
+
content: "";
|
|
282
|
+
width: var(--code-tab-logo-width);
|
|
283
|
+
height: var(--code-tab-logo-height);
|
|
284
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/c/c-original.svg")
|
|
285
|
+
no-repeat;
|
|
286
|
+
margin-block: auto;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
&.active {
|
|
290
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-c);
|
|
291
|
+
border-color: var(--openapi-code-tab-border-color-c);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.openapi-tabs__code-item--objective-c {
|
|
296
|
+
color: var(--ifm-color-info);
|
|
297
|
+
|
|
298
|
+
&::after {
|
|
299
|
+
content: "";
|
|
300
|
+
width: var(--code-tab-logo-width);
|
|
301
|
+
height: var(--code-tab-logo-height);
|
|
302
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/objectivec/objectivec-plain.svg")
|
|
303
|
+
no-repeat;
|
|
304
|
+
margin-block: auto;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
&.active {
|
|
308
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-objective-c);
|
|
309
|
+
border-color: var(--openapi-code-tab-border-color-objective-c);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.openapi-tabs__code-item--ocaml {
|
|
314
|
+
color: var(--ifm-color-warning);
|
|
315
|
+
|
|
316
|
+
&::after {
|
|
317
|
+
content: "";
|
|
318
|
+
width: var(--code-tab-logo-width);
|
|
319
|
+
height: var(--code-tab-logo-height);
|
|
320
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/ocaml/ocaml-original.svg")
|
|
321
|
+
no-repeat;
|
|
322
|
+
margin-block: auto;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
&.active {
|
|
326
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-objective-ocaml);
|
|
327
|
+
border-color: var(--openapi-code-tab-border-color-objective-ocaml);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
223
331
|
.openapi-tabs__code-item--nodejs {
|
|
224
332
|
color: var(--ifm-color-success);
|
|
225
333
|
|
|
@@ -256,6 +364,42 @@ body[class="ReactModal__Body--open"] {
|
|
|
256
364
|
}
|
|
257
365
|
}
|
|
258
366
|
|
|
367
|
+
.openapi-tabs__code-item--kotlin {
|
|
368
|
+
color: var(--ifm-color-gray-500);
|
|
369
|
+
|
|
370
|
+
&::after {
|
|
371
|
+
content: "";
|
|
372
|
+
width: var(--code-tab-logo-width);
|
|
373
|
+
height: var(--code-tab-logo-height);
|
|
374
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/kotlin/kotlin-original.svg")
|
|
375
|
+
no-repeat;
|
|
376
|
+
margin-block: auto;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
&.active {
|
|
380
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-kotlin);
|
|
381
|
+
border-color: var(--openapi-code-tab-border-color-kotlin);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.openapi-tabs__code-item--rust {
|
|
386
|
+
color: var(--ifm-color-gray-500);
|
|
387
|
+
|
|
388
|
+
&::after {
|
|
389
|
+
content: "";
|
|
390
|
+
width: var(--code-tab-logo-width);
|
|
391
|
+
height: var(--code-tab-logo-height);
|
|
392
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/rust/rust-original.svg")
|
|
393
|
+
no-repeat;
|
|
394
|
+
margin-block: auto;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
&.active {
|
|
398
|
+
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-rust);
|
|
399
|
+
border-color: var(--openapi-code-tab-border-color-rust);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
259
403
|
.openapi-tabs__code-item--java {
|
|
260
404
|
color: var(--ifm-color-warning);
|
|
261
405
|
|
|
@@ -292,6 +436,56 @@ body[class="ReactModal__Body--open"] {
|
|
|
292
436
|
}
|
|
293
437
|
}
|
|
294
438
|
|
|
439
|
+
.openapi-tabs__code-item--http {
|
|
440
|
+
color: var(--ifm-color-gray-500);
|
|
441
|
+
display: flex;
|
|
442
|
+
align-items: center;
|
|
443
|
+
justify-content: center;
|
|
444
|
+
position: relative;
|
|
445
|
+
|
|
446
|
+
&::after {
|
|
447
|
+
content: "";
|
|
448
|
+
display: inline-block;
|
|
449
|
+
width: 32px; /* Explicitly setting width to 32 pixels */
|
|
450
|
+
height: 32px; /* Explicitly setting height to 32 pixels */
|
|
451
|
+
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIyTDggMTZMMTIgMTBNMjAgMjJMMjQgMTZMIDIwIDEwIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=");
|
|
452
|
+
background-size: contain;
|
|
453
|
+
background-repeat: no-repeat;
|
|
454
|
+
background-position: center; /* Center the SVG */
|
|
455
|
+
margin-top: 0.5rem;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
&.active {
|
|
459
|
+
box-shadow: 0 0 0 3px var(--opeanpi-code-tab-shadow-color-http);
|
|
460
|
+
border-color: var(--openapi-code-tab-border-color-http);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.openapi-tabs__code-item--shell {
|
|
465
|
+
color: var(--ifm-color-gray-500);
|
|
466
|
+
display: flex;
|
|
467
|
+
align-items: center;
|
|
468
|
+
justify-content: center;
|
|
469
|
+
position: relative;
|
|
470
|
+
|
|
471
|
+
&::after {
|
|
472
|
+
content: "";
|
|
473
|
+
display: inline-block;
|
|
474
|
+
width: 32px; /* Explicitly setting width to 32 pixels */
|
|
475
|
+
height: 32px; /* Explicitly setting height to 32 pixels */
|
|
476
|
+
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIyTDggMTZMMTIgMTBNMjAgMjJMMjQgMTZMIDIwIDEwIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=");
|
|
477
|
+
background-size: contain;
|
|
478
|
+
background-repeat: no-repeat;
|
|
479
|
+
background-position: center; /* Center the SVG */
|
|
480
|
+
margin-top: 0.5rem;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
&.active {
|
|
484
|
+
box-shadow: 0 0 0 3px var(--opeanpi-code-tab-shadow-color-shell);
|
|
485
|
+
border-color: var(--openapi-code-tab-border-color-shell);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
295
489
|
@media only screen and (min-width: 768px) and (max-width: 996px) {
|
|
296
490
|
.openapi-tabs__code-list {
|
|
297
491
|
justify-content: space-around;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React, { cloneElement, ReactElement } from "react";
|
|
8
|
+
import React, { cloneElement, ReactElement, useEffect, useRef } from "react";
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
sanitizeTabsChildren,
|
|
@@ -43,10 +43,38 @@ function TabList({
|
|
|
43
43
|
selectValue,
|
|
44
44
|
tabValues,
|
|
45
45
|
}: CodeTabsProps & ReturnType<typeof useTabs>) {
|
|
46
|
-
const tabRefs
|
|
46
|
+
const tabRefs = useRef<(HTMLLIElement | null)[]>([]);
|
|
47
|
+
const tabsScrollContainerRef = useRef<any>();
|
|
47
48
|
const { blockElementScrollPositionUntilNextRender } =
|
|
48
49
|
useScrollPositionBlocker();
|
|
49
50
|
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const activeTab = tabRefs.current.find(
|
|
53
|
+
(tab) => tab?.getAttribute("aria-selected") === "true"
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
if (activeTab && tabsScrollContainerRef.current) {
|
|
57
|
+
const container = tabsScrollContainerRef.current;
|
|
58
|
+
const containerRect = container.getBoundingClientRect();
|
|
59
|
+
const activeTabRect = activeTab.getBoundingClientRect();
|
|
60
|
+
|
|
61
|
+
// Calculate the distance to scroll to align active tab to the left
|
|
62
|
+
const glowOffset = 3;
|
|
63
|
+
const scrollOffset =
|
|
64
|
+
activeTabRect.left -
|
|
65
|
+
containerRect.left +
|
|
66
|
+
container.scrollLeft -
|
|
67
|
+
glowOffset;
|
|
68
|
+
|
|
69
|
+
// Check if the active tab is not already at the left position
|
|
70
|
+
|
|
71
|
+
if (Math.abs(scrollOffset - container.scrollLeft) > 4) {
|
|
72
|
+
// Adjust the scroll of the container
|
|
73
|
+
container.scrollLeft = scrollOffset;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
50
78
|
const handleTabChange = (
|
|
51
79
|
event:
|
|
52
80
|
| React.FocusEvent<HTMLLIElement>
|
|
@@ -54,7 +82,7 @@ function TabList({
|
|
|
54
82
|
| React.KeyboardEvent<HTMLLIElement>
|
|
55
83
|
) => {
|
|
56
84
|
const newTab = event.currentTarget;
|
|
57
|
-
const newTabIndex = tabRefs.indexOf(newTab);
|
|
85
|
+
const newTabIndex = tabRefs.current.indexOf(newTab);
|
|
58
86
|
const newTabValue = tabValues[newTabIndex]!.value;
|
|
59
87
|
|
|
60
88
|
if (newTabValue !== selectedValue) {
|
|
@@ -80,7 +108,7 @@ function TabList({
|
|
|
80
108
|
newLanguage = languageSet.filter(
|
|
81
109
|
(lang: Language) => lang.language === newTabValue
|
|
82
110
|
)[0];
|
|
83
|
-
action.setSelectedVariant(newLanguage.
|
|
111
|
+
action.setSelectedVariant(newLanguage.variants[0].toLowerCase());
|
|
84
112
|
action.setSelectedSample(newLanguage.sample);
|
|
85
113
|
}
|
|
86
114
|
action.setLanguage(newLanguage);
|
|
@@ -96,13 +124,15 @@ function TabList({
|
|
|
96
124
|
break;
|
|
97
125
|
}
|
|
98
126
|
case "ArrowRight": {
|
|
99
|
-
const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
|
|
100
|
-
focusElement = tabRefs[nextTab] ?? tabRefs[0]!;
|
|
127
|
+
const nextTab = tabRefs.current.indexOf(event.currentTarget) + 1;
|
|
128
|
+
focusElement = tabRefs.current[nextTab] ?? tabRefs.current[0]!;
|
|
101
129
|
break;
|
|
102
130
|
}
|
|
103
131
|
case "ArrowLeft": {
|
|
104
|
-
const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
|
|
105
|
-
focusElement =
|
|
132
|
+
const prevTab = tabRefs.current.indexOf(event.currentTarget) - 1;
|
|
133
|
+
focusElement =
|
|
134
|
+
tabRefs.current[prevTab] ??
|
|
135
|
+
tabRefs.current[tabRefs.current.length - 1]!;
|
|
106
136
|
break;
|
|
107
137
|
}
|
|
108
138
|
default:
|
|
@@ -124,6 +154,7 @@ function TabList({
|
|
|
124
154
|
},
|
|
125
155
|
className
|
|
126
156
|
)}
|
|
157
|
+
ref={tabsScrollContainerRef}
|
|
127
158
|
>
|
|
128
159
|
{tabValues.map(({ value, label, attributes }) => (
|
|
129
160
|
<li
|
|
@@ -132,7 +163,7 @@ function TabList({
|
|
|
132
163
|
tabIndex={selectedValue === value ? 0 : -1}
|
|
133
164
|
aria-selected={selectedValue === value}
|
|
134
165
|
key={value}
|
|
135
|
-
ref={(tabControl) => tabRefs.push(tabControl)}
|
|
166
|
+
ref={(tabControl) => tabRefs.current.push(tabControl)}
|
|
136
167
|
onKeyDown={handleKeydown}
|
|
137
168
|
onClick={handleTabChange}
|
|
138
169
|
{...attributes}
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import BrowserOnly from "@docusaurus/BrowserOnly";
|
|
11
|
-
|
|
12
|
-
import { useTypedSelector } from "../../ApiItem/hooks";
|
|
11
|
+
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
13
12
|
|
|
14
13
|
function colorForMethod(method: string) {
|
|
15
14
|
switch (method.toLowerCase()) {
|
|
@@ -35,13 +34,18 @@ function colorForMethod(method: string) {
|
|
|
35
34
|
export interface Props {
|
|
36
35
|
method: string;
|
|
37
36
|
path: string;
|
|
37
|
+
context?: "endpoint" | "callback";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function MethodEndpoint({ method, path }: Props) {
|
|
40
|
+
function MethodEndpoint({ method, path, context }: Props) {
|
|
41
41
|
let serverValue = useTypedSelector((state: any) => state.server.value);
|
|
42
42
|
let serverUrlWithVariables = "";
|
|
43
43
|
|
|
44
44
|
const renderServerUrl = () => {
|
|
45
|
+
if (context === "callback") {
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
if (serverValue && serverValue.variables) {
|
|
46
50
|
serverUrlWithVariables = serverValue.url.replace(/\/$/, "");
|
|
47
51
|
|
|
@@ -114,6 +114,11 @@
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
.openapi-security__summary-container {
|
|
118
|
+
background: var(--ifm-pre-background);
|
|
119
|
+
border-radius: var(--ifm-pre-border-radius);
|
|
120
|
+
}
|
|
121
|
+
|
|
117
122
|
// Prevent auto zoom on mobile iOS devices when focusing on input elmenents
|
|
118
123
|
@media screen and (-webkit-min-device-pixel-ratio: 0) and (max-device-width: 1024px) {
|
|
119
124
|
.prism-code,
|
|
@@ -10,6 +10,7 @@ import React from "react";
|
|
|
10
10
|
import CodeSnippets from "@theme/ApiExplorer/CodeSnippets";
|
|
11
11
|
import Request from "@theme/ApiExplorer/Request";
|
|
12
12
|
import Response from "@theme/ApiExplorer/Response";
|
|
13
|
+
import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";
|
|
13
14
|
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
14
15
|
import sdk from "postman-collection";
|
|
15
16
|
|
|
@@ -24,6 +25,7 @@ function ApiExplorer({
|
|
|
24
25
|
|
|
25
26
|
return (
|
|
26
27
|
<>
|
|
28
|
+
<SecuritySchemes infoPath={infoPath} />
|
|
27
29
|
{item.method !== "event" && (
|
|
28
30
|
<CodeSnippets
|
|
29
31
|
postman={postman}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import { useDoc } from "@docusaurus/plugin-content-docs/client";
|
|
11
|
+
import { useWindowSize } from "@docusaurus/theme-common";
|
|
12
|
+
import type { Props } from "@theme/ApiItem/Layout";
|
|
13
|
+
import ContentVisibility from "@theme/ContentVisibility";
|
|
14
|
+
import DocBreadcrumbs from "@theme/DocBreadcrumbs";
|
|
15
|
+
import DocItemContent from "@theme/DocItem/Content";
|
|
16
|
+
import DocItemFooter from "@theme/DocItem/Footer";
|
|
17
|
+
import DocItemPaginator from "@theme/DocItem/Paginator";
|
|
18
|
+
import DocItemTOCDesktop from "@theme/DocItem/TOC/Desktop";
|
|
19
|
+
import DocItemTOCMobile from "@theme/DocItem/TOC/Mobile";
|
|
20
|
+
import DocVersionBadge from "@theme/DocVersionBadge";
|
|
21
|
+
import DocVersionBanner from "@theme/DocVersionBanner";
|
|
22
|
+
import clsx from "clsx";
|
|
23
|
+
|
|
24
|
+
import styles from "./styles.module.css";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Decide if the toc should be rendered, on mobile or desktop viewports
|
|
28
|
+
*/
|
|
29
|
+
function useDocTOC() {
|
|
30
|
+
const { frontMatter, toc } = useDoc();
|
|
31
|
+
const windowSize = useWindowSize();
|
|
32
|
+
|
|
33
|
+
const hidden = frontMatter.hide_table_of_contents;
|
|
34
|
+
const canRender = !hidden && toc.length > 0;
|
|
35
|
+
|
|
36
|
+
const mobile = canRender ? <DocItemTOCMobile /> : undefined;
|
|
37
|
+
|
|
38
|
+
const desktop =
|
|
39
|
+
canRender && (windowSize === "desktop" || windowSize === "ssr") ? (
|
|
40
|
+
<DocItemTOCDesktop />
|
|
41
|
+
) : undefined;
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
hidden,
|
|
45
|
+
mobile,
|
|
46
|
+
desktop,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default function DocItemLayout({ children }: Props): JSX.Element {
|
|
51
|
+
const docTOC = useDocTOC();
|
|
52
|
+
const { metadata } = useDoc();
|
|
53
|
+
const { frontMatter } = useDoc();
|
|
54
|
+
const api = frontMatter.api;
|
|
55
|
+
const schema = frontMatter.schema;
|
|
56
|
+
return (
|
|
57
|
+
<div className="row">
|
|
58
|
+
<div className={clsx("col", !docTOC.hidden && styles.docItemCol)}>
|
|
59
|
+
<ContentVisibility metadata={metadata} />
|
|
60
|
+
<DocVersionBanner />
|
|
61
|
+
<div className={styles.docItemContainer}>
|
|
62
|
+
<article>
|
|
63
|
+
<DocBreadcrumbs />
|
|
64
|
+
<DocVersionBadge />
|
|
65
|
+
{docTOC.mobile}
|
|
66
|
+
<DocItemContent>{children}</DocItemContent>
|
|
67
|
+
<div className="row">
|
|
68
|
+
<div
|
|
69
|
+
className={clsx("col", api || schema ? "col--7" : "col--12")}
|
|
70
|
+
>
|
|
71
|
+
<DocItemFooter />
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</article>
|
|
75
|
+
<div className="row">
|
|
76
|
+
<div className={clsx("col", api || schema ? "col--7" : "col--12")}>
|
|
77
|
+
<DocItemPaginator />
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
{docTOC.desktop && <div className="col col--3">{docTOC.desktop}</div>}
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
.docItemContainer header + *,
|
|
9
|
+
.docItemContainer article > *:first-child {
|
|
10
|
+
margin-top: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@media (min-width: 997px) {
|
|
14
|
+
.docItemCol {
|
|
15
|
+
max-width: 75% !important;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -17,9 +17,11 @@ import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
|
17
17
|
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
18
18
|
import { createAuth } from "@theme/ApiExplorer/Authorization/slice";
|
|
19
19
|
import { createPersistanceMiddleware } from "@theme/ApiExplorer/persistanceMiddleware";
|
|
20
|
+
import DocItemLayout from "@theme/ApiItem/Layout";
|
|
21
|
+
import CodeBlock from "@theme/CodeBlock";
|
|
20
22
|
import type { Props } from "@theme/DocItem";
|
|
21
|
-
import DocItemLayout from "@theme/DocItem/Layout";
|
|
22
23
|
import DocItemMetadata from "@theme/DocItem/Metadata";
|
|
24
|
+
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
23
25
|
import clsx from "clsx";
|
|
24
26
|
import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
25
27
|
import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
@@ -46,6 +48,10 @@ interface SchemaFrontMatter extends DocFrontMatter {
|
|
|
46
48
|
readonly schema?: boolean;
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
interface SampleFrontMatter extends DocFrontMatter {
|
|
52
|
+
readonly sample?: any;
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
// @ts-ignore
|
|
50
56
|
export default function ApiItem(props: Props): JSX.Element {
|
|
51
57
|
const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
|
|
@@ -54,6 +60,7 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
54
60
|
const { info_path: infoPath } = frontMatter as DocFrontMatter;
|
|
55
61
|
let { api } = frontMatter as ApiFrontMatter;
|
|
56
62
|
const { schema } = frontMatter as SchemaFrontMatter;
|
|
63
|
+
const { sample } = frontMatter as SampleFrontMatter;
|
|
57
64
|
// decompress and parse
|
|
58
65
|
if (api) {
|
|
59
66
|
try {
|
|
@@ -152,7 +159,7 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
152
159
|
<MDXComponent />
|
|
153
160
|
</div>
|
|
154
161
|
<div className="col col--5 openapi-right-panel__container">
|
|
155
|
-
<BrowserOnly fallback={<
|
|
162
|
+
<BrowserOnly fallback={<SkeletonLoader size="lg" />}>
|
|
156
163
|
{() => {
|
|
157
164
|
return <ApiExplorer item={api} infoPath={infoPath} />;
|
|
158
165
|
}}
|
|
@@ -171,9 +178,14 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
171
178
|
<DocItemMetadata />
|
|
172
179
|
<DocItemLayout>
|
|
173
180
|
<div className={clsx("row", "theme-api-markdown")}>
|
|
174
|
-
<div className="col col--
|
|
181
|
+
<div className="col col--7 openapi-left-panel__container schema">
|
|
175
182
|
<MDXComponent />
|
|
176
183
|
</div>
|
|
184
|
+
<div className="col col--5 openapi-right-panel__container">
|
|
185
|
+
<CodeBlock language="json" title={`${frontMatter.title}`}>
|
|
186
|
+
{JSON.stringify(sample, null, 2)}
|
|
187
|
+
</CodeBlock>
|
|
188
|
+
</div>
|
|
177
189
|
</div>
|
|
178
190
|
</DocItemLayout>
|
|
179
191
|
</HtmlClassNameProvider>
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
export const OpeningArrayBracket = () => (
|
|
11
|
+
<li>
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
15
|
+
opacity: 0.6,
|
|
16
|
+
marginLeft: "-.5rem",
|
|
17
|
+
paddingBottom: ".5rem",
|
|
18
|
+
}}
|
|
19
|
+
>
|
|
20
|
+
Array [
|
|
21
|
+
</div>
|
|
22
|
+
</li>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const ClosingArrayBracket = () => (
|
|
26
|
+
<li>
|
|
27
|
+
<div
|
|
28
|
+
style={{
|
|
29
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
30
|
+
opacity: 0.6,
|
|
31
|
+
marginLeft: "-.5rem",
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
]
|
|
35
|
+
</div>
|
|
36
|
+
</li>
|
|
37
|
+
);
|