docusaurus-theme-openapi-docs 0.0.0-704 → 0.0.0-705
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 -4
- package/lib/markdown/utils.test.js +4 -4
- package/lib/theme/ParamsItem/index.js +19 -3
- package/lib/theme/SchemaItem/index.js +1 -1
- package/package.json +3 -3
- package/src/markdown/utils.test.ts +5 -4
- package/src/markdown/utils.ts +4 -4
- package/src/theme/ParamsItem/index.js +19 -3
- package/src/theme/SchemaItem/index.js +1 -1
package/lib/markdown/utils.js
CHANGED
|
@@ -17,11 +17,11 @@ function create(tag, props) {
|
|
|
17
17
|
}
|
|
18
18
|
exports.create = create;
|
|
19
19
|
function guard(value, cb) {
|
|
20
|
-
if (value
|
|
21
|
-
|
|
20
|
+
if (!!value || value === 0) {
|
|
21
|
+
const children = cb(value);
|
|
22
|
+
return render(children);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
return render(children);
|
|
24
|
+
return "";
|
|
25
25
|
}
|
|
26
26
|
exports.guard = guard;
|
|
27
27
|
function render(children) {
|
|
@@ -20,6 +20,10 @@ describe("guard", () => {
|
|
|
20
20
|
});
|
|
21
21
|
expect(actual).toBe("");
|
|
22
22
|
});
|
|
23
|
+
it("should guard false booleans", () => {
|
|
24
|
+
const actual = (0, utils_1.guard)(false, (value) => `${value}`);
|
|
25
|
+
expect(actual).toBe("");
|
|
26
|
+
});
|
|
23
27
|
it("should not guard strings", () => {
|
|
24
28
|
const actual = (0, utils_1.guard)("hello", (value) => value);
|
|
25
29
|
expect(actual).toBe("hello");
|
|
@@ -32,10 +36,6 @@ describe("guard", () => {
|
|
|
32
36
|
const actual = (0, utils_1.guard)(0, (value) => `${value}`);
|
|
33
37
|
expect(actual).toBe("0");
|
|
34
38
|
});
|
|
35
|
-
it("should not guard false booleans", () => {
|
|
36
|
-
const actual = (0, utils_1.guard)(false, (value) => `${value}`);
|
|
37
|
-
expect(actual).toBe("false");
|
|
38
|
-
});
|
|
39
39
|
it("should not guard true booleans", () => {
|
|
40
40
|
const actual = (0, utils_1.guard)(true, (value) => `${value}`);
|
|
41
41
|
expect(actual).toBe("true");
|
|
@@ -11,6 +11,7 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
12
12
|
import TabItem from "@theme/TabItem";
|
|
13
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
+
import clsx from "clsx";
|
|
14
15
|
import { createDescription } from "docusaurus-theme-openapi-docs/lib/markdown/createDescription";
|
|
15
16
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
16
17
|
import {
|
|
@@ -26,8 +27,10 @@ import ReactMarkdown from "react-markdown";
|
|
|
26
27
|
import rehypeRaw from "rehype-raw";
|
|
27
28
|
|
|
28
29
|
function ParamsItem({
|
|
29
|
-
param: { description, example, examples, name, required, schema },
|
|
30
|
+
param: { description, example, examples, name, required, schema, deprecated },
|
|
30
31
|
}) {
|
|
32
|
+
console.log(name, required);
|
|
33
|
+
|
|
31
34
|
if (!schema || !schema?.type) {
|
|
32
35
|
schema = { type: "any" };
|
|
33
36
|
}
|
|
@@ -40,6 +43,10 @@ function ParamsItem({
|
|
|
40
43
|
<span className="openapi-schema__required">required</span>
|
|
41
44
|
));
|
|
42
45
|
|
|
46
|
+
const renderDeprecated = guard(deprecated, () => (
|
|
47
|
+
<span className="openapi-schema__deprecated">deprecated</span>
|
|
48
|
+
));
|
|
49
|
+
|
|
43
50
|
const renderSchema = guard(getQualifierMessage(schema), (message) => (
|
|
44
51
|
<div>
|
|
45
52
|
<ReactMarkdown
|
|
@@ -119,10 +126,19 @@ function ParamsItem({
|
|
|
119
126
|
return (
|
|
120
127
|
<div className="openapi-params__list-item">
|
|
121
128
|
<span className="openapi-schema__container">
|
|
122
|
-
<strong
|
|
129
|
+
<strong
|
|
130
|
+
className={clsx("openapi-schema__property", {
|
|
131
|
+
"openapi-schema__strikethrough": deprecated,
|
|
132
|
+
})}
|
|
133
|
+
>
|
|
134
|
+
{name}
|
|
135
|
+
</strong>
|
|
123
136
|
{renderSchemaName}
|
|
124
|
-
{required &&
|
|
137
|
+
{(required || deprecated) && (
|
|
138
|
+
<span className="openapi-schema__divider"></span>
|
|
139
|
+
)}
|
|
125
140
|
{renderSchemaRequired}
|
|
141
|
+
{renderDeprecated}
|
|
126
142
|
</span>
|
|
127
143
|
{renderSchema}
|
|
128
144
|
{renderDefaultValue}
|
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-705",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"clsx": "^1.1.1",
|
|
44
44
|
"copy-text-to-clipboard": "^3.1.0",
|
|
45
45
|
"crypto-js": "^4.1.1",
|
|
46
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
46
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-705",
|
|
47
47
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
48
48
|
"file-saver": "^2.0.5",
|
|
49
49
|
"lodash": "^4.17.20",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "fc2ef4c67cc1f972e90f3a5fd81300efecc715b9"
|
|
72
72
|
}
|
|
@@ -22,6 +22,11 @@ describe("guard", () => {
|
|
|
22
22
|
expect(actual).toBe("");
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
+
it("should guard false booleans", () => {
|
|
26
|
+
const actual = guard(false, (value) => `${value}`);
|
|
27
|
+
expect(actual).toBe("");
|
|
28
|
+
});
|
|
29
|
+
|
|
25
30
|
it("should not guard strings", () => {
|
|
26
31
|
const actual = guard("hello", (value) => value);
|
|
27
32
|
expect(actual).toBe("hello");
|
|
@@ -37,10 +42,6 @@ describe("guard", () => {
|
|
|
37
42
|
expect(actual).toBe("0");
|
|
38
43
|
});
|
|
39
44
|
|
|
40
|
-
it("should not guard false booleans", () => {
|
|
41
|
-
const actual = guard(false, (value) => `${value}`);
|
|
42
|
-
expect(actual).toBe("false");
|
|
43
|
-
});
|
|
44
45
|
it("should not guard true booleans", () => {
|
|
45
46
|
const actual = guard(true, (value) => `${value}`);
|
|
46
47
|
expect(actual).toBe("true");
|
package/src/markdown/utils.ts
CHANGED
|
@@ -24,11 +24,11 @@ export function guard<T>(
|
|
|
24
24
|
value: T | undefined | string,
|
|
25
25
|
cb: (value: T) => Children
|
|
26
26
|
): string {
|
|
27
|
-
if (value
|
|
28
|
-
|
|
27
|
+
if (!!value || value === 0) {
|
|
28
|
+
const children = cb(value as T);
|
|
29
|
+
return render(children);
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
return render(children);
|
|
31
|
+
return "";
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export function render(children: Children): string {
|
|
@@ -11,6 +11,7 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
12
12
|
import TabItem from "@theme/TabItem";
|
|
13
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
+
import clsx from "clsx";
|
|
14
15
|
import { createDescription } from "docusaurus-theme-openapi-docs/lib/markdown/createDescription";
|
|
15
16
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
16
17
|
import {
|
|
@@ -26,8 +27,10 @@ import ReactMarkdown from "react-markdown";
|
|
|
26
27
|
import rehypeRaw from "rehype-raw";
|
|
27
28
|
|
|
28
29
|
function ParamsItem({
|
|
29
|
-
param: { description, example, examples, name, required, schema },
|
|
30
|
+
param: { description, example, examples, name, required, schema, deprecated },
|
|
30
31
|
}) {
|
|
32
|
+
console.log(name, required);
|
|
33
|
+
|
|
31
34
|
if (!schema || !schema?.type) {
|
|
32
35
|
schema = { type: "any" };
|
|
33
36
|
}
|
|
@@ -40,6 +43,10 @@ function ParamsItem({
|
|
|
40
43
|
<span className="openapi-schema__required">required</span>
|
|
41
44
|
));
|
|
42
45
|
|
|
46
|
+
const renderDeprecated = guard(deprecated, () => (
|
|
47
|
+
<span className="openapi-schema__deprecated">deprecated</span>
|
|
48
|
+
));
|
|
49
|
+
|
|
43
50
|
const renderSchema = guard(getQualifierMessage(schema), (message) => (
|
|
44
51
|
<div>
|
|
45
52
|
<ReactMarkdown
|
|
@@ -119,10 +126,19 @@ function ParamsItem({
|
|
|
119
126
|
return (
|
|
120
127
|
<div className="openapi-params__list-item">
|
|
121
128
|
<span className="openapi-schema__container">
|
|
122
|
-
<strong
|
|
129
|
+
<strong
|
|
130
|
+
className={clsx("openapi-schema__property", {
|
|
131
|
+
"openapi-schema__strikethrough": deprecated,
|
|
132
|
+
})}
|
|
133
|
+
>
|
|
134
|
+
{name}
|
|
135
|
+
</strong>
|
|
123
136
|
{renderSchemaName}
|
|
124
|
-
{required &&
|
|
137
|
+
{(required || deprecated) && (
|
|
138
|
+
<span className="openapi-schema__divider"></span>
|
|
139
|
+
)}
|
|
125
140
|
{renderSchemaRequired}
|
|
141
|
+
{renderDeprecated}
|
|
126
142
|
</span>
|
|
127
143
|
{renderSchema}
|
|
128
144
|
{renderDefaultValue}
|