docusaurus-plugin-openapi-docs 0.0.0-486 → 0.0.0-489

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/index.js CHANGED
@@ -73,7 +73,7 @@ function pluginOpenAPIDocs(context, options) {
73
73
  let docRouteBasePath = docData ? docData.routeBasePath : undefined;
74
74
  let docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
75
75
  async function generateApiDocs(options, pluginId) {
76
- let { specPath, outputDir, template, sidebarOptions } = options;
76
+ let { specPath, outputDir, template, downloadUrl, sidebarOptions } = options;
77
77
  // Override docPath if pluginId provided
78
78
  if (pluginId) {
79
79
  docData = getDocsPluginConfig(presetsPlugins, pluginId);
@@ -179,6 +179,11 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
179
179
  \`\`\`
180
180
  `;
181
181
  loadedApi.map(async (item) => {
182
+ if (item.type === "info") {
183
+ if (downloadUrl && isURL(downloadUrl)) {
184
+ item.downloadUrl = downloadUrl;
185
+ }
186
+ }
182
187
  const markdown = item.type === "api"
183
188
  ? (0, markdown_1.createApiPageMD)(item)
184
189
  : item.type === "info"
@@ -0,0 +1 @@
1
+ export declare function createDownload(url: string | undefined): string;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.createDownload = void 0;
10
+ const utils_1 = require("./utils");
11
+ function createDownload(url) {
12
+ return (0, utils_1.guard)(url, (url) => [
13
+ (0, utils_1.create)("Export", { url: url, proxy: undefined }),
14
+ `\n\n`,
15
+ ]);
16
+ }
17
+ exports.createDownload = createDownload;
@@ -1,4 +1,4 @@
1
1
  import { ApiPageMetadata, InfoPageMetadata, TagPageMetadata } from "../types";
2
2
  export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }: ApiPageMetadata): string;
3
- export declare function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, }: InfoPageMetadata): string;
3
+ export declare function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, downloadUrl, }: InfoPageMetadata): string;
4
4
  export declare function createTagPageMD({ tag: { description } }: TagPageMetadata): string;
@@ -11,6 +11,7 @@ const createAuthentication_1 = require("./createAuthentication");
11
11
  const createContactInfo_1 = require("./createContactInfo");
12
12
  const createDeprecationNotice_1 = require("./createDeprecationNotice");
13
13
  const createDescription_1 = require("./createDescription");
14
+ const createDownload_1 = require("./createDownload");
14
15
  const createLicense_1 = require("./createLicense");
15
16
  const createLogo_1 = require("./createLogo");
16
17
  const createParamsDetails_1 = require("./createParamsDetails");
@@ -44,12 +45,14 @@ function createApiPageMD({ title, api: { deprecated, "x-deprecated-description":
44
45
  ]);
45
46
  }
46
47
  exports.createApiPageMD = createApiPageMD;
