docusaurus-theme-openapi-docs 4.2.0 → 4.3.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/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +0 -12
- package/lib/theme/ApiExplorer/Authorization/index.js +3 -0
- package/lib/theme/ApiExplorer/Body/index.js +11 -2
- package/lib/theme/Markdown/Details/_Details.scss +5 -2
- package/lib/theme/Markdown/index.js +160 -18
- package/lib/theme/ParamsItem/index.js +7 -48
- package/lib/theme/RequestSchema/index.js +11 -3
- package/lib/theme/ResponseExamples/index.d.ts +9 -39
- package/lib/theme/ResponseExamples/index.js +3 -99
- package/lib/theme/ResponseHeaders/index.d.ts +13 -0
- package/lib/theme/ResponseHeaders/index.js +39 -0
- package/lib/theme/ResponseSchema/index.js +4 -2
- package/lib/theme/Schema/index.js +29 -21
- package/lib/theme/SchemaItem/index.js +7 -41
- package/lib/theme/StatusCodes/index.js +10 -7
- package/package.json +10 -6
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +0 -12
- package/src/theme/ApiExplorer/Authorization/index.tsx +3 -0
- package/src/theme/ApiExplorer/Body/index.tsx +3 -2
- package/src/theme/Markdown/Details/_Details.scss +5 -2
- package/src/theme/Markdown/index.js +160 -18
- package/src/theme/ParamsItem/index.tsx +6 -36
- package/src/theme/RequestSchema/index.tsx +3 -3
- package/src/theme/ResponseExamples/index.tsx +24 -122
- package/src/theme/ResponseHeaders/index.tsx +49 -0
- package/src/theme/ResponseSchema/index.tsx +2 -2
- package/src/theme/Schema/index.tsx +29 -22
- package/src/theme/SchemaItem/index.tsx +11 -35
- package/src/theme/StatusCodes/index.tsx +3 -3
|
@@ -8,13 +8,6 @@ the background in custom CSS file due bug https://github.com/facebook/docusaurus
|
|
|
8
8
|
--docusaurus-highlighted-code-line-bg: rgb(100 100 100);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.theme-code-block-highlighted-line {
|
|
12
|
-
background-color: var(--docusaurus-highlighted-code-line-bg);
|
|
13
|
-
display: block;
|
|
14
|
-
margin: 0 calc(-1 * var(--ifm-pre-padding));
|
|
15
|
-
padding: 0 var(--ifm-pre-padding);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
11
|
.openapi-explorer__code-block-code-line {
|
|
19
12
|
display: table-row;
|
|
20
13
|
counter-increment: line-count;
|
|
@@ -36,11 +29,6 @@ the background in custom CSS file due bug https://github.com/facebook/docusaurus
|
|
|
36
29
|
opacity: 0.4;
|
|
37
30
|
}
|
|
38
31
|
|
|
39
|
-
:global(.theme-code-block-highlighted-line)
|
|
40
|
-
.openapi-explorer__code-block-code-line-number::before {
|
|
41
|
-
opacity: 0.8;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
32
|
.openapi-explorer__code-block-code-line-number {
|
|
45
33
|
padding-right: var(--ifm-pre-padding);
|
|
46
34
|
}
|
|
@@ -53,6 +53,7 @@ function Authorization() {
|
|
|
53
53
|
{ label: "Bearer Token", key: a.key + "-bearer" },
|
|
54
54
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
55
55
|
placeholder: "Bearer Token",
|
|
56
|
+
password: true,
|
|
56
57
|
value: data[a.key].token ?? "",
|
|
57
58
|
onChange: (e) => {
|
|
58
59
|
const value = e.target.value;
|
|
@@ -73,6 +74,7 @@ function Authorization() {
|
|
|
73
74
|
{ label: "Bearer Token", key: a.key + "-oauth2" },
|
|
74
75
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
75
76
|
placeholder: "Bearer Token",
|
|
77
|
+
password: true,
|
|
76
78
|
value: data[a.key].token ?? "",
|
|
77
79
|
onChange: (e) => {
|
|
78
80
|
const value = e.target.value;
|
|
@@ -136,6 +138,7 @@ function Authorization() {
|
|
|
136
138
|
{ label: `${a.key}`, key: a.key + "-apikey" },
|
|
137
139
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
138
140
|
placeholder: `${a.key}`,
|
|
141
|
+
password: true,
|
|
139
142
|
value: data[a.key].apiKey ?? "",
|
|
140
143
|
onChange: (e) => {
|
|
141
144
|
const value = e.target.value;
|
|
@@ -23,6 +23,7 @@ const FormTextInput_1 = __importDefault(
|
|
|
23
23
|
);
|
|
24
24
|
const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
|
|
25
25
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
26
|
+
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
26
27
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
27
28
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
28
29
|
const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
@@ -297,7 +298,11 @@ function Body({
|
|
|
297
298
|
TabItem_1.default,
|
|
298
299
|
{ label: "Example", value: "example" },
|
|
299
300
|
example.summary &&
|
|
300
|
-
react_1.default.createElement(
|
|
301
|
+
react_1.default.createElement(
|
|
302
|
+
Markdown_1.default,
|
|
303
|
+
null,
|
|
304
|
+
example.summary
|
|
305
|
+
),
|
|
301
306
|
exampleBody &&
|
|
302
307
|
react_1.default.createElement(
|
|
303
308
|
LiveEditor_1.default,
|
|
@@ -339,7 +344,11 @@ function Body({
|
|
|
339
344
|
key: example.label,
|
|
340
345
|
},
|
|
341
346
|
example.summary &&
|
|
342
|
-
react_1.default.createElement(
|
|
347
|
+
react_1.default.createElement(
|
|
348
|
+
Markdown_1.default,
|
|
349
|
+
null,
|
|
350
|
+
example.summary
|
|
351
|
+
),
|
|
343
352
|
example.body &&
|
|
344
353
|
react_1.default.createElement(
|
|
345
354
|
LiveEditor_1.default,
|
|
@@ -23,10 +23,13 @@
|
|
|
23
23
|
|
|
24
24
|
/* Top-Level Details Caret Styling */
|
|
25
25
|
.openapi-left-panel__container > .openapi-markdown__details > summary::before,
|
|
26
|
-
.openapi-markdown__details.mime > summary::before
|
|
27
|
-
.openapi-markdown__details.response > summary::before {
|
|
26
|
+
.openapi-markdown__details.mime > summary::before {
|
|
28
27
|
top: 0.1rem;
|
|
29
28
|
}
|
|
29
|
+
|
|
30
|
+
.openapi-markdown__details.response > summary::before {
|
|
31
|
+
top: 0.25rem; /* TODO: figure out why this is necessary */
|
|
32
|
+
}
|
|
30
33
|
/* End of Top-Level Details Caret Styling */
|
|
31
34
|
|
|
32
35
|
.openapi-markdown__details {
|
|
@@ -7,30 +7,172 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import Admonition from "@theme/Admonition";
|
|
10
11
|
import CodeBlock from "@theme/CodeBlock";
|
|
11
12
|
import ReactMarkdown from "react-markdown";
|
|
12
13
|
import rehypeRaw from "rehype-raw";
|
|
14
|
+
import remarkGfm from "remark-gfm";
|
|
15
|
+
|
|
16
|
+
function remarkAdmonition() {
|
|
17
|
+
return (tree) => {
|
|
18
|
+
const openingTagRegex = /^:::(\w+)(?:\[(.*?)\])?\s*$/;
|
|
19
|
+
const closingTagRegex = /^:::\s*$/;
|
|
20
|
+
const textOnlyAdmonition = /^:::(\w+)(?:\[(.*?)\])?\s*([\s\S]*?)\s*:::$/;
|
|
21
|
+
|
|
22
|
+
const nodes = [];
|
|
23
|
+
let bufferedChildren = [];
|
|
24
|
+
|
|
25
|
+
let insideAdmonition = false;
|
|
26
|
+
let type = null;
|
|
27
|
+
let title = null;
|
|
28
|
+
|
|
29
|
+
tree.children.forEach((node) => {
|
|
30
|
+
if (
|
|
31
|
+
node.type === "paragraph" &&
|
|
32
|
+
node.children.length === 1 &&
|
|
33
|
+
node.children[0].type === "text"
|
|
34
|
+
) {
|
|
35
|
+
const text = node.children[0].value.trim();
|
|
36
|
+
const openingMatch = text.match(openingTagRegex);
|
|
37
|
+
const closingMatch = text.match(closingTagRegex);
|
|
38
|
+
const textOnlyAdmonitionMatch = text.match(textOnlyAdmonition);
|
|
39
|
+
|
|
40
|
+
if (textOnlyAdmonitionMatch) {
|
|
41
|
+
const type = textOnlyAdmonitionMatch[1];
|
|
42
|
+
const title = textOnlyAdmonitionMatch[2]
|
|
43
|
+
? textOnlyAdmonitionMatch[2]?.trim()
|
|
44
|
+
: undefined;
|
|
45
|
+
const content = textOnlyAdmonitionMatch[3];
|
|
46
|
+
|
|
47
|
+
const admonitionNode = {
|
|
48
|
+
type: "admonition",
|
|
49
|
+
data: {
|
|
50
|
+
hName: "Admonition", // Tells ReactMarkdown to replace the node with Admonition component
|
|
51
|
+
hProperties: {
|
|
52
|
+
type, // Passed as a prop to the Admonition component
|
|
53
|
+
title,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
children: [
|
|
57
|
+
{
|
|
58
|
+
type: "text",
|
|
59
|
+
value: content?.trim(), // Trim leading/trailing whitespace
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
nodes.push(admonitionNode);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (openingMatch) {
|
|
68
|
+
type = openingMatch[1];
|
|
69
|
+
title = openingMatch[2] || type;
|
|
70
|
+
insideAdmonition = true;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (closingMatch && insideAdmonition) {
|
|
75
|
+
nodes.push({
|
|
76
|
+
type: "admonition",
|
|
77
|
+
data: {
|
|
78
|
+
hName: "Admonition",
|
|
79
|
+
hProperties: { type: type, title: title },
|
|
80
|
+
},
|
|
81
|
+
children: bufferedChildren,
|
|
82
|
+
});
|
|
83
|
+
bufferedChildren = [];
|
|
84
|
+
insideAdmonition = false;
|
|
85
|
+
type = null;
|
|
86
|
+
title = null;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (insideAdmonition) {
|
|
92
|
+
bufferedChildren.push(node);
|
|
93
|
+
} else {
|
|
94
|
+
nodes.push(node);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (bufferedChildren.length > 0 && type) {
|
|
99
|
+
nodes.push({
|
|
100
|
+
type: "admonition",
|
|
101
|
+
data: {
|
|
102
|
+
hName: "Admonition",
|
|
103
|
+
hProperties: { type: type, title: title },
|
|
104
|
+
},
|
|
105
|
+
children: bufferedChildren,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
tree.children = nodes;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function convertAstToHtmlStr(ast) {
|
|
113
|
+
if (!ast || !Array.isArray(ast)) {
|
|
114
|
+
return "";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const convertNode = (node) => {
|
|
118
|
+
switch (node.type) {
|
|
119
|
+
case "text":
|
|
120
|
+
return node.value;
|
|
121
|
+
case "element":
|
|
122
|
+
const { tagName, properties, children } = node;
|
|
123
|
+
|
|
124
|
+
// Convert attributes to a string
|
|
125
|
+
const attrs = properties
|
|
126
|
+
? Object.entries(properties)
|
|
127
|
+
.map(([key, value]) => `${key}="${value}"`)
|
|
128
|
+
.join(" ")
|
|
129
|
+
: "";
|
|
130
|
+
|
|
131
|
+
// Convert children to HTML
|
|
132
|
+
const childrenHtml = children ? children.map(convertNode).join("") : "";
|
|
133
|
+
|
|
134
|
+
return `<${tagName} ${attrs}>${childrenHtml}</${tagName}>`;
|
|
135
|
+
default:
|
|
136
|
+
return "";
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return ast.map(convertNode).join("");
|
|
141
|
+
}
|
|
13
142
|
|
|
14
143
|
function Markdown({ children }) {
|
|
15
144
|
return (
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
145
|
+
<ReactMarkdown
|
|
146
|
+
rehypePlugins={[rehypeRaw]}
|
|
147
|
+
remarkPlugins={[remarkGfm, remarkAdmonition]}
|
|
148
|
+
components={{
|
|
149
|
+
pre: (props) => <div {...props} />,
|
|
150
|
+
code({ node, inline, className, children, ...props }) {
|
|
151
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
152
|
+
return match ? (
|
|
153
|
+
<CodeBlock className={className} language={match[1]} {...props}>
|
|
154
|
+
{children}
|
|
155
|
+
</CodeBlock>
|
|
156
|
+
) : (
|
|
157
|
+
<code className={className} {...props}>
|
|
158
|
+
{children}
|
|
159
|
+
</code>
|
|
160
|
+
);
|
|
161
|
+
},
|
|
162
|
+
admonition: ({ node, ...props }) => {
|
|
163
|
+
const type = node.data?.hProperties?.type || "note";
|
|
164
|
+
const title = node.data?.hProperties?.title || type;
|
|
165
|
+
const content = convertAstToHtmlStr(node.children);
|
|
166
|
+
return (
|
|
167
|
+
<Admonition type={type} title={title} {...props}>
|
|
168
|
+
<div dangerouslySetInnerHTML={{ __html: content }} />
|
|
169
|
+
</Admonition>
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
{children}
|
|
175
|
+
</ReactMarkdown>
|
|
34
176
|
);
|
|
35
177
|
}
|
|
36
178
|
|
|
@@ -12,15 +12,11 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
-
const
|
|
15
|
+
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
16
16
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
17
17
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
18
18
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
19
19
|
const clsx_1 = __importDefault(require("clsx"));
|
|
20
|
-
const react_markdown_1 = __importDefault(require("react-markdown"));
|
|
21
|
-
const rehype_raw_1 = __importDefault(require("rehype-raw"));
|
|
22
|
-
const remark_gfm_1 = __importDefault(require("remark-gfm"));
|
|
23
|
-
const createDescription_1 = require("../../markdown/createDescription");
|
|
24
20
|
const schema_1 = require("../../markdown/schema");
|
|
25
21
|
const utils_1 = require("../../markdown/utils");
|
|
26
22
|
const getEnumDescriptionMarkdown = (enumDescriptions) => {
|
|
@@ -80,46 +76,13 @@ function ParamsItem({ param, ...rest }) {
|
|
|
80
76
|
"deprecated"
|
|
81
77
|
)
|
|
82
78
|
);
|
|
83
|
-
const
|
|
79
|
+
const renderQualifier = (0, utils_1.guard)(
|
|
84
80
|
(0, schema_1.getQualifierMessage)(schema),
|
|
85
|
-
(
|
|
86
|
-
react_1.default.createElement(
|
|
87
|
-
"div",
|
|
88
|
-
null,
|
|
89
|
-
react_1.default.createElement(react_markdown_1.default, {
|
|
90
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
91
|
-
rehypePlugins: [rehype_raw_1.default],
|
|
92
|
-
})
|
|
93
|
-
)
|
|
81
|
+
(qualifier) =>
|
|
82
|
+
react_1.default.createElement(Markdown_1.default, null, qualifier)
|
|
94
83
|
);
|
|
95
84
|
const renderDescription = (0, utils_1.guard)(description, (description) =>
|
|
96
|
-
react_1.default.createElement(
|
|
97
|
-
react_1.default.Fragment,
|
|
98
|
-
null,
|
|
99
|
-
react_1.default.createElement(react_markdown_1.default, {
|
|
100
|
-
children: (0, createDescription_1.createDescription)(description),
|
|
101
|
-
components: {
|
|
102
|
-
pre: "div",
|
|
103
|
-
code({ node, inline, className, children, ...props }) {
|
|
104
|
-
const match = /language-(\w+)/.exec(className || "");
|
|
105
|
-
if (inline)
|
|
106
|
-
return react_1.default.createElement("code", null, children);
|
|
107
|
-
return !inline && match
|
|
108
|
-
? react_1.default.createElement(
|
|
109
|
-
CodeBlock_1.default,
|
|
110
|
-
{ className: className },
|
|
111
|
-
children
|
|
112
|
-
)
|
|
113
|
-
: react_1.default.createElement(
|
|
114
|
-
CodeBlock_1.default,
|
|
115
|
-
null,
|
|
116
|
-
children
|
|
117
|
-
);
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
rehypePlugins: [rehype_raw_1.default],
|
|
121
|
-
})
|
|
122
|
-
)
|
|
85
|
+
react_1.default.createElement(Markdown_1.default, null, description)
|
|
123
86
|
);
|
|
124
87
|
const renderEnumDescriptions = (0, utils_1.guard)(
|
|
125
88
|
getEnumDescriptionMarkdown(enumDescriptions),
|
|
@@ -127,11 +90,7 @@ function ParamsItem({ param, ...rest }) {
|
|
|
127
90
|
return react_1.default.createElement(
|
|
128
91
|
"div",
|
|
129
92
|
{ style: { marginTop: ".5rem" } },
|
|
130
|
-
react_1.default.createElement(
|
|
131
|
-
rehypePlugins: [rehype_raw_1.default],
|
|
132
|
-
remarkPlugins: [remark_gfm_1.default],
|
|
133
|
-
children: value,
|
|
134
|
-
})
|
|
93
|
+
react_1.default.createElement(Markdown_1.default, null, value)
|
|
135
94
|
);
|
|
136
95
|
}
|
|
137
96
|
);
|
|
@@ -245,7 +204,7 @@ function ParamsItem({ param, ...rest }) {
|
|
|
245
204
|
renderSchemaRequired,
|
|
246
205
|
renderDeprecated
|
|
247
206
|
),
|
|
248
|
-
|
|
207
|
+
renderQualifier,
|
|
249
208
|
renderDescription,
|
|
250
209
|
renderEnumDescriptions,
|
|
251
210
|
renderDefaultValue(),
|
|
@@ -58,11 +58,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
58
58
|
const react_1 = __importStar(require("react"));
|
|
59
59
|
const BrowserOnly_1 = __importDefault(require("@docusaurus/BrowserOnly"));
|
|
60
60
|
const Details_1 = __importDefault(require("@theme/Details"));
|
|
61
|
+
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
61
62
|
const MimeTabs_1 = __importDefault(require("@theme/MimeTabs")); // Assume these components exist
|
|
62
63
|
const Schema_1 = __importDefault(require("@theme/Schema"));
|
|
63
64
|
const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
|
|
64
65
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
65
|
-
const createDescription_1 = require("docusaurus-plugin-openapi-docs/lib/markdown/createDescription");
|
|
66
66
|
const RequestSchemaComponent = ({ title, body, style }) => {
|
|
67
67
|
if (
|
|
68
68
|
body === undefined ||
|
|
@@ -128,7 +128,11 @@ const RequestSchemaComponent = ({ title, body, style }) => {
|
|
|
128
128
|
react_1.default.createElement(
|
|
129
129
|
"div",
|
|
130
130
|
{ style: { marginTop: "1rem", marginBottom: "1rem" } },
|
|
131
|
-
|
|
131
|
+
react_1.default.createElement(
|
|
132
|
+
Markdown_1.default,
|
|
133
|
+
null,
|
|
134
|
+
body.description
|
|
135
|
+
)
|
|
132
136
|
)
|
|
133
137
|
),
|
|
134
138
|
react_1.default.createElement(
|
|
@@ -197,7 +201,11 @@ const RequestSchemaComponent = ({ title, body, style }) => {
|
|
|
197
201
|
react_1.default.createElement(
|
|
198
202
|
"div",
|
|
199
203
|
{ style: { marginTop: "1rem", marginBottom: "1rem" } },
|
|
200
|
-
|
|
204
|
+
react_1.default.createElement(
|
|
205
|
+
Markdown_1.default,
|
|
206
|
+
null,
|
|
207
|
+
body.description
|
|
208
|
+
)
|
|
201
209
|
)
|
|
202
210
|
),
|
|
203
211
|
react_1.default.createElement(
|
|
@@ -1,48 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export declare function json2xml(o: Record<string, any>, tab: string): string;
|
|
3
|
-
interface
|
|
4
|
-
in: string;
|
|
5
|
-
name: string;
|
|
6
|
-
schema?: {
|
|
7
|
-
type?: string;
|
|
8
|
-
items?: Record<string, any>;
|
|
9
|
-
};
|
|
10
|
-
enumDescriptions?: [string, string][];
|
|
11
|
-
}
|
|
12
|
-
interface ResponseHeaderProps {
|
|
13
|
-
description?: string;
|
|
14
|
-
example?: string;
|
|
15
|
-
schema?: {
|
|
16
|
-
type?: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
interface ResponseExampleProps {
|
|
20
|
-
value: any;
|
|
21
|
-
summary?: string;
|
|
22
|
-
}
|
|
23
|
-
interface Props {
|
|
24
|
-
parameters?: ParameterProps[];
|
|
25
|
-
type: string;
|
|
26
|
-
responseHeaders?: Record<string, ResponseHeaderProps>;
|
|
27
|
-
responseExamples?: Record<string, ResponseExampleProps>;
|
|
28
|
-
responseExample?: any;
|
|
29
|
-
schema?: any;
|
|
30
|
-
mimeType: string;
|
|
31
|
-
}
|
|
32
|
-
export declare const ParamsDetails: React.FC<Props>;
|
|
33
|
-
export declare const ResponseHeaders: React.FC<{
|
|
34
|
-
responseHeaders?: Record<string, ResponseHeaderProps>;
|
|
35
|
-
}>;
|
|
36
|
-
export declare const ResponseExamples: React.FC<{
|
|
3
|
+
interface ResponseExamplesProps {
|
|
37
4
|
responseExamples: any;
|
|
38
5
|
mimeType: string;
|
|
39
|
-
}
|
|
40
|
-
export declare const
|
|
6
|
+
}
|
|
7
|
+
export declare const ResponseExamples: React.FC<ResponseExamplesProps>;
|
|
8
|
+
interface ResponseExampleProps {
|
|
41
9
|
responseExample: any;
|
|
42
10
|
mimeType: string;
|
|
43
|
-
}
|
|
44
|
-
export declare const
|
|
11
|
+
}
|
|
12
|
+
export declare const ResponseExample: React.FC<ResponseExampleProps>;
|
|
13
|
+
interface ExampleFromSchemaProps {
|
|
45
14
|
schema: any;
|
|
46
15
|
mimeType: string;
|
|
47
|
-
}
|
|
16
|
+
}
|
|
17
|
+
export declare const ExampleFromSchema: React.FC<ExampleFromSchemaProps>;
|
|
48
18
|
export {};
|
|
@@ -14,18 +14,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.ExampleFromSchema =
|
|
15
15
|
exports.ResponseExample =
|
|
16
16
|
exports.ResponseExamples =
|
|
17
|
-
exports.ResponseHeaders =
|
|
18
|
-
exports.ParamsDetails =
|
|
19
17
|
exports.json2xml =
|
|
20
18
|
void 0;
|
|
21
19
|
const react_1 = __importDefault(require("react"));
|
|
22
|
-
const
|
|
20
|
+
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
23
21
|
const ResponseSamples_1 = __importDefault(require("@theme/ResponseSamples"));
|
|
24
22
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
25
|
-
const createDescription_1 = require("docusaurus-plugin-openapi-docs/lib/markdown/createDescription");
|
|
26
23
|
const createResponseExample_1 = require("docusaurus-plugin-openapi-docs/lib/openapi/createResponseExample");
|
|
27
24
|
const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
28
|
-
// Utility function
|
|
29
25
|
function json2xml(o, tab) {
|
|
30
26
|
const toXml = (v, name, ind) => {
|
|
31
27
|
let xml = "";
|
|
@@ -63,98 +59,6 @@ function json2xml(o, tab) {
|
|
|
63
59
|
return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
|
|
64
60
|
}
|
|
65
61
|
exports.json2xml = json2xml;
|
|
66
|
-
// React components
|
|
67
|
-
const ParamsDetails = ({ parameters, type }) => {
|
|
68
|
-
const params = parameters?.filter((param) => param?.in === type);
|
|
69
|
-
if (!params || params.length === 0) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
return react_1.default.createElement(
|
|
73
|
-
"details",
|
|
74
|
-
{
|
|
75
|
-
className: "openapi-markdown__details",
|
|
76
|
-
"data-collapsed": false,
|
|
77
|
-
open: true,
|
|
78
|
-
style: { marginBottom: "1rem" },
|
|
79
|
-
},
|
|
80
|
-
react_1.default.createElement(
|
|
81
|
-
"summary",
|
|
82
|
-
null,
|
|
83
|
-
react_1.default.createElement(
|
|
84
|
-
"h3",
|
|
85
|
-
{ className: "openapi-markdown__details-summary-header-params" },
|
|
86
|
-
`${type.charAt(0).toUpperCase() + type.slice(1)} Parameters`
|
|
87
|
-
)
|
|
88
|
-
),
|
|
89
|
-
react_1.default.createElement(
|
|
90
|
-
"div",
|
|
91
|
-
null,
|
|
92
|
-
react_1.default.createElement(
|
|
93
|
-
"ul",
|
|
94
|
-
null,
|
|
95
|
-
params.map((param, index) =>
|
|
96
|
-
react_1.default.createElement(ParamsItem_1.default, {
|
|
97
|
-
key: index,
|
|
98
|
-
className: "paramsItem",
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
param: {
|
|
101
|
-
...param,
|
|
102
|
-
enumDescriptions: Object.entries(
|
|
103
|
-
param?.schema?.items?.["x-enumDescriptions"] ?? {}
|
|
104
|
-
),
|
|
105
|
-
},
|
|
106
|
-
})
|
|
107
|
-
)
|
|
108
|
-
)
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
exports.ParamsDetails = ParamsDetails;
|
|
113
|
-
const ResponseHeaders = ({ responseHeaders }) => {
|
|
114
|
-
if (!responseHeaders) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
return react_1.default.createElement(
|
|
118
|
-
"ul",
|
|
119
|
-
{ style: { marginLeft: "1rem" } },
|
|
120
|
-
Object.entries(responseHeaders).map(([headerName, headerObj]) => {
|
|
121
|
-
const { description, example, schema } = headerObj;
|
|
122
|
-
const type = schema?.type ?? "any";
|
|
123
|
-
return react_1.default.createElement(
|
|
124
|
-
"li",
|
|
125
|
-
{ className: "schemaItem", key: headerName },
|
|
126
|
-
react_1.default.createElement(
|
|
127
|
-
"details",
|
|
128
|
-
null,
|
|
129
|
-
react_1.default.createElement(
|
|
130
|
-
"summary",
|
|
131
|
-
null,
|
|
132
|
-
react_1.default.createElement("strong", null, headerName),
|
|
133
|
-
type &&
|
|
134
|
-
react_1.default.createElement(
|
|
135
|
-
"span",
|
|
136
|
-
{ style: { opacity: "0.6" } },
|
|
137
|
-
" ",
|
|
138
|
-
type
|
|
139
|
-
)
|
|
140
|
-
),
|
|
141
|
-
react_1.default.createElement(
|
|
142
|
-
"div",
|
|
143
|
-
null,
|
|
144
|
-
description &&
|
|
145
|
-
react_1.default.createElement(
|
|
146
|
-
"div",
|
|
147
|
-
{ style: { marginTop: ".5rem", marginBottom: ".5rem" } },
|
|
148
|
-
example && `Example: ${example}`,
|
|
149
|
-
(0, createDescription_1.createDescription)(description)
|
|
150
|
-
)
|
|
151
|
-
)
|
|
152
|
-
)
|
|
153
|
-
);
|
|
154
|
-
})
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
exports.ResponseHeaders = ResponseHeaders;
|
|
158
62
|
const ResponseExamples = ({ responseExamples, mimeType }) => {
|
|
159
63
|
let language = "shell";
|
|
160
64
|
if (mimeType.endsWith("json")) language = "json";
|
|
@@ -173,7 +77,7 @@ const ResponseExamples = ({ responseExamples, mimeType }) => {
|
|
|
173
77
|
{ label: exampleName, value: exampleName, key: exampleName },
|
|
174
78
|
exampleValue.summary &&
|
|
175
79
|
react_1.default.createElement(
|
|
176
|
-
|
|
80
|
+
Markdown_1.default,
|
|
177
81
|
{ className: "openapi-example__summary" },
|
|
178
82
|
exampleValue.summary
|
|
179
83
|
),
|
|
@@ -207,7 +111,7 @@ const ResponseExample = ({ responseExample, mimeType }) => {
|
|
|
207
111
|
{ label: "Example", value: "Example" },
|
|
208
112
|
responseExample.summary &&
|
|
209
113
|
react_1.default.createElement(
|
|
210
|
-
|
|
114
|
+
Markdown_1.default,
|
|
211
115
|
{ className: "openapi-example__summary" },
|
|
212
116
|
responseExample.summary
|
|
213
117
|
),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ResponseHeadersProps {
|
|
3
|
+
description?: string;
|
|
4
|
+
example?: string;
|
|
5
|
+
schema?: {
|
|
6
|
+
type?: string;
|
|
7
|
+
format?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const ResponseHeaders: React.FC<{
|
|
11
|
+
responseHeaders?: Record<string, ResponseHeadersProps>;
|
|
12
|
+
}>;
|
|
13
|
+
export default ResponseHeaders;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
exports.ResponseHeaders = void 0;
|
|
15
|
+
const react_1 = __importDefault(require("react"));
|
|
16
|
+
const SchemaItem_1 = __importDefault(require("@theme/SchemaItem"));
|
|
17
|
+
const schema_1 = require("../../markdown/schema");
|
|
18
|
+
const ResponseHeaders = ({ responseHeaders }) => {
|
|
19
|
+
if (!responseHeaders) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return react_1.default.createElement(
|
|
23
|
+
"ul",
|
|
24
|
+
{ style: { marginLeft: "1rem" } },
|
|
25
|
+
Object.entries(responseHeaders).map(([name, schema]) => {
|
|
26
|
+
return react_1.default.createElement(SchemaItem_1.default, {
|
|
27
|
+
name: name,
|
|
28
|
+
collapsible: false,
|
|
29
|
+
schemaName: (0, schema_1.getSchemaName)(schema),
|
|
30
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
31
|
+
schema: schema,
|
|
32
|
+
discriminator: false,
|
|
33
|
+
children: null,
|
|
34
|
+
});
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
exports.ResponseHeaders = ResponseHeaders;
|
|
39
|
+
exports.default = exports.ResponseHeaders;
|