docusaurus-theme-openapi-docs 1.1.3 → 1.1.4
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 +4 -0
- package/lib/theme/ParamsItem/index.js +10 -0
- package/lib/theme/SchemaItem/index.js +8 -0
- package/lib-next/markdown/utils.js +4 -0
- package/lib-next/theme/ParamsItem/index.js +10 -0
- package/lib-next/theme/SchemaItem/index.js +8 -0
- package/package.json +3 -3
- package/src/markdown/utils.ts +5 -2
- package/src/theme/ParamsItem/index.js +10 -0
- package/src/theme/SchemaItem/index.js +8 -0
package/lib/markdown/utils.js
CHANGED
|
@@ -37,6 +37,15 @@ function ParamsItem({
|
|
|
37
37
|
</div>
|
|
38
38
|
));
|
|
39
39
|
|
|
40
|
+
const renderDefaultValue = guard(
|
|
41
|
+
schema.items ? schema.items.default : schema.default,
|
|
42
|
+
(value) => (
|
|
43
|
+
<div>
|
|
44
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
|
|
40
49
|
const renderExample = guard(example, (example) => (
|
|
41
50
|
<div>{`Example: ${example}`}</div>
|
|
42
51
|
));
|
|
@@ -58,6 +67,7 @@ function ParamsItem({
|
|
|
58
67
|
{renderSchemaName}
|
|
59
68
|
{renderSchemaRequired}
|
|
60
69
|
{renderSchema}
|
|
70
|
+
{renderDefaultValue}
|
|
61
71
|
{renderDescription}
|
|
62
72
|
{renderExample}
|
|
63
73
|
{renderExamples}
|
|
@@ -21,6 +21,7 @@ function SchemaItem({
|
|
|
21
21
|
required,
|
|
22
22
|
schemaDescription,
|
|
23
23
|
schemaName,
|
|
24
|
+
defaultValue,
|
|
24
25
|
}) {
|
|
25
26
|
const renderRequired = guard(required, () => (
|
|
26
27
|
<strong className={styles.required}> required</strong>
|
|
@@ -38,12 +39,19 @@ function SchemaItem({
|
|
|
38
39
|
</div>
|
|
39
40
|
));
|
|
40
41
|
|
|
42
|
+
const renderDefaultValue = guard(defaultValue, (value) => (
|
|
43
|
+
<div className={styles.schemaQualifierMessage}>
|
|
44
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
45
|
+
</div>
|
|
46
|
+
));
|
|
47
|
+
|
|
41
48
|
const schemaContent = (
|
|
42
49
|
<div>
|
|
43
50
|
<strong>{name}</strong>
|
|
44
51
|
<span className={styles.schemaName}> {schemaName}</span>
|
|
45
52
|
{renderRequired}
|
|
46
53
|
{renderQualifierMessage}
|
|
54
|
+
{renderDefaultValue}
|
|
47
55
|
{renderSchemaDescription}
|
|
48
56
|
</div>
|
|
49
57
|
);
|
|
@@ -15,6 +15,10 @@ export function create(tag, props) {
|
|
|
15
15
|
return `<${tag}${propString}>${render(children)}</${tag}>`;
|
|
16
16
|
}
|
|
17
17
|
export function guard(value, cb) {
|
|
18
|
+
if (typeof value === "boolean") {
|
|
19
|
+
value = value.toString();
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
if (value) {
|
|
19
23
|
const children = cb(value);
|
|
20
24
|
return render(children);
|
|
@@ -37,6 +37,15 @@ function ParamsItem({
|
|
|
37
37
|
</div>
|
|
38
38
|
));
|
|
39
39
|
|
|
40
|
+
const renderDefaultValue = guard(
|
|
41
|
+
schema.items ? schema.items.default : schema.default,
|
|
42
|
+
(value) => (
|
|
43
|
+
<div>
|
|
44
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
|
|
40
49
|
const renderExample = guard(example, (example) => (
|
|
41
50
|
<div>{`Example: ${example}`}</div>
|
|
42
51
|
));
|
|
@@ -58,6 +67,7 @@ function ParamsItem({
|
|
|
58
67
|
{renderSchemaName}
|
|
59
68
|
{renderSchemaRequired}
|
|
60
69
|
{renderSchema}
|
|
70
|
+
{renderDefaultValue}
|
|
61
71
|
{renderDescription}
|
|
62
72
|
{renderExample}
|
|
63
73
|
{renderExamples}
|
|
@@ -21,6 +21,7 @@ function SchemaItem({
|
|
|
21
21
|
required,
|
|
22
22
|
schemaDescription,
|
|
23
23
|
schemaName,
|
|
24
|
+
defaultValue,
|
|
24
25
|
}) {
|
|
25
26
|
const renderRequired = guard(required, () => (
|
|
26
27
|
<strong className={styles.required}> required</strong>
|
|
@@ -38,12 +39,19 @@ function SchemaItem({
|
|
|
38
39
|
</div>
|
|
39
40
|
));
|
|
40
41
|
|
|
42
|
+
const renderDefaultValue = guard(defaultValue, (value) => (
|
|
43
|
+
<div className={styles.schemaQualifierMessage}>
|
|
44
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
45
|
+
</div>
|
|
46
|
+
));
|
|
47
|
+
|
|
41
48
|
const schemaContent = (
|
|
42
49
|
<div>
|
|
43
50
|
<strong>{name}</strong>
|
|
44
51
|
<span className={styles.schemaName}> {schemaName}</span>
|
|
45
52
|
{renderRequired}
|
|
46
53
|
{renderQualifierMessage}
|
|
54
|
+
{renderDefaultValue}
|
|
47
55
|
{renderSchemaDescription}
|
|
48
56
|
</div>
|
|
49
57
|
);
|
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.4",
|
|
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.4",
|
|
54
54
|
"immer": "^9.0.7",
|
|
55
55
|
"lodash": "^4.17.20",
|
|
56
56
|
"process": "^0.11.10",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "dadb0aa5d3516b3020ff1d94288efd6f136e02ba"
|
|
72
72
|
}
|
package/src/markdown/utils.ts
CHANGED
|
@@ -21,11 +21,14 @@ export function create(tag: string, props: Props): string {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function guard<T>(
|
|
24
|
-
value: T | undefined,
|
|
24
|
+
value: T | undefined | string,
|
|
25
25
|
cb: (value: T) => Children
|
|
26
26
|
): string {
|
|
27
|
+
if (typeof value === "boolean") {
|
|
28
|
+
value = value.toString();
|
|
29
|
+
}
|
|
27
30
|
if (value) {
|
|
28
|
-
const children = cb(value);
|
|
31
|
+
const children = cb(value as T);
|
|
29
32
|
return render(children);
|
|
30
33
|
}
|
|
31
34
|
return "";
|
|
@@ -37,6 +37,15 @@ function ParamsItem({
|
|
|
37
37
|
</div>
|
|
38
38
|
));
|
|
39
39
|
|
|
40
|
+
const renderDefaultValue = guard(
|
|
41
|
+
schema.items ? schema.items.default : schema.default,
|
|
42
|
+
(value) => (
|
|
43
|
+
<div>
|
|
44
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
|
|
40
49
|
const renderExample = guard(example, (example) => (
|
|
41
50
|
<div>{`Example: ${example}`}</div>
|
|
42
51
|
));
|
|
@@ -58,6 +67,7 @@ function ParamsItem({
|
|
|
58
67
|
{renderSchemaName}
|
|
59
68
|
{renderSchemaRequired}
|
|
60
69
|
{renderSchema}
|
|
70
|
+
{renderDefaultValue}
|
|
61
71
|
{renderDescription}
|
|
62
72
|
{renderExample}
|
|
63
73
|
{renderExamples}
|
|
@@ -21,6 +21,7 @@ function SchemaItem({
|
|
|
21
21
|
required,
|
|
22
22
|
schemaDescription,
|
|
23
23
|
schemaName,
|
|
24
|
+
defaultValue,
|
|
24
25
|
}) {
|
|
25
26
|
const renderRequired = guard(required, () => (
|
|
26
27
|
<strong className={styles.required}> required</strong>
|
|
@@ -38,12 +39,19 @@ function SchemaItem({
|
|
|
38
39
|
</div>
|
|
39
40
|
));
|
|
40
41
|
|
|
42
|
+
const renderDefaultValue = guard(defaultValue, (value) => (
|
|
43
|
+
<div className={styles.schemaQualifierMessage}>
|
|
44
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
45
|
+
</div>
|
|
46
|
+
));
|
|
47
|
+
|
|
41
48
|
const schemaContent = (
|
|
42
49
|
<div>
|
|
43
50
|
<strong>{name}</strong>
|
|
44
51
|
<span className={styles.schemaName}> {schemaName}</span>
|
|
45
52
|
{renderRequired}
|
|
46
53
|
{renderQualifierMessage}
|
|
54
|
+
{renderDefaultValue}
|
|
47
55
|
{renderSchemaDescription}
|
|
48
56
|
</div>
|
|
49
57
|
);
|