docusaurus-plugin-openapi-docs 2.0.0 → 3.0.0-beta.1
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/createContactInfo.js +2 -11
- package/lib/markdown/createDescription.js +2 -1
- package/lib/markdown/createHeading.js +3 -1
- package/lib/markdown/utils.js +6 -3
- package/package.json +6 -6
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +1 -1
- package/src/markdown/createContactInfo.ts +2 -13
- package/src/markdown/createDescription.ts +3 -2
- package/src/markdown/createHeading.ts +4 -2
- package/src/markdown/utils.ts +6 -3
|
@@ -28,20 +28,11 @@ function createContactInfo(contact) {
|
|
|
28
28
|
(0, utils_1.create)("span", {
|
|
29
29
|
children: [
|
|
30
30
|
(0, utils_1.guard)(name, () => `${name}: `),
|
|
31
|
-
(0, utils_1.guard)(email, () => (
|
|
32
|
-
href: `mailto:${email}`,
|
|
33
|
-
children: `${email}`,
|
|
34
|
-
})),
|
|
31
|
+
(0, utils_1.guard)(email, () => `[${email}](mailto:${email})`),
|
|
35
32
|
],
|
|
36
33
|
}),
|
|
37
34
|
(0, utils_1.guard)(url, () => (0, utils_1.create)("span", {
|
|
38
|
-
children: [
|
|
39
|
-
"URL: ",
|
|
40
|
-
(0, utils_1.create)("a", {
|
|
41
|
-
href: `${url}`,
|
|
42
|
-
children: `${url}`,
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
35
|
+
children: ["URL: ", `[${url}](mailto:${url})`],
|
|
45
36
|
})),
|
|
46
37
|
],
|
|
47
38
|
});
|
|
@@ -13,7 +13,8 @@ function createDescription(description) {
|
|
|
13
13
|
return "";
|
|
14
14
|
}
|
|
15
15
|
return `\n\n${description
|
|
16
|
-
.replace(utils_1.
|
|
16
|
+
.replace(utils_1.lessThan, "<")
|
|
17
|
+
.replace(utils_1.greaterThan, ">")
|
|
17
18
|
.replace(utils_1.codeFence, function (match) {
|
|
18
19
|
return match.replace(/\\>/g, ">");
|
|
19
20
|
})}\n\n`;
|
|
@@ -12,7 +12,9 @@ function createHeading(heading) {
|
|
|
12
12
|
return [
|
|
13
13
|
(0, utils_1.create)("h1", {
|
|
14
14
|
className: "openapi__heading",
|
|
15
|
-
children: `${heading
|
|
15
|
+
children: `${heading
|
|
16
|
+
.replace(utils_1.lessThan, "<")
|
|
17
|
+
.replace(utils_1.greaterThan, ">")}`,
|
|
16
18
|
}),
|
|
17
19
|
`\n\n`,
|
|
18
20
|
];
|
package/lib/markdown/utils.js
CHANGED
|
@@ -11,9 +11,12 @@ function create(tag, props) {
|
|
|
11
11
|
const { children, ...rest } = props;
|
|
12
12
|
let propString = "";
|
|
13
13
|
for (const [key, value] of Object.entries(rest)) {
|
|
14
|
-
propString +=
|
|
14
|
+
propString += `\n ${key}={${JSON.stringify(value)}}`;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
propString += propString ? "\n" : "";
|
|
17
|
+
let indentedChildren = render(children).replace(/^/gm, " ");
|
|
18
|
+
indentedChildren += indentedChildren ? "\n" : "";
|
|
19
|
+
return `<${tag}${propString}>\n${indentedChildren}</${tag}>`;
|
|
17
20
|
}
|
|
18
21
|
exports.create = create;
|
|
19
22
|
function guard(value, cb) {
|
|
@@ -35,6 +38,6 @@ function render(children) {
|
|
|
35
38
|
}
|
|
36
39
|
exports.render = render;
|
|
37
40
|
// Regex to selectively URL-encode '>' and '<' chars
|
|
38
|
-
exports.lessThan =
|
|
41
|
+
exports.lessThan = /<=?(?!(=|button|\s?\/button|code|\s?\/code|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|thead|\s?\/thead|tbody|\s?\/tbody|td|\s?\/td|tr|\s?\/tr|th|\s?\/th|h1|\s?\/h1|h2|\s?\/h2|h3|\s?\/h3|h4|\s?\/h4|h5|\s?\/h5|h6|\s?\/h6|title|\s?\/title|p|\s?\/p|em|\s?\/em|b|\s?\/b|i|\s?\/i|u|\s?\/u|strike|\s?\/strike|bold|\s?\/bold|a|\s?\/a|table|\s?\/table|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|svg|\s?\/svg|div|\s?\/div|center|\s?\/center))/gu;
|
|
39
42
|
exports.greaterThan = /(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|bold|a|li|ol|ul|img|svg|div|center|\/|\s|"|'))>/gu;
|
|
40
43
|
exports.codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0-beta.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"watch": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/types": "
|
|
31
|
+
"@docusaurus/types": "^3.0.0",
|
|
32
32
|
"@types/fs-extra": "^9.0.13",
|
|
33
33
|
"@types/json-pointer": "^1.0.31",
|
|
34
34
|
"@types/json-schema": "^7.0.9",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
40
|
-
"@docusaurus/plugin-content-docs": "
|
|
41
|
-
"@docusaurus/utils": "
|
|
42
|
-
"@docusaurus/utils-validation": "
|
|
40
|
+
"@docusaurus/plugin-content-docs": "^3.0.0",
|
|
41
|
+
"@docusaurus/utils": "^3.0.0",
|
|
42
|
+
"@docusaurus/utils-validation": "^3.0.0",
|
|
43
43
|
"@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
|
|
44
44
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
45
45
|
"@redocly/openapi-core": "^1.0.0-beta.125",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=14"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "9641610aae936a5d9193f43068a2fdd337da0416"
|
|
64
64
|
}
|
|
@@ -6,7 +6,7 @@ Array [
|
|
|
6
6
|
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
7
7
|
<summary style={{}}>
|
|
8
8
|
<strong>oneOfProperty</strong>
|
|
9
|
-
<span style={{ opacity: \\"0.6\\" }}>
|
|
9
|
+
<span style={{ opacity: \\"0.6\\" }}>object</span>
|
|
10
10
|
</summary>
|
|
11
11
|
<div style={{ marginLeft: \\"1rem\\" }}></div>
|
|
12
12
|
<div>
|
|
@@ -28,23 +28,12 @@ export function createContactInfo(contact: ContactObject) {
|
|
|
28
28
|
create("span", {
|
|
29
29
|
children: [
|
|
30
30
|
guard(name, () => `${name}: `),
|
|
31
|
-
guard(email, () =>
|
|
32
|
-
create("a", {
|
|
33
|
-
href: `mailto:${email}`,
|
|
34
|
-
children: `${email}`,
|
|
35
|
-
})
|
|
36
|
-
),
|
|
31
|
+
guard(email, () => `[${email}](mailto:${email})`),
|
|
37
32
|
],
|
|
38
33
|
}),
|
|
39
34
|
guard(url, () =>
|
|
40
35
|
create("span", {
|
|
41
|
-
children: [
|
|
42
|
-
"URL: ",
|
|
43
|
-
create("a", {
|
|
44
|
-
href: `${url}`,
|
|
45
|
-
children: `${url}`,
|
|
46
|
-
}),
|
|
47
|
-
],
|
|
36
|
+
children: ["URL: ", `[${url}](mailto:${url})`],
|
|
48
37
|
})
|
|
49
38
|
),
|
|
50
39
|
],
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import { greaterThan, codeFence } from "./utils";
|
|
8
|
+
import { greaterThan, codeFence, lessThan } from "./utils";
|
|
9
9
|
|
|
10
10
|
export function createDescription(description: string | undefined) {
|
|
11
11
|
if (!description) {
|
|
12
12
|
return "";
|
|
13
13
|
}
|
|
14
14
|
return `\n\n${description
|
|
15
|
-
.replace(
|
|
15
|
+
.replace(lessThan, "<")
|
|
16
|
+
.replace(greaterThan, ">")
|
|
16
17
|
.replace(codeFence, function (match) {
|
|
17
18
|
return match.replace(/\\>/g, ">");
|
|
18
19
|
})}\n\n`;
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import { create } from "./utils";
|
|
8
|
+
import { create, greaterThan, lessThan } from "./utils";
|
|
9
9
|
|
|
10
10
|
export function createHeading(heading: string) {
|
|
11
11
|
return [
|
|
12
12
|
create("h1", {
|
|
13
13
|
className: "openapi__heading",
|
|
14
|
-
children: `${heading
|
|
14
|
+
children: `${heading
|
|
15
|
+
.replace(lessThan, "<")
|
|
16
|
+
.replace(greaterThan, ">")}`,
|
|
15
17
|
}),
|
|
16
18
|
`\n\n`,
|
|
17
19
|
];
|
package/src/markdown/utils.ts
CHANGED
|
@@ -14,10 +14,13 @@ export function create(tag: string, props: Props): string {
|
|
|
14
14
|
|
|
15
15
|
let propString = "";
|
|
16
16
|
for (const [key, value] of Object.entries(rest)) {
|
|
17
|
-
propString +=
|
|
17
|
+
propString += `\n ${key}={${JSON.stringify(value)}}`;
|
|
18
18
|
}
|
|
19
|
+
propString += propString ? "\n" : "";
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
let indentedChildren = render(children).replace(/^/gm, " ");
|
|
22
|
+
indentedChildren += indentedChildren ? "\n" : "";
|
|
23
|
+
return `<${tag}${propString}>\n${indentedChildren}</${tag}>`;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export function guard<T>(
|
|
@@ -43,7 +46,7 @@ export function render(children: Children): string {
|
|
|
43
46
|
|
|
44
47
|
// Regex to selectively URL-encode '>' and '<' chars
|
|
45
48
|
export const lessThan =
|
|
46
|
-
|
|
49
|
+
/<=?(?!(=|button|\s?\/button|code|\s?\/code|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|thead|\s?\/thead|tbody|\s?\/tbody|td|\s?\/td|tr|\s?\/tr|th|\s?\/th|h1|\s?\/h1|h2|\s?\/h2|h3|\s?\/h3|h4|\s?\/h4|h5|\s?\/h5|h6|\s?\/h6|title|\s?\/title|p|\s?\/p|em|\s?\/em|b|\s?\/b|i|\s?\/i|u|\s?\/u|strike|\s?\/strike|bold|\s?\/bold|a|\s?\/a|table|\s?\/table|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|svg|\s?\/svg|div|\s?\/div|center|\s?\/center))/gu;
|
|
47
50
|
export const greaterThan =
|
|
48
51
|
/(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|bold|a|li|ol|ul|img|svg|div|center|\/|\s|"|'))>/gu;
|
|
49
52
|
export const codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
|