docusaurus-plugin-openapi-docs 0.0.0-beta.722 → 0.0.0-beta.727

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
@@ -78,7 +78,7 @@ function pluginOpenAPIDocs(context, options) {
78
78
  let docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
79
79
  async function generateApiDocs(options, pluginId) {
80
80
  var _a, _b, _c, _d;
81
- let { specPath, outputDir, template, markdownGenerators, downloadUrl, sidebarOptions, } = options;
81
+ let { specPath, outputDir, template, markdownGenerators, downloadUrl, sidebarOptions, disableCompression, } = options;
82
82
  // Remove trailing slash before proceeding
83
83
  outputDir = outputDir.replace(/\/$/, "");
84
84
  // Override docPath if pluginId provided
@@ -235,9 +235,11 @@ custom_edit_url: null
235
235
  // const deserialize = (s: any) => {
236
236
  // return zlib.inflateSync(Buffer.from(s, "base64")).toString();
237
237
  // };
238
- item.json = zlib_1.default
239
- .deflateSync(JSON.stringify(item.api))
240
- .toString("base64");
238
+ disableCompression === true
239
+ ? (item.json = JSON.stringify(item.api))
240
+ : (item.json = zlib_1.default
241
+ .deflateSync(JSON.stringify(item.api))
242
+ .toString("base64"));
241
243
  let infoBasePath = `${outputDir}/${item.infoId}`;
242
244
  if (docRouteBasePath) {
243
245
  infoBasePath = `${docRouteBasePath}/${outputDir
@@ -333,11 +335,7 @@ custom_edit_url: null
333
335
  cwd: path_1.default.resolve(apiDir),
334
336
  deep: 1,
335
337
  });
336
- const schemaMdxFiles = await (0, utils_1.Globby)(["*.schema.mdx"], {
337
- cwd: path_1.default.resolve(apiDir, "schemas"),
338
- deep: 1,
339
- });
340
- const sidebarFile = await (0, utils_1.Globby)(["sidebar.js"], {
338
+ const sidebarFile = await (0, utils_1.Globby)(["sidebar.js", "sidebar.ts"], {
341
339
  cwd: path_1.default.resolve(apiDir),
342
340
  deep: 1,
343
341
  });
@@ -349,14 +347,15 @@ custom_edit_url: null
349
347
  console.log(chalk_1.default.green(`Cleanup succeeded for "${apiDir}/${mdx}"`));
350
348
  }
351
349
  }));
352
- schemaMdxFiles.map((mdx) => fs_1.default.unlink(`${apiDir}/schemas/${mdx}`, (err) => {
353
- if (err) {
354
- console.error(chalk_1.default.red(`Cleanup failed for "${apiDir}/schemas/${mdx}"`), chalk_1.default.yellow(err));
355
- }
356
- else {
357
- console.log(chalk_1.default.green(`Cleanup succeeded for "${apiDir}/schemas/${mdx}"`));
350
+ try {
351
+ fs_1.default.rmSync(`${apiDir}/schemas`, { recursive: true });
352
+ console.log(chalk_1.default.green(`Cleanup succeeded for "${apiDir}/schemas"`));
353
+ }
354
+ catch (err) {
355
+ if (err.code !== "ENOENT") {
356
+ console.error(chalk_1.default.red(`Cleanup failed for "${apiDir}/schemas"`), chalk_1.default.yellow(err));
358
357
  }
359
- }));
358
+ }
360
359
  sidebarFile.map((sidebar) => fs_1.default.unlink(`${apiDir}/${sidebar}`, (err) => {
361
360
  if (err) {
362
361
  console.error(chalk_1.default.red(`Cleanup failed for "${apiDir}/${sidebar}"`), chalk_1.default.yellow(err));
package/lib/options.js CHANGED
@@ -36,6 +36,7 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
36
36
  sidebarOptions: sidebarOptions,
37
37
  markdownGenerators: markdownGenerators,
38
38
  showSchemas: utils_validation_1.Joi.boolean(),
39
+ disableCompression: utils_validation_1.Joi.boolean(),
39
40
  version: utils_validation_1.Joi.string().when("versions", {
40
41
  is: utils_validation_1.Joi.exist(),
41
42
  then: utils_validation_1.Joi.required(),
package/lib/types.d.ts CHANGED
@@ -26,6 +26,7 @@ export interface APIOptions {
26
26
  proxy?: string;
27
27
  markdownGenerators?: MarkdownGenerator;
28
28
  showSchemas?: boolean;
29
+ disableCompression?: boolean;
29
30
  }
30
31
  export interface MarkdownGenerator {
31
32
  createApiPageMD?: (pageData: ApiPageMetadata) => 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-beta.722",
4
+ "version": "0.0.0-beta.727",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=14"
64
64
  },
65
- "gitHead": "cae8c487b81918ef2cab2c7338deaae407b4dc2b"
65
+ "gitHead": "3269c28557138d879701d00fe96c054c708155cc"
66
66
  }
package/src/index.ts CHANGED
@@ -120,6 +120,7 @@ export default function pluginOpenAPIDocs(
120
120
  markdownGenerators,
121
121
  downloadUrl,
122
122
  sidebarOptions,
123
+ disableCompression,
123
124
  } = options;
124
125
 
125
126
  // Remove trailing slash before proceeding
@@ -325,9 +326,11 @@ custom_edit_url: null
325
326
  // const deserialize = (s: any) => {
326
327
  // return zlib.inflateSync(Buffer.from(s, "base64")).toString();
327
328
  // };
328
- item.json = zlib
329
- .deflateSync(JSON.stringify(item.api))
330
- .toString("base64");
329
+ disableCompression === true
330
+ ? (item.json = JSON.stringify(item.api))
331
+ : (item.json = zlib
332
+ .deflateSync(JSON.stringify(item.api))
333
+ .toString("base64"));
331
334
  let infoBasePath = `${outputDir}/${item.infoId}`;
332
335
  if (docRouteBasePath) {
333
336
  infoBasePath = `${docRouteBasePath}/${outputDir
@@ -476,11 +479,7 @@ custom_edit_url: null
476
479
  cwd: path.resolve(apiDir),
477
480
  deep: 1,
478
481
  });
479
- const schemaMdxFiles = await Globby(["*.schema.mdx"], {
480
- cwd: path.resolve(apiDir, "schemas"),
481
- deep: 1,
482
- });
483
- const sidebarFile = await Globby(["sidebar.js"], {
482
+ const sidebarFile = await Globby(["sidebar.js", "sidebar.ts"], {
484
483
  cwd: path.resolve(apiDir),
485
484
  deep: 1,
486
485
  });
@@ -497,20 +496,17 @@ custom_edit_url: null
497
496
  })
498
497
  );
499
498
 
500
- schemaMdxFiles.map((mdx) =>
501
- fs.unlink(`${apiDir}/schemas/${mdx}`, (err) => {
502
- if (err) {
503
- console.error(
504
- chalk.red(`Cleanup failed for "${apiDir}/schemas/${mdx}"`),
505
- chalk.yellow(err)
506
- );
507
- } else {
508
- console.log(
509
- chalk.green(`Cleanup succeeded for "${apiDir}/schemas/${mdx}"`)
510
- );
511
- }
512
- })
513
- );
499
+ try {
500
+ fs.rmSync(`${apiDir}/schemas`, { recursive: true });
501
+ console.log(chalk.green(`Cleanup succeeded for "${apiDir}/schemas"`));
502
+ } catch (err: any) {
503
+ if (err.code !== "ENOENT") {
504
+ console.error(
505
+ chalk.red(`Cleanup failed for "${apiDir}/schemas"`),
506
+ chalk.yellow(err)
507
+ );
508
+ }
509
+ }
514
510
 
515
511
  sidebarFile.map((sidebar) =>
516
512
  fs.unlink(`${apiDir}/${sidebar}`, (err) => {
package/src/options.ts CHANGED
@@ -39,6 +39,7 @@ export const OptionsSchema = Joi.object({
39
39
  sidebarOptions: sidebarOptions,
40
40
  markdownGenerators: markdownGenerators,
41
41
  showSchemas: Joi.boolean(),
42
+ disableCompression: Joi.boolean(),
42
43
  version: Joi.string().when("versions", {
43
44
  is: Joi.exist(),
44
45
  then: Joi.required(),
package/src/types.ts CHANGED
@@ -47,6 +47,7 @@ export interface APIOptions {
47
47
  proxy?: string;
48
48
  markdownGenerators?: MarkdownGenerator;
49
49
  showSchemas?: boolean;
50
+ disableCompression?: boolean;
50
51
  }
51
52
 
52
53
  export interface MarkdownGenerator {