docusaurus-theme-openapi-docs 1.1.6 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/theme/ApiDemoPanel/Body/index.js +11 -1
- package/lib/theme/ApiItem/Layout/styles.module.css +2 -0
- package/lib/theme/ParamsItem/index.js +16 -1
- package/lib/theme/ResponseSamples/index.js +2 -2
- package/lib/theme/SchemaItem/index.js +17 -2
- package/lib-next/theme/ApiDemoPanel/Body/index.js +10 -1
- package/lib-next/theme/ApiItem/Layout/styles.module.css +2 -0
- package/lib-next/theme/ParamsItem/index.js +16 -1
- package/lib-next/theme/ResponseSamples/index.js +2 -2
- package/lib-next/theme/SchemaItem/index.js +17 -2
- package/package.json +5 -4
- package/src/theme/ApiDemoPanel/Body/index.tsx +10 -1
- package/src/theme/ApiItem/Layout/styles.module.css +2 -0
- package/src/theme/ParamsItem/index.js +16 -1
- package/src/theme/ResponseSamples/index.js +2 -2
- package/src/theme/SchemaItem/index.js +17 -2
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _xmlFormatter = _interopRequireDefault(require("xml-formatter"));
|
|
11
|
+
|
|
10
12
|
var _ContentType = _interopRequireDefault(require("../ContentType"));
|
|
11
13
|
|
|
12
14
|
var _FormSelect = _interopRequireDefault(require("../FormSelect"));
|
|
@@ -170,7 +172,15 @@ function Body({
|
|
|
170
172
|
|
|
171
173
|
if (contentType === "application/xml") {
|
|
172
174
|
if (jsonRequestBodyExample) {
|
|
173
|
-
|
|
175
|
+
try {
|
|
176
|
+
exampleBodyString = (0, _xmlFormatter.default)((0, _json2xml.default)(jsonRequestBodyExample, ""), {
|
|
177
|
+
indentation: " ",
|
|
178
|
+
lineSeparator: "\n",
|
|
179
|
+
collapseContent: true
|
|
180
|
+
});
|
|
181
|
+
} catch {
|
|
182
|
+
exampleBodyString = (0, _json2xml.default)(jsonRequestBodyExample);
|
|
183
|
+
}
|
|
174
184
|
}
|
|
175
185
|
|
|
176
186
|
language = "xml";
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import CodeBlock from "@theme/CodeBlock";
|
|
10
11
|
import ReactMarkdown from "react-markdown";
|
|
11
12
|
|
|
12
13
|
import { createDescription } from "../../markdown/createDescription";
|
|
@@ -33,7 +34,21 @@ function ParamsItem({
|
|
|
33
34
|
|
|
34
35
|
const renderDescription = guard(description, (description) => (
|
|
35
36
|
<div>
|
|
36
|
-
<ReactMarkdown
|
|
37
|
+
<ReactMarkdown
|
|
38
|
+
children={createDescription(description)}
|
|
39
|
+
components={{
|
|
40
|
+
pre: "div",
|
|
41
|
+
code({ node, inline, className, children, ...props }) {
|
|
42
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
43
|
+
if (inline) return <code>{children}</code>;
|
|
44
|
+
return !inline && match ? (
|
|
45
|
+
<CodeBlock className={className}>{children}</CodeBlock>
|
|
46
|
+
) : (
|
|
47
|
+
<CodeBlock>{children}</CodeBlock>
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
37
52
|
</div>
|
|
38
53
|
));
|
|
39
54
|
|
|
@@ -11,11 +11,11 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
|
|
12
12
|
import styles from "./styles.module.css";
|
|
13
13
|
|
|
14
|
-
function ResponseSamples({ responseExample }) {
|
|
14
|
+
function ResponseSamples({ responseExample, language }) {
|
|
15
15
|
return (
|
|
16
16
|
<div className={styles.responseSamplesContainer}>
|
|
17
17
|
<CodeBlock
|
|
18
|
-
language="
|
|
18
|
+
language={language ? language : "json"}
|
|
19
19
|
className={styles.responseSamplesCodeBlock}
|
|
20
20
|
>
|
|
21
21
|
{responseExample}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import CodeBlock from "@theme/CodeBlock";
|
|
10
11
|
import ReactMarkdown from "react-markdown";
|
|
11
12
|
|
|
12
13
|
import { createDescription } from "../../markdown/createDescription";
|
|
@@ -29,8 +30,22 @@ function SchemaItem({
|
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
const renderSchemaDescription = guard(schemaDescription, (description) => (
|
|
32
|
-
<div
|
|
33
|
-
<ReactMarkdown
|
|
33
|
+
<div>
|
|
34
|
+
<ReactMarkdown
|
|
35
|
+
children={createDescription(description)}
|
|
36
|
+
components={{
|
|
37
|
+
pre: "div",
|
|
38
|
+
code({ node, inline, className, children, ...props }) {
|
|
39
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
40
|
+
if (inline) return <code>{children}</code>;
|
|
41
|
+
return !inline && match ? (
|
|
42
|
+
<CodeBlock className={className}>{children}</CodeBlock>
|
|
43
|
+
) : (
|
|
44
|
+
<CodeBlock>{children}</CodeBlock>
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
34
49
|
</div>
|
|
35
50
|
));
|
|
36
51
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
import React from "react";
|
|
8
|
+
import format from "xml-formatter";
|
|
8
9
|
import ContentType from "../ContentType";
|
|
9
10
|
import FormSelect from "../FormSelect";
|
|
10
11
|
import { useTypedDispatch, useTypedSelector } from "../hooks";
|
|
@@ -188,7 +189,15 @@ function Body({ requestBodyMetadata, jsonRequestBodyExample }) {
|
|
|
188
189
|
|
|
189
190
|
if (contentType === "application/xml") {
|
|
190
191
|
if (jsonRequestBodyExample) {
|
|
191
|
-
|
|
192
|
+
try {
|
|
193
|
+
exampleBodyString = format(json2xml(jsonRequestBodyExample, ""), {
|
|
194
|
+
indentation: " ",
|
|
195
|
+
lineSeparator: "\n",
|
|
196
|
+
collapseContent: true,
|
|
197
|
+
});
|
|
198
|
+
} catch {
|
|
199
|
+
exampleBodyString = json2xml(jsonRequestBodyExample);
|
|
200
|
+
}
|
|
192
201
|
}
|
|
193
202
|
|
|
194
203
|
language = "xml";
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import CodeBlock from "@theme/CodeBlock";
|
|
10
11
|
import ReactMarkdown from "react-markdown";
|
|
11
12
|
|
|
12
13
|
import { createDescription } from "../../markdown/createDescription";
|
|
@@ -33,7 +34,21 @@ function ParamsItem({
|
|
|
33
34
|
|
|
34
35
|
const renderDescription = guard(description, (description) => (
|
|
35
36
|
<div>
|
|
36
|
-
<ReactMarkdown
|
|
37
|
+
<ReactMarkdown
|
|
38
|
+
children={createDescription(description)}
|
|
39
|
+
components={{
|
|
40
|
+
pre: "div",
|
|
41
|
+
code({ node, inline, className, children, ...props }) {
|
|
42
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
43
|
+
if (inline) return <code>{children}</code>;
|
|
44
|
+
return !inline && match ? (
|
|
45
|
+
<CodeBlock className={className}>{children}</CodeBlock>
|
|
46
|
+
) : (
|
|
47
|
+
<CodeBlock>{children}</CodeBlock>
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
37
52
|
</div>
|
|
38
53
|
));
|
|
39
54
|
|
|
@@ -11,11 +11,11 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
|
|
12
12
|
import styles from "./styles.module.css";
|
|
13
13
|
|
|
14
|
-
function ResponseSamples({ responseExample }) {
|
|
14
|
+
function ResponseSamples({ responseExample, language }) {
|
|
15
15
|
return (
|
|
16
16
|
<div className={styles.responseSamplesContainer}>
|
|
17
17
|
<CodeBlock
|
|
18
|
-
language="
|
|
18
|
+
language={language ? language : "json"}
|
|
19
19
|
className={styles.responseSamplesCodeBlock}
|
|
20
20
|
>
|
|
21
21
|
{responseExample}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import CodeBlock from "@theme/CodeBlock";
|
|
10
11
|
import ReactMarkdown from "react-markdown";
|
|
11
12
|
|
|
12
13
|
import { createDescription } from "../../markdown/createDescription";
|
|
@@ -29,8 +30,22 @@ function SchemaItem({
|
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
const renderSchemaDescription = guard(schemaDescription, (description) => (
|
|
32
|
-
<div
|
|
33
|
-
<ReactMarkdown
|
|
33
|
+
<div>
|
|
34
|
+
<ReactMarkdown
|
|
35
|
+
children={createDescription(description)}
|
|
36
|
+
components={{
|
|
37
|
+
pre: "div",
|
|
38
|
+
code({ node, inline, className, children, ...props }) {
|
|
39
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
40
|
+
if (inline) return <code>{children}</code>;
|
|
41
|
+
return !inline && match ? (
|
|
42
|
+
<CodeBlock className={className}>{children}</CodeBlock>
|
|
43
|
+
) : (
|
|
44
|
+
<CodeBlock>{children}</CodeBlock>
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
34
49
|
</div>
|
|
35
50
|
));
|
|
36
51
|
|
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": "1.1.
|
|
4
|
+
"version": "1.1.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"buffer": "^6.0.3",
|
|
51
51
|
"clsx": "^1.1.1",
|
|
52
52
|
"crypto-js": "^4.1.1",
|
|
53
|
-
"docusaurus-plugin-openapi-docs": "^1.1.
|
|
53
|
+
"docusaurus-plugin-openapi-docs": "^1.1.9",
|
|
54
54
|
"immer": "^9.0.7",
|
|
55
55
|
"lodash": "^4.17.20",
|
|
56
56
|
"process": "^0.11.10",
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"react-markdown": "^8.0.1",
|
|
60
60
|
"react-redux": "^7.2.0",
|
|
61
61
|
"redux-devtools-extension": "^2.13.8",
|
|
62
|
-
"webpack": "^5.61.0"
|
|
62
|
+
"webpack": "^5.61.0",
|
|
63
|
+
"xml-formatter": "^2.6.1"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"engines": {
|
|
69
70
|
"node": ">=14"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "c9153730f9f180dbd199fbc9cb66f8470339c877"
|
|
72
73
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import { RequestBodyObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
11
|
+
import format from "xml-formatter";
|
|
11
12
|
|
|
12
13
|
import ContentType from "../ContentType";
|
|
13
14
|
import FormSelect from "../FormSelect";
|
|
@@ -197,7 +198,15 @@ function Body({ requestBodyMetadata, jsonRequestBodyExample }: Props) {
|
|
|
197
198
|
|
|
198
199
|
if (contentType === "application/xml") {
|
|
199
200
|
if (jsonRequestBodyExample) {
|
|
200
|
-
|
|
201
|
+
try {
|
|
202
|
+
exampleBodyString = format(json2xml(jsonRequestBodyExample, ""), {
|
|
203
|
+
indentation: " ",
|
|
204
|
+
lineSeparator: "\n",
|
|
205
|
+
collapseContent: true,
|
|
206
|
+
});
|
|
207
|
+
} catch {
|
|
208
|
+
exampleBodyString = json2xml(jsonRequestBodyExample);
|
|
209
|
+
}
|
|
201
210
|
}
|
|
202
211
|
language = "xml";
|
|
203
212
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import CodeBlock from "@theme/CodeBlock";
|
|
10
11
|
import ReactMarkdown from "react-markdown";
|
|
11
12
|
|
|
12
13
|
import { createDescription } from "../../markdown/createDescription";
|
|
@@ -33,7 +34,21 @@ function ParamsItem({
|
|
|
33
34
|
|
|
34
35
|
const renderDescription = guard(description, (description) => (
|
|
35
36
|
<div>
|
|
36
|
-
<ReactMarkdown
|
|
37
|
+
<ReactMarkdown
|
|
38
|
+
children={createDescription(description)}
|
|
39
|
+
components={{
|
|
40
|
+
pre: "div",
|
|
41
|
+
code({ node, inline, className, children, ...props }) {
|
|
42
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
43
|
+
if (inline) return <code>{children}</code>;
|
|
44
|
+
return !inline && match ? (
|
|
45
|
+
<CodeBlock className={className}>{children}</CodeBlock>
|
|
46
|
+
) : (
|
|
47
|
+
<CodeBlock>{children}</CodeBlock>
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
37
52
|
</div>
|
|
38
53
|
));
|
|
39
54
|
|
|
@@ -11,11 +11,11 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
|
|
12
12
|
import styles from "./styles.module.css";
|
|
13
13
|
|
|
14
|
-
function ResponseSamples({ responseExample }) {
|
|
14
|
+
function ResponseSamples({ responseExample, language }) {
|
|
15
15
|
return (
|
|
16
16
|
<div className={styles.responseSamplesContainer}>
|
|
17
17
|
<CodeBlock
|
|
18
|
-
language="
|
|
18
|
+
language={language ? language : "json"}
|
|
19
19
|
className={styles.responseSamplesCodeBlock}
|
|
20
20
|
>
|
|
21
21
|
{responseExample}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import CodeBlock from "@theme/CodeBlock";
|
|
10
11
|
import ReactMarkdown from "react-markdown";
|
|
11
12
|
|
|
12
13
|
import { createDescription } from "../../markdown/createDescription";
|
|
@@ -29,8 +30,22 @@ function SchemaItem({
|
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
const renderSchemaDescription = guard(schemaDescription, (description) => (
|
|
32
|
-
<div
|
|
33
|
-
<ReactMarkdown
|
|
33
|
+
<div>
|
|
34
|
+
<ReactMarkdown
|
|
35
|
+
children={createDescription(description)}
|
|
36
|
+
components={{
|
|
37
|
+
pre: "div",
|
|
38
|
+
code({ node, inline, className, children, ...props }) {
|
|
39
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
40
|
+
if (inline) return <code>{children}</code>;
|
|
41
|
+
return !inline && match ? (
|
|
42
|
+
<CodeBlock className={className}>{children}</CodeBlock>
|
|
43
|
+
) : (
|
|
44
|
+
<CodeBlock>{children}</CodeBlock>
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
34
49
|
</div>
|
|
35
50
|
));
|
|
36
51
|
|