docusaurus-theme-openapi-docs 0.0.0-862 → 0.0.0-939
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/CodeTabs/_CodeTabs.scss +50 -0
- package/lib/theme/ApiItem/index.js +3 -3
- 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 +1 -0
- package/lib/theme/ParamsItem/index.js +10 -6
- 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 +778 -0
- package/lib/theme/SchemaItem/index.d.ts +8 -8
- package/lib/theme/SchemaItem/index.js +9 -5
- 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 +41 -0
- package/package.json +4 -3
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +50 -0
- package/src/theme/ApiItem/index.tsx +2 -1
- package/src/theme/ArrayBrackets/index.tsx +37 -0
- package/src/theme/ParamsDetails/index.tsx +88 -0
- package/src/theme/ParamsItem/index.tsx +10 -7
- 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 +809 -0
- package/src/theme/SchemaItem/index.tsx +15 -13
- package/src/theme/SkeletonLoader/index.tsx +18 -0
- package/src/theme/StatusCodes/index.tsx +72 -0
- package/src/theme/styles.scss +41 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
export interface Props {
|
|
3
|
-
children
|
|
4
|
-
collapsible
|
|
5
|
-
name
|
|
6
|
-
qualifierMessage
|
|
7
|
-
required
|
|
8
|
-
schemaName
|
|
9
|
-
schema
|
|
10
|
-
discriminator
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
collapsible?: boolean;
|
|
5
|
+
name?: string;
|
|
6
|
+
qualifierMessage?: string | undefined;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
schemaName?: string;
|
|
9
|
+
schema?: any;
|
|
10
|
+
discriminator?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export default function SchemaItem(props: Props): React.JSX.Element;
|
|
@@ -88,11 +88,15 @@ function SchemaItem(props) {
|
|
|
88
88
|
const renderEnumDescriptions = (0, utils_1.guard)(
|
|
89
89
|
getEnumDescriptionMarkdown(enumDescriptions),
|
|
90
90
|
(value) => {
|
|
91
|
-
return react_1.default.createElement(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
return react_1.default.createElement(
|
|
92
|
+
"div",
|
|
93
|
+
{ style: { marginTop: ".5rem" } },
|
|
94
|
+
react_1.default.createElement(react_markdown_1.default, {
|
|
95
|
+
remarkPlugins: [remark_gfm_1.default],
|
|
96
|
+
rehypePlugins: [rehype_raw_1.default],
|
|
97
|
+
children: value,
|
|
98
|
+
})
|
|
99
|
+
);
|
|
96
100
|
}
|
|
97
101
|
);
|
|
98
102
|
const renderSchemaDescription = (0, utils_1.guard)(
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const SkeletonLoader = (props) => {
|
|
16
|
+
return react_1.default.createElement("div", {
|
|
17
|
+
className: `openapi-skeleton ${props.size ?? "md"}`,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.default = SkeletonLoader;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ApiItem } from "docusaurus-plugin-openapi-docs/lib/types";
|
|
3
|
+
interface Props {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
responses: ApiItem["responses"];
|
|
7
|
+
}
|
|
8
|
+
declare const StatusCodes: React.FC<Props>;
|
|
9
|
+
export default StatusCodes;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const ApiTabs_1 = __importDefault(require("@theme/ApiTabs"));
|
|
16
|
+
const Details_1 = __importDefault(require("@theme/Details"));
|
|
17
|
+
const ResponseExamples_1 = require("@theme/ResponseExamples");
|
|
18
|
+
const ResponseSchema_1 = __importDefault(require("@theme/ResponseSchema"));
|
|
19
|
+
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
20
|
+
const createDescription_1 = require("docusaurus-plugin-openapi-docs/lib/markdown/createDescription");
|
|
21
|
+
const StatusCodes = ({ label, id, responses }) => {
|
|
22
|
+
if (!responses) return null;
|
|
23
|
+
const codes = Object.keys(responses);
|
|
24
|
+
if (codes.length === 0) return null;
|
|
25
|
+
return react_1.default.createElement(
|
|
26
|
+
ApiTabs_1.default,
|
|
27
|
+
{ label: label, id: id },
|
|
28
|
+
codes.map((code) => {
|
|
29
|
+
const response = responses[code];
|
|
30
|
+
const responseHeaders = response.headers;
|
|
31
|
+
return (
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
react_1.default.createElement(
|
|
34
|
+
TabItem_1.default,
|
|
35
|
+
{ key: code, label: code, value: code },
|
|
36
|
+
react_1.default.createElement(
|
|
37
|
+
"div",
|
|
38
|
+
null,
|
|
39
|
+
response.description &&
|
|
40
|
+
react_1.default.createElement(
|
|
41
|
+
"div",
|
|
42
|
+
{ style: { marginTop: ".5rem", marginBottom: ".5rem" } },
|
|
43
|
+
(0, createDescription_1.createDescription)(response.description)
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
responseHeaders &&
|
|
47
|
+
react_1.default.createElement(
|
|
48
|
+
Details_1.default,
|
|
49
|
+
{
|
|
50
|
+
className: "openapi-markdown__details",
|
|
51
|
+
"data-collapsed": true,
|
|
52
|
+
open: false,
|
|
53
|
+
style: { textAlign: "left", marginBottom: "1rem" },
|
|
54
|
+
summary: react_1.default.createElement(
|
|
55
|
+
"summary",
|
|
56
|
+
null,
|
|
57
|
+
react_1.default.createElement(
|
|
58
|
+
"strong",
|
|
59
|
+
null,
|
|
60
|
+
"Response Headers"
|
|
61
|
+
)
|
|
62
|
+
),
|
|
63
|
+
},
|
|
64
|
+
react_1.default.createElement(
|
|
65
|
+
ResponseExamples_1.ResponseHeaders,
|
|
66
|
+
{ responseHeaders: responseHeaders }
|
|
67
|
+
)
|
|
68
|
+
),
|
|
69
|
+
react_1.default.createElement(ResponseSchema_1.default, {
|
|
70
|
+
title: "Schema",
|
|
71
|
+
body: { content: response.content },
|
|
72
|
+
})
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
exports.default = StatusCodes;
|
package/lib/theme/styles.scss
CHANGED
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
--openapi-explorer-padding-input: 0.5rem;
|
|
82
82
|
--openapi-explorer-border-color: var(--ifm-toc-border-color);
|
|
83
83
|
--openapi-explorer-caret-bg: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" viewBox="0 0 24 24"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path></svg>');
|
|
84
|
+
--openapi-skeleton-background: var(--ifm-color-emphasis-100);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
[data-theme="dark"] {
|
|
@@ -163,3 +164,43 @@
|
|
|
163
164
|
.openapi-tabs__heading {
|
|
164
165
|
margin-bottom: 1rem;
|
|
165
166
|
}
|
|
167
|
+
|
|
168
|
+
/* Loading Skeleton */
|
|
169
|
+
@keyframes pulsing {
|
|
170
|
+
0% {
|
|
171
|
+
opacity: 1;
|
|
172
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
173
|
+
}
|
|
174
|
+
50% {
|
|
175
|
+
opacity: 0.6;
|
|
176
|
+
background-color: var(--ifm-toc-border-color);
|
|
177
|
+
}
|
|
178
|
+
100% {
|
|
179
|
+
opacity: 1;
|
|
180
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.openapi-skeleton {
|
|
185
|
+
animation: pulsing 2s infinite ease-in-out;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* Loading Skeleton */
|
|
189
|
+
.openapi-skeleton {
|
|
190
|
+
border-radius: var(--ifm-pre-border-radius);
|
|
191
|
+
background-color: var(--openapi-skeleton-background);
|
|
192
|
+
max-width: 100%;
|
|
193
|
+
margin: 1rem auto;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.openapi-skeleton.sm {
|
|
197
|
+
height: 100px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.openapi-skeleton.md {
|
|
201
|
+
height: 350px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.openapi-skeleton.lg {
|
|
205
|
+
height: 96.5%;
|
|
206
|
+
}
|
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-939",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -39,10 +39,11 @@
|
|
|
39
39
|
"@docusaurus/theme-common": "^3.5.0",
|
|
40
40
|
"@hookform/error-message": "^2.0.1",
|
|
41
41
|
"@reduxjs/toolkit": "^1.7.1",
|
|
42
|
+
"allof-merge": "^0.6.6",
|
|
42
43
|
"clsx": "^1.1.1",
|
|
43
44
|
"copy-text-to-clipboard": "^3.1.0",
|
|
44
45
|
"crypto-js": "^4.1.1",
|
|
45
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
46
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-939",
|
|
46
47
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
47
48
|
"file-saver": "^2.0.5",
|
|
48
49
|
"lodash": "^4.17.20",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"engines": {
|
|
71
72
|
"node": ">=14"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "a5d3c2f5f5615038a44bb175811196f8be913503"
|
|
74
75
|
}
|
|
@@ -436,6 +436,56 @@ body[class="ReactModal__Body--open"] {
|
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
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
|
+
|
|
439
489
|
@media only screen and (min-width: 768px) and (max-width: 996px) {
|
|
440
490
|
.openapi-tabs__code-list {
|
|
441
491
|
justify-content: space-around;
|
|
@@ -20,6 +20,7 @@ import { createPersistanceMiddleware } from "@theme/ApiExplorer/persistanceMiddl
|
|
|
20
20
|
import DocItemLayout from "@theme/ApiItem/Layout";
|
|
21
21
|
import type { Props } from "@theme/DocItem";
|
|
22
22
|
import DocItemMetadata from "@theme/DocItem/Metadata";
|
|
23
|
+
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
23
24
|
import clsx from "clsx";
|
|
24
25
|
import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
25
26
|
import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
@@ -152,7 +153,7 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
152
153
|
<MDXComponent />
|
|
153
154
|
</div>
|
|
154
155
|
<div className="col col--5 openapi-right-panel__container">
|
|
155
|
-
<BrowserOnly fallback={<
|
|
156
|
+
<BrowserOnly fallback={<SkeletonLoader size="lg" />}>
|
|
156
157
|
{() => {
|
|
157
158
|
return <ApiExplorer item={api} infoPath={infoPath} />;
|
|
158
159
|
}}
|
|
@@ -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
|
+
);
|
|
@@ -0,0 +1,88 @@
|
|
|
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, { Suspense } from "react";
|
|
9
|
+
|
|
10
|
+
import BrowserOnly from "@docusaurus/BrowserOnly";
|
|
11
|
+
import Details from "@theme/Details";
|
|
12
|
+
import ParamsItem from "@theme/ParamsItem";
|
|
13
|
+
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
parameters: any[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const ParamsDetailsComponent: React.FC<Props> = ({ parameters }) => {
|
|
20
|
+
const types = ["path", "query", "header", "cookie"];
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
{types.map((type) => {
|
|
25
|
+
const params = parameters?.filter((param: any) => param?.in === type);
|
|
26
|
+
|
|
27
|
+
if (!params || params.length === 0) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const summaryElement = (
|
|
32
|
+
<summary>
|
|
33
|
+
<h3 className="openapi-markdown__details-summary-header-params">
|
|
34
|
+
{`${type.charAt(0).toUpperCase() + type.slice(1)} Parameters`}
|
|
35
|
+
</h3>
|
|
36
|
+
</summary>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Details
|
|
41
|
+
key={type}
|
|
42
|
+
className="openapi-markdown__details"
|
|
43
|
+
style={{ marginBottom: "1rem" }}
|
|
44
|
+
data-collapsed={false}
|
|
45
|
+
open={true}
|
|
46
|
+
summary={summaryElement}
|
|
47
|
+
>
|
|
48
|
+
<ul>
|
|
49
|
+
{params.map((param: any, index: number) => (
|
|
50
|
+
<ParamsItem
|
|
51
|
+
key={index}
|
|
52
|
+
className="paramsItem"
|
|
53
|
+
param={{
|
|
54
|
+
...param,
|
|
55
|
+
enumDescriptions: Object.entries(
|
|
56
|
+
param?.schema?.["x-enumDescriptions"] ??
|
|
57
|
+
param?.schema?.items?.["x-enumDescriptions"] ??
|
|
58
|
+
{}
|
|
59
|
+
),
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
))}
|
|
63
|
+
</ul>
|
|
64
|
+
</Details>
|
|
65
|
+
);
|
|
66
|
+
})}
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const ParamsDetails: React.FC<Props> = (props) => {
|
|
72
|
+
return (
|
|
73
|
+
<BrowserOnly fallback={<SkeletonLoader size="sm" />}>
|
|
74
|
+
{() => {
|
|
75
|
+
const LazyComponent = React.lazy(() =>
|
|
76
|
+
Promise.resolve({ default: ParamsDetailsComponent })
|
|
77
|
+
);
|
|
78
|
+
return (
|
|
79
|
+
<Suspense fallback={null}>
|
|
80
|
+
<LazyComponent {...props} />
|
|
81
|
+
</Suspense>
|
|
82
|
+
);
|
|
83
|
+
}}
|
|
84
|
+
</BrowserOnly>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default ParamsDetails;
|
|
@@ -32,6 +32,7 @@ export interface ExampleObject {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface Props {
|
|
35
|
+
className: string;
|
|
35
36
|
param: {
|
|
36
37
|
description: string;
|
|
37
38
|
example: any;
|
|
@@ -106,7 +107,7 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
106
107
|
));
|
|
107
108
|
|
|
108
109
|
const renderDescription = guard(description, (description) => (
|
|
109
|
-
|
|
110
|
+
<>
|
|
110
111
|
<ReactMarkdown
|
|
111
112
|
children={createDescription(description)}
|
|
112
113
|
components={{
|
|
@@ -123,18 +124,20 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
123
124
|
}}
|
|
124
125
|
rehypePlugins={[rehypeRaw]}
|
|
125
126
|
/>
|
|
126
|
-
|
|
127
|
+
</>
|
|
127
128
|
));
|
|
128
129
|
|
|
129
130
|
const renderEnumDescriptions = guard(
|
|
130
131
|
getEnumDescriptionMarkdown(enumDescriptions),
|
|
131
132
|
(value) => {
|
|
132
133
|
return (
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
<div style={{ marginTop: ".5rem" }}>
|
|
135
|
+
<ReactMarkdown
|
|
136
|
+
rehypePlugins={[rehypeRaw]}
|
|
137
|
+
remarkPlugins={[remarkGfm]}
|
|
138
|
+
children={value}
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
138
141
|
);
|
|
139
142
|
}
|
|
140
143
|
);
|
|
@@ -0,0 +1,164 @@
|
|
|
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, { Suspense } from "react";
|
|
9
|
+
|
|
10
|
+
import BrowserOnly from "@docusaurus/BrowserOnly";
|
|
11
|
+
import Details from "@theme/Details";
|
|
12
|
+
import MimeTabs from "@theme/MimeTabs"; // Assume these components exist
|
|
13
|
+
import SchemaNode from "@theme/Schema";
|
|
14
|
+
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
15
|
+
import TabItem from "@theme/TabItem";
|
|
16
|
+
import { createDescription } from "docusaurus-plugin-openapi-docs/lib/markdown/createDescription";
|
|
17
|
+
import { MediaTypeObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
title: string;
|
|
22
|
+
body: {
|
|
23
|
+
content?: {
|
|
24
|
+
[key: string]: MediaTypeObject;
|
|
25
|
+
};
|
|
26
|
+
description?: string;
|
|
27
|
+
required?: string[] | boolean;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
32
|
+
if (
|
|
33
|
+
body === undefined ||
|
|
34
|
+
body.content === undefined ||
|
|
35
|
+
Object.keys(body).length === 0 ||
|
|
36
|
+
Object.keys(body.content).length === 0
|
|
37
|
+
) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const mimeTypes = Object.keys(body.content);
|
|
42
|
+
|
|
43
|
+
if (mimeTypes.length > 1) {
|
|
44
|
+
return (
|
|
45
|
+
<MimeTabs className="openapi-tabs__mime" schemaType="request">
|
|
46
|
+
{mimeTypes.map((mimeType) => {
|
|
47
|
+
const firstBody = body.content![mimeType].schema;
|
|
48
|
+
if (
|
|
49
|
+
firstBody === undefined ||
|
|
50
|
+
(firstBody.properties &&
|
|
51
|
+
Object.keys(firstBody.properties).length === 0)
|
|
52
|
+
) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return (
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
<TabItem key={mimeType} label={mimeType} value={mimeType}>
|
|
58
|
+
<Details
|
|
59
|
+
className="openapi-markdown__details mime"
|
|
60
|
+
data-collapsed={false}
|
|
61
|
+
open={true}
|
|
62
|
+
style={style}
|
|
63
|
+
summary={
|
|
64
|
+
<>
|
|
65
|
+
<summary>
|
|
66
|
+
<h3 className="openapi-markdown__details-summary-header-body">
|
|
67
|
+
{title}
|
|
68
|
+
{body.required === true && (
|
|
69
|
+
<span className="openapi-schema__required">
|
|
70
|
+
required
|
|
71
|
+
</span>
|
|
72
|
+
)}
|
|
73
|
+
</h3>
|
|
74
|
+
</summary>
|
|
75
|
+
</>
|
|
76
|
+
}
|
|
77
|
+
>
|
|
78
|
+
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
79
|
+
{body.description && (
|
|
80
|
+
<div style={{ marginTop: "1rem", marginBottom: "1rem" }}>
|
|
81
|
+
{createDescription(body.description)}
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
<ul style={{ marginLeft: "1rem" }}>
|
|
86
|
+
<SchemaNode schema={firstBody} schemaType="request" />
|
|
87
|
+
</ul>
|
|
88
|
+
</Details>
|
|
89
|
+
</TabItem>
|
|
90
|
+
);
|
|
91
|
+
})}
|
|
92
|
+
</MimeTabs>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const randomFirstKey = mimeTypes[0];
|
|
97
|
+
const firstBody =
|
|
98
|
+
body.content[randomFirstKey].schema ?? body.content![randomFirstKey];
|
|
99
|
+
|
|
100
|
+
if (firstBody === undefined) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<MimeTabs className="openapi-tabs__mime" schemaType="request">
|
|
106
|
+
{/* @ts-ignore */}
|
|
107
|
+
<TabItem label={randomFirstKey} value={`${randomFirstKey}-schema`}>
|
|
108
|
+
<Details
|
|
109
|
+
className="openapi-markdown__details mime"
|
|
110
|
+
data-collapsed={false}
|
|
111
|
+
open={true}
|
|
112
|
+
style={style}
|
|
113
|
+
summary={
|
|
114
|
+
<>
|
|
115
|
+
<summary>
|
|
116
|
+
<h3 className="openapi-markdown__details-summary-header-body">
|
|
117
|
+
{title}
|
|
118
|
+
{firstBody.type === "array" && (
|
|
119
|
+
<span style={{ opacity: "0.6" }}> array</span>
|
|
120
|
+
)}
|
|
121
|
+
{body.required && (
|
|
122
|
+
<strong className="openapi-schema__required">
|
|
123
|
+
required
|
|
124
|
+
</strong>
|
|
125
|
+
)}
|
|
126
|
+
</h3>
|
|
127
|
+
</summary>
|
|
128
|
+
</>
|
|
129
|
+
}
|
|
130
|
+
>
|
|
131
|
+
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
132
|
+
{body.description && (
|
|
133
|
+
<div style={{ marginTop: "1rem", marginBottom: "1rem" }}>
|
|
134
|
+
{createDescription(body.description)}
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
<ul style={{ marginLeft: "1rem" }}>
|
|
139
|
+
<SchemaNode schema={firstBody} schemaType="request" />
|
|
140
|
+
</ul>
|
|
141
|
+
</Details>
|
|
142
|
+
</TabItem>
|
|
143
|
+
</MimeTabs>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const RequestSchema: React.FC<Props> = (props) => {
|
|
148
|
+
return (
|
|
149
|
+
<BrowserOnly fallback={<SkeletonLoader size="sm" />}>
|
|
150
|
+
{() => {
|
|
151
|
+
const LazyComponent = React.lazy(() =>
|
|
152
|
+
Promise.resolve({ default: RequestSchemaComponent })
|
|
153
|
+
);
|
|
154
|
+
return (
|
|
155
|
+
<Suspense fallback={null}>
|
|
156
|
+
<LazyComponent {...props} />
|
|
157
|
+
</Suspense>
|
|
158
|
+
);
|
|
159
|
+
}}
|
|
160
|
+
</BrowserOnly>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export default RequestSchema;
|