docusaurus-theme-openapi-docs 4.0.0 → 4.1.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 +2 -112
- 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 +146 -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 +117 -0
- package/lib/theme/ApiItem/Layout/styles.module.css +17 -0
- package/lib/theme/ApiItem/index.js +1 -1
- package/lib/theme/ParamsItem/index.d.ts +2 -1
- package/lib/theme/ParamsItem/index.js +74 -17
- package/lib/theme/SchemaItem/index.d.ts +1 -1
- package/lib/theme/SchemaItem/index.js +106 -20
- package/package.json +6 -5
- 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 +6 -112
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +26 -5
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +146 -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 +82 -0
- package/src/theme/ApiItem/Layout/styles.module.css +17 -0
- package/src/theme/ApiItem/index.tsx +1 -1
- package/src/theme/ParamsItem/index.tsx +75 -15
- package/src/theme/SchemaItem/index.tsx +106 -17
- package/src/theme-classic.d.ts +0 -2
- package/src/theme-openapi.d.ts +4 -0
|
@@ -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
|
|
|
@@ -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,82 @@
|
|
|
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
|
+
return (
|
|
56
|
+
<div className="row">
|
|
57
|
+
<div className={clsx("col", !docTOC.hidden && styles.docItemCol)}>
|
|
58
|
+
<ContentVisibility metadata={metadata} />
|
|
59
|
+
<DocVersionBanner />
|
|
60
|
+
<div className={styles.docItemContainer}>
|
|
61
|
+
<article>
|
|
62
|
+
<DocBreadcrumbs />
|
|
63
|
+
<DocVersionBadge />
|
|
64
|
+
{docTOC.mobile}
|
|
65
|
+
<DocItemContent>{children}</DocItemContent>
|
|
66
|
+
<div className="row">
|
|
67
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
68
|
+
<DocItemFooter />
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</article>
|
|
72
|
+
<div className="row">
|
|
73
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
74
|
+
<DocItemPaginator />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
{docTOC.desktop && <div className="col col--3">{docTOC.desktop}</div>}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -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,8 +17,8 @@ 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";
|
|
20
21
|
import type { Props } from "@theme/DocItem";
|
|
21
|
-
import DocItemLayout from "@theme/DocItem/Layout";
|
|
22
22
|
import DocItemMetadata from "@theme/DocItem/Metadata";
|
|
23
23
|
import clsx from "clsx";
|
|
24
24
|
import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
@@ -14,6 +14,7 @@ import TabItem from "@theme/TabItem";
|
|
|
14
14
|
import clsx from "clsx";
|
|
15
15
|
import ReactMarkdown from "react-markdown";
|
|
16
16
|
import rehypeRaw from "rehype-raw";
|
|
17
|
+
import remarkGfm from "remark-gfm";
|
|
17
18
|
|
|
18
19
|
import { createDescription } from "../../markdown/createDescription";
|
|
19
20
|
import { getQualifierMessage, getSchemaName } from "../../markdown/schema";
|
|
@@ -39,15 +40,49 @@ export interface Props {
|
|
|
39
40
|
required: boolean;
|
|
40
41
|
deprecated: boolean;
|
|
41
42
|
schema: any;
|
|
43
|
+
enumDescriptions?: [string, string][];
|
|
42
44
|
};
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => {
|
|
48
|
+
if (enumDescriptions?.length) {
|
|
49
|
+
return `| Enum Value | Description |
|
|
50
|
+
| ---- | ----- |
|
|
51
|
+
${enumDescriptions
|
|
52
|
+
.map((desc) => {
|
|
53
|
+
return `| ${desc[0]} | ${desc[1]} | `.replaceAll("\n", "<br/>");
|
|
54
|
+
})
|
|
55
|
+
.join("\n")}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return "";
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
function ParamsItem({ param, ...rest }: Props) {
|
|
63
|
+
const {
|
|
64
|
+
description,
|
|
65
|
+
example,
|
|
66
|
+
examples,
|
|
67
|
+
name,
|
|
68
|
+
required,
|
|
69
|
+
deprecated,
|
|
70
|
+
enumDescriptions,
|
|
71
|
+
} = param;
|
|
72
|
+
|
|
73
|
+
let schema = param.schema;
|
|
74
|
+
let defaultValue: string | undefined;
|
|
75
|
+
|
|
48
76
|
if (!schema || !schema?.type) {
|
|
49
77
|
schema = { type: "any" };
|
|
50
78
|
}
|
|
79
|
+
if (schema) {
|
|
80
|
+
if (schema.items) {
|
|
81
|
+
defaultValue = schema.items.default;
|
|
82
|
+
} else {
|
|
83
|
+
defaultValue = schema.default;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
51
86
|
|
|
52
87
|
const renderSchemaName = guard(schema, (schema) => (
|
|
53
88
|
<span className="openapi-schema__type"> {getSchemaName(schema)}</span>
|
|
@@ -91,19 +126,43 @@ function ParamsItem({
|
|
|
91
126
|
</div>
|
|
92
127
|
));
|
|
93
128
|
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
129
|
+
const renderEnumDescriptions = guard(
|
|
130
|
+
getEnumDescriptionMarkdown(enumDescriptions),
|
|
131
|
+
(value) => {
|
|
132
|
+
return (
|
|
133
|
+
<ReactMarkdown
|
|
134
|
+
rehypePlugins={[rehypeRaw]}
|
|
135
|
+
remarkPlugins={[remarkGfm]}
|
|
136
|
+
children={value}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
105
140
|
);
|
|
106
141
|
|
|
142
|
+
function renderDefaultValue() {
|
|
143
|
+
if (defaultValue !== undefined) {
|
|
144
|
+
if (typeof defaultValue === "string") {
|
|
145
|
+
return (
|
|
146
|
+
<div>
|
|
147
|
+
<strong>Default value: </strong>
|
|
148
|
+
<span>
|
|
149
|
+
<code>{defaultValue}</code>
|
|
150
|
+
</span>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return (
|
|
155
|
+
<div>
|
|
156
|
+
<strong>Default value: </strong>
|
|
157
|
+
<span>
|
|
158
|
+
<code>{JSON.stringify(defaultValue)}</code>
|
|
159
|
+
</span>
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
|
|
107
166
|
const renderExample = guard(toString(example), (example) => (
|
|
108
167
|
<div>
|
|
109
168
|
<strong>Example: </strong>
|
|
@@ -156,8 +215,9 @@ function ParamsItem({
|
|
|
156
215
|
{renderDeprecated}
|
|
157
216
|
</span>
|
|
158
217
|
{renderSchema}
|
|
159
|
-
{renderDefaultValue}
|
|
160
218
|
{renderDescription}
|
|
219
|
+
{renderEnumDescriptions}
|
|
220
|
+
{renderDefaultValue()}
|
|
161
221
|
{renderExample}
|
|
162
222
|
{renderExamples}
|
|
163
223
|
</div>
|