docusaurus-plugin-openapi-docs 0.0.0-479 → 0.0.0-481

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.
@@ -7,10 +7,13 @@
7
7
  * ========================================================================== */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createDescription = void 0;
10
+ const utils_1 = require("./utils");
10
11
  function createDescription(description) {
11
12
  if (!description) {
12
13
  return "";
13
14
  }
14
- return `\n\n${description}\n\n`;
15
+ return `\n\n${description
16
+ .replace(utils_1.lessThan, "<")
17
+ .replace(utils_1.greaterThan, ">")}\n\n`;
15
18
  }
16
19
  exports.createDescription = createDescription;
@@ -7,7 +7,6 @@
7
7
  * ========================================================================== */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createTagPageMD = exports.createInfoPageMD = exports.createApiPageMD = void 0;
10
- const lodash_1 = require("lodash");
11
10
  const createAuthentication_1 = require("./createAuthentication");
12
11
  const createContactInfo_1 = require("./createContactInfo");
13
12
  const createDeprecationNotice_1 = require("./createDeprecationNotice");
@@ -30,9 +29,9 @@ function createApiPageMD({ title, api: { deprecated, "x-deprecated-description":
30
29
  `import SchemaTabs from "@theme/SchemaTabs";\n`,
31
30
  `import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
32
31
  `import TabItem from "@theme/TabItem";\n\n`,
33
- `## ${(0, lodash_1.escape)(title)}\n\n`,
32
+ `## ${title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")}\n\n`,
34
33
  (0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
35
- (0, createDescription_1.createDescription)((0, lodash_1.escape)(description)),
34
+ (0, createDescription_1.createDescription)(description),
36
35
  (0, createParamsDetails_1.createParamsDetails)({ parameters, type: "path" }),
37
36
  (0, createParamsDetails_1.createParamsDetails)({ parameters, type: "query" }),
38
37
  (0, createParamsDetails_1.createParamsDetails)({ parameters, type: "header" }),
@@ -51,7 +50,7 @@ function createInfoPageMD({ info: { title, version, description, contact, licens
51
50
  `import Tabs from "@theme/Tabs";\n`,
52
51
  `import TabItem from "@theme/TabItem";\n\n`,
53
52
  (0, createVersionBadge_1.createVersionBadge)(version),
54
- `# ${(0, lodash_1.escape)(title)}\n\n`,
53
+ `# ${title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")}\n\n`,
55
54
  (0, createLogo_1.createLogo)(logo, darkLogo),
56
55
  (0, createDescription_1.createDescription)(description),
57
56
  (0, createAuthentication_1.createAuthentication)(securitySchemes),
@@ -5,3 +5,5 @@ export declare type Props = Record<string, any> & {
5
5
  export declare function create(tag: string, props: Props): string;
6
6
  export declare function guard<T>(value: T | undefined, cb: (value: T) => Children): string;
7
7
  export declare function render(children: Children): string;
8
+ export declare const lessThan: RegExp;
9
+ export declare const greaterThan: RegExp;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  * ========================================================================== */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.render = exports.guard = exports.create = void 0;
9
+ exports.greaterThan = exports.lessThan = exports.render = exports.guard = exports.create = void 0;
10
10
  function create(tag, props) {
11
11
  const { children, ...rest } = props;
12
12
  let propString = "";
@@ -34,3 +34,6 @@ function render(children) {
34
34
  return children !== null && children !== void 0 ? children : "";
35
35
  }
36
36
  exports.render = render;
37
+ // Regex to selectively URL-encode '>' and '<' chars
38
+ exports.lessThan = /<(?!(button|\s?\/button|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|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|a|\s?\/a|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|div|\s?\/div|center|\s?\/center))/giu;
39
+ exports.greaterThan = /(?<!(button|details|summary|hr|br|span|strong|small|table|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|a|tag|li|ol|ul|img|div|center|\/|\s|"|'))>/giu;
@@ -60,12 +60,10 @@ function sampleResponseFromProp(name, prop, obj) {
60
60
  }
61
61
  const sampleResponseFromSchema = (schema = {}) => {
62
62
  try {
63
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
63
  let { type, example, allOf, oneOf, anyOf, properties, items } = schema;
65
- // TODO: determine if we should always ignore the example when creating from schema
66
- // if (example !== undefined) {
67
- // return example;
68
- // }
64
+ if (example !== undefined) {
65
+ return example;
66
+ }
69
67
  if (allOf) {
70
68
  const { mergedSchemas } = (0, createResponseSchema_1.mergeAllOf)(allOf);
71
69
  if (mergedSchemas.properties) {
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": "0.0.0-479",
4
+ "version": "0.0.0-481",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -68,5 +68,5 @@
68
68
  "engines": {
69
69
  "node": ">=14"
70
70
  },
71
- "gitHead": "72d4c8ac5203c761c8ed3f9b30ee6ee79e386500"
71
+ "gitHead": "6eff65560dc9e24c5823ea1ba7da33fa86bfc703"
72
72
  }
@@ -5,9 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
+ import { greaterThan, lessThan } from "./utils";
9
+
8
10
  export function createDescription(description: string | undefined) {
9
11
  if (!description) {
10
12
  return "";
11
13
  }
12
- return `\n\n${description}\n\n`;
14
+ return `\n\n${description
15
+ .replace(lessThan, "&lt;")
16
+ .replace(greaterThan, "&gt;")}\n\n`;
13
17
  }
@@ -5,8 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { escape } from "lodash";
9
-
10
8
  import {
11
9
  ContactObject,
12
10
  LicenseObject,
@@ -25,7 +23,7 @@ import { createRequestBodyDetails } from "./createRequestBodyDetails";
25
23
  import { createStatusCodes } from "./createStatusCodes";
26
24
  import { createTermsOfService } from "./createTermsOfService";
27
25
  import { createVersionBadge } from "./createVersionBadge";
28
- import { render } from "./utils";
26
+ import { greaterThan, lessThan, render } from "./utils";
29
27
 
30
28
  interface Props {
31
29
  title: string;
@@ -58,9 +56,9 @@ export function createApiPageMD({
58
56
  `import SchemaTabs from "@theme/SchemaTabs";\n`,
59
57
  `import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
60
58
  `import TabItem from "@theme/TabItem";\n\n`,
61
- `## ${escape(title)}\n\n`,
59
+ `## ${title.replace(lessThan, "&lt;").replace(greaterThan, "&gt;")}\n\n`,
62
60
  createDeprecationNotice({ deprecated, description: deprecatedDescription }),
63
- createDescription(escape(description)),
61
+ createDescription(description),
64
62
  createParamsDetails({ parameters, type: "path" }),
65
63
  createParamsDetails({ parameters, type: "query" }),
66
64
  createParamsDetails({ parameters, type: "header" }),
@@ -92,7 +90,7 @@ export function createInfoPageMD({
92
90
  `import TabItem from "@theme/TabItem";\n\n`,
93
91
 
94
92
  createVersionBadge(version),
95
- `# ${escape(title)}\n\n`,
93
+ `# ${title.replace(lessThan, "&lt;").replace(greaterThan, "&gt;")}\n\n`,
96
94
  createLogo(logo, darkLogo),
97
95
  createDescription(description),
98
96
  createAuthentication(securitySchemes as unknown as SecuritySchemeObject),
@@ -40,3 +40,9 @@ export function render(children: Children): string {
40
40
  }
41
41
  return children ?? "";
42
42
  }
43
+
44
+ // Regex to selectively URL-encode '>' and '<' chars
45
+ export const lessThan =
46
+ /<(?!(button|\s?\/button|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|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|a|\s?\/a|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|div|\s?\/div|center|\s?\/center))/giu;
47
+ export const greaterThan =
48
+ /(?<!(button|details|summary|hr|br|span|strong|small|table|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|a|tag|li|ol|ul|img|div|center|\/|\s|"|'))>/giu;
@@ -77,13 +77,11 @@ function sampleResponseFromProp(name: string, prop: any, obj: any): any {
77
77
 
78
78
  export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
79
79
  try {
80
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
81
80
  let { type, example, allOf, oneOf, anyOf, properties, items } = schema;
82
81
 
83
- // TODO: determine if we should always ignore the example when creating from schema
84
- // if (example !== undefined) {
85
- // return example;
86
- // }
82
+ if (example !== undefined) {
83
+ return example;
84
+ }
87
85
 
88
86
  if (allOf) {
89
87
  const { mergedSchemas }: { mergedSchemas: SchemaObject } =