docusaurus-theme-openapi-docs 0.0.0-558 → 0.0.0-559
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.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.create = create;
|
|
7
7
|
exports.guard = guard;
|
|
8
8
|
exports.render = render;
|
|
9
|
+
exports.toString = toString;
|
|
9
10
|
/* ============================================================================
|
|
10
11
|
* Copyright (c) Palo Alto Networks
|
|
11
12
|
*
|
|
@@ -25,7 +26,7 @@ function create(tag, props) {
|
|
|
25
26
|
return `<${tag}${propString}>${render(children)}</${tag}>`;
|
|
26
27
|
}
|
|
27
28
|
function guard(value, cb) {
|
|
28
|
-
if (value) {
|
|
29
|
+
if (value !== undefined) {
|
|
29
30
|
const children = cb(value);
|
|
30
31
|
return render(children);
|
|
31
32
|
}
|
|
@@ -36,4 +37,20 @@ function render(children) {
|
|
|
36
37
|
return children.filter(c => c !== undefined).join("");
|
|
37
38
|
}
|
|
38
39
|
return children !== null && children !== void 0 ? children : "";
|
|
40
|
+
}
|
|
41
|
+
function toString(value) {
|
|
42
|
+
// Return as-is if already string
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
// Return undefined if null or undefined
|
|
47
|
+
if (value == null) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// Return formatted array if Array
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
return `[${value.join(", ")}]`;
|
|
53
|
+
}
|
|
54
|
+
// Coerce to string in all other cases,
|
|
55
|
+
return value + "";
|
|
39
56
|
}
|
|
@@ -11,7 +11,10 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
12
12
|
import { createDescription } from "docusaurus-theme-openapi-docs/lib/markdown/createDescription";
|
|
13
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
guard,
|
|
16
|
+
toString,
|
|
17
|
+
} from "docusaurus-theme-openapi-docs/lib/markdown/utils";
|
|
15
18
|
import ReactMarkdown from "react-markdown";
|
|
16
19
|
import rehypeRaw from "rehype-raw";
|
|
17
20
|
|
|
@@ -36,6 +39,7 @@ function SchemaItem({
|
|
|
36
39
|
defaultValue = schema.default;
|
|
37
40
|
nullable = schema.nullable;
|
|
38
41
|
}
|
|
42
|
+
|
|
39
43
|
const renderRequired = guard(
|
|
40
44
|
Array.isArray(required) ? required.includes(name) : required,
|
|
41
45
|
() => <strong className={styles.required}> required</strong>
|
|
@@ -79,14 +83,11 @@ function SchemaItem({
|
|
|
79
83
|
</div>
|
|
80
84
|
));
|
|
81
85
|
|
|
82
|
-
const renderDefaultValue = guard(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</div>
|
|
88
|
-
)
|
|
89
|
-
);
|
|
86
|
+
const renderDefaultValue = guard(toString(defaultValue), (value) => (
|
|
87
|
+
<div className={styles.schemaQualifierMessage}>
|
|
88
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
89
|
+
</div>
|
|
90
|
+
));
|
|
90
91
|
|
|
91
92
|
const schemaContent = (
|
|
92
93
|
<div>
|
|
@@ -14,7 +14,7 @@ export function create(tag, props) {
|
|
|
14
14
|
return `<${tag}${propString}>${render(children)}</${tag}>`;
|
|
15
15
|
}
|
|
16
16
|
export function guard(value, cb) {
|
|
17
|
-
if (value) {
|
|
17
|
+
if (value !== undefined) {
|
|
18
18
|
const children = cb(value);
|
|
19
19
|
return render(children);
|
|
20
20
|
}
|
|
@@ -26,3 +26,19 @@ export function render(children) {
|
|
|
26
26
|
}
|
|
27
27
|
return children ?? "";
|
|
28
28
|
}
|
|
29
|
+
export function toString(value) {
|
|
30
|
+
// Return as-is if already string
|
|
31
|
+
if (typeof value === "string") {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
// Return undefined if null or undefined
|
|
35
|
+
if (value == null) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
// Return formatted array if Array
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return `[${value.join(", ")}]`;
|
|
41
|
+
}
|
|
42
|
+
// Coerce to string in all other cases,
|
|
43
|
+
return value + "";
|
|
44
|
+
}
|
|
@@ -11,7 +11,10 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
12
12
|
import { createDescription } from "docusaurus-theme-openapi-docs/lib/markdown/createDescription";
|
|
13
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
guard,
|
|
16
|
+
toString,
|
|
17
|
+
} from "docusaurus-theme-openapi-docs/lib/markdown/utils";
|
|
15
18
|
import ReactMarkdown from "react-markdown";
|
|
16
19
|
import rehypeRaw from "rehype-raw";
|
|
17
20
|
|
|
@@ -36,6 +39,7 @@ function SchemaItem({
|
|
|
36
39
|
defaultValue = schema.default;
|
|
37
40
|
nullable = schema.nullable;
|
|
38
41
|
}
|
|
42
|
+
|
|
39
43
|
const renderRequired = guard(
|
|
40
44
|
Array.isArray(required) ? required.includes(name) : required,
|
|
41
45
|
() => <strong className={styles.required}> required</strong>
|
|
@@ -79,14 +83,11 @@ function SchemaItem({
|
|
|
79
83
|
</div>
|
|
80
84
|
));
|
|
81
85
|
|
|
82
|
-
const renderDefaultValue = guard(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</div>
|
|
88
|
-
)
|
|
89
|
-
);
|
|
86
|
+
const renderDefaultValue = guard(toString(defaultValue), (value) => (
|
|
87
|
+
<div className={styles.schemaQualifierMessage}>
|
|
88
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
89
|
+
</div>
|
|
90
|
+
));
|
|
90
91
|
|
|
91
92
|
const schemaContent = (
|
|
92
93
|
<div>
|
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-559",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"buffer": "^6.0.3",
|
|
52
52
|
"clsx": "^1.1.1",
|
|
53
53
|
"crypto-js": "^4.1.1",
|
|
54
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
54
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-559",
|
|
55
55
|
"file-saver": "^2.0.5",
|
|
56
56
|
"immer": "^9.0.7",
|
|
57
57
|
"lodash": "^4.17.20",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=14"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "b6289a8621a9a388476834d66629a35df98317a8"
|
|
78
78
|
}
|
package/src/markdown/utils.ts
CHANGED
|
@@ -24,7 +24,7 @@ export function guard<T>(
|
|
|
24
24
|
value: T | undefined | string,
|
|
25
25
|
cb: (value: T) => Children
|
|
26
26
|
): string {
|
|
27
|
-
if (value) {
|
|
27
|
+
if (value !== undefined) {
|
|
28
28
|
const children = cb(value as T);
|
|
29
29
|
return render(children);
|
|
30
30
|
}
|
|
@@ -37,3 +37,20 @@ export function render(children: Children): string {
|
|
|
37
37
|
}
|
|
38
38
|
return children ?? "";
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
export function toString(value: any): string | undefined {
|
|
42
|
+
// Return as-is if already string
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
// Return undefined if null or undefined
|
|
47
|
+
if (value == null) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// Return formatted array if Array
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
return `[${value.join(", ")}]`;
|
|
53
|
+
}
|
|
54
|
+
// Coerce to string in all other cases,
|
|
55
|
+
return value + "";
|
|
56
|
+
}
|
|
@@ -11,7 +11,10 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
12
12
|
import { createDescription } from "docusaurus-theme-openapi-docs/lib/markdown/createDescription";
|
|
13
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
guard,
|
|
16
|
+
toString,
|
|
17
|
+
} from "docusaurus-theme-openapi-docs/lib/markdown/utils";
|
|
15
18
|
import ReactMarkdown from "react-markdown";
|
|
16
19
|
import rehypeRaw from "rehype-raw";
|
|
17
20
|
|
|
@@ -36,6 +39,7 @@ function SchemaItem({
|
|
|
36
39
|
defaultValue = schema.default;
|
|
37
40
|
nullable = schema.nullable;
|
|
38
41
|
}
|
|
42
|
+
|
|
39
43
|
const renderRequired = guard(
|
|
40
44
|
Array.isArray(required) ? required.includes(name) : required,
|
|
41
45
|
() => <strong className={styles.required}> required</strong>
|
|
@@ -79,14 +83,11 @@ function SchemaItem({
|
|
|
79
83
|
</div>
|
|
80
84
|
));
|
|
81
85
|
|
|
82
|
-
const renderDefaultValue = guard(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</div>
|
|
88
|
-
)
|
|
89
|
-
);
|
|
86
|
+
const renderDefaultValue = guard(toString(defaultValue), (value) => (
|
|
87
|
+
<div className={styles.schemaQualifierMessage}>
|
|
88
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
89
|
+
</div>
|
|
90
|
+
));
|
|
90
91
|
|
|
91
92
|
const schemaContent = (
|
|
92
93
|
<div>
|