47
- function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, }) {
48
+ function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, downloadUrl, }) {
48
49
  return (0, utils_1.render)([
49
50
  `import ApiLogo from "@theme/ApiLogo";\n`,
50
51
  `import Tabs from "@theme/Tabs";\n`,
51
- `import TabItem from "@theme/TabItem";\n\n`,
52
+ `import TabItem from "@theme/TabItem";\n`,
53
+ `import Export from "@theme/ApiDemoPanel/Export";\n\n`,
52
54
  (0, createVersionBadge_1.createVersionBadge)(version),
55
+ (0, createDownload_1.createDownload)(downloadUrl),
53
56
  `# ${title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")}\n\n`,
54
57
  (0, createLogo_1.createLogo)(logo, darkLogo),
55
58
  (0, createDescription_1.createDescription)(description),
@@ -35,5 +35,5 @@ function render(children) {
35
35
  }
36
36
  exports.render = render;
37
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;
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;
package/lib/options.js CHANGED
@@ -23,6 +23,7 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
23
23
  specPath: utils_validation_1.Joi.string().required(),
24
24
  outputDir: utils_validation_1.Joi.string().required(),
25
25
  template: utils_validation_1.Joi.string(),
26
+ downloadUrl: utils_validation_1.Joi.string(),
26
27
  sidebarOptions: sidebarOptions,
27
28
  version: utils_validation_1.Joi.string().when("versions", {
28
29
  is: utils_validation_1.Joi.exist(),
package/lib/types.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface APIOptions {
12
12
  specPath: string;
13
13
  outputDir: string;
14
14
  template?: string;
15
+ downloadUrl?: string;
15
16
  sidebarOptions?: SidebarOptions;
16
17
  version?: string;
17
18
  label?: string;
@@ -47,6 +48,7 @@ export interface ApiMetadataBase {
47
48
  unversionedId: string;
48
49
  infoId?: string;
49
50
  infoPath?: string;
51
+ downloadUrl?: string;
50
52
  title: string;
51
53
  description: string;
52
54
  source: string;
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-486",
4
+ "version": "0.0.0-489",
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": "412d6f0f36d01841630b19cdbee865dda8c7fb0f"
71
+ "gitHead": "f445c3439eb90580c2eb5ae0c14bea96cfdd7e59"
72
72
  }
package/src/index.ts CHANGED
@@ -85,7 +85,8 @@ export default function pluginOpenAPIDocs(
85
85
  let docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
86
86
 
87
87
  async function generateApiDocs(options: APIOptions, pluginId: any) {
88
- let { specPath, outputDir, template, sidebarOptions } = options;
88
+ let { specPath, outputDir, template, downloadUrl, sidebarOptions } =
89
+ options;
89
90
 
90
91
  // Override docPath if pluginId provided
91
92
  if (pluginId) {
@@ -217,6 +218,11 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
217
218
  `;
218
219
 
219
220
  loadedApi.map(async (item) => {
221
+ if (item.type === "info") {
222
+ if (downloadUrl && isURL(downloadUrl)) {
223
+ item.downloadUrl = downloadUrl;
224
+ }
225
+ }
220
226
  const markdown =
221
227
  item.type === "api"
222
228
  ? createApiPageMD(item)
@@ -0,0 +1,15 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import { create, guard } from "./utils";
9
+
10
+ export function createDownload(url: string | undefined) {
11
+ return guard(url, (url) => [
12
+ create("Export", { url: url, proxy: undefined }),
13
+ `\n\n`,
14
+ ]);
15
+ }
@@ -16,6 +16,7 @@ import { createAuthentication } from "./createAuthentication";
16
16
  import { createContactInfo } from "./createContactInfo";
17
17
  import { createDeprecationNotice } from "./createDeprecationNotice";
18
18
  import { createDescription } from "./createDescription";
19
+ import { createDownload } from "./createDownload";
19
20
  import { createLicense } from "./createLicense";
20
21
  import { createLogo } from "./createLogo";
21
22
  import { createParamsDetails } from "./createParamsDetails";
@@ -83,13 +84,16 @@ export function createInfoPageMD({
83
84
  darkLogo,
84
85
  },
85
86
  securitySchemes,
87
+ downloadUrl,
86
88
  }: InfoPageMetadata) {
87
89
  return render([
88
90
  `import ApiLogo from "@theme/ApiLogo";\n`,
89
91
  `import Tabs from "@theme/Tabs";\n`,
90
- `import TabItem from "@theme/TabItem";\n\n`,
92
+ `import TabItem from "@theme/TabItem";\n`,
93
+ `import Export from "@theme/ApiDemoPanel/Export";\n\n`,
91
94
 
92
95
  createVersionBadge(version),
96
+ createDownload(downloadUrl),
93
97
  `# ${title.replace(lessThan, "&lt;").replace(greaterThan, "&gt;")}\n\n`,
94
98
  createLogo(logo, darkLogo),
95
99
  createDescription(description),
@@ -43,6 +43,6 @@ export function render(children: Children): string {
43
43
 
44
44
  // Regex to selectively URL-encode '>' and '<' chars
45
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;
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
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;
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;
package/src/options.ts CHANGED
@@ -25,6 +25,7 @@ export const OptionsSchema = Joi.object({
25
25
  specPath: Joi.string().required(),
26
26
  outputDir: Joi.string().required(),
27
27
  template: Joi.string(),
28
+ downloadUrl: Joi.string(),
28
29
  sidebarOptions: sidebarOptions,
29
30
  version: Joi.string().when("versions", {
30
31
  is: Joi.exist(),
package/src/types.ts CHANGED
@@ -32,6 +32,7 @@ export interface APIOptions {
32
32
  specPath: string;
33
33
  outputDir: string;
34
34
  template?: string;
35
+ downloadUrl?: string;
35
36
  sidebarOptions?: SidebarOptions;
36
37
  version?: string;
37
38
  label?: string;
@@ -72,6 +73,7 @@ export interface ApiMetadataBase {
72
73
  unversionedId: string; // TODO new unversioned id => try to rename to "id"
73
74
  infoId?: string;
74
75
  infoPath?: string;
76
+ downloadUrl?: string;
75
77
  title: string;
76
78
  description: string;
77
79
  source: string; // @site aliased source => "@site/docs/folder/subFolder/subSubFolder/myDoc.md"