docusaurus-plugin-openapi-docs 0.0.0-1081 → 0.0.0-1083

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/README.md CHANGED
@@ -176,6 +176,8 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
176
176
  | `versions` | `object` | `null` | _Optional:_ Options for versioning configuration. See below for a list of supported options. |
177
177
  | `markdownGenerators` | `object` | `null` | _Optional:_ Customize MDX content via generator functions. See below for a list of supported options. |
178
178
  | `showSchemas` | `boolean` | `null` | _Optional:_ If set to `true`, generates standalone schema pages and adds them to the sidebar. |
179
+ | `showInfoPage` | `boolean` | `true` | _Optional:_ If set to `false`, disables generation of the info page (overview page with API title and description). |
180
+ | `schemasOnly` | `boolean` | `false` | _Optional:_ If set to `true`, generates only schema pages (no API endpoint pages). Also available as `--schemas-only` CLI flag. |
179
181
 
180
182
  ### sidebarOptions
181
183
 
package/lib/index.js CHANGED
@@ -234,6 +234,7 @@ custom_edit_url: null
234
234
  schema: schemaPageGenerator,
235
235
  };
236
236
  loadedApi.map(async (item) => {
237
+ var _a, _b;
237
238
  if (downloadUrl) {
238
239
  item.downloadUrl = downloadUrl;
239
240
  }
@@ -257,9 +258,14 @@ custom_edit_url: null
257
258
  .toString("base64"));
258
259
  let infoBasePath = `${outputDir}/${item.infoId}`;
259
260
  if (docRouteBasePath) {
260
- infoBasePath = `${docRouteBasePath}/${outputDir
261
- .split(docPath)[1]
262
- .replace(/^\/+/g, "")}/${item.infoId}`.replace(/^\/+/g, "");
261
+ // Safely extract path segment, handling cases where docPath may not be in outputDir
262
+ const outputSegment = docPath && outputDir.includes(docPath)
263
+ ? ((_b = (_a = outputDir.split(docPath)[1]) === null || _a === void 0 ? void 0 : _a.replace(/^\/+/g, "")) !== null && _b !== void 0 ? _b : "")
264
+ : outputDir
265
+ .slice(outputDir.indexOf("/", 1))
266
+ .replace(/^\/+/g, "");
267
+ infoBasePath =
268
+ `${docRouteBasePath}/${outputSegment}/${item.infoId}`.replace(/^\/+/g, "");
263
269
  }
264
270
  if (item.infoId)
265
271
  item.infoPath = infoBasePath;
@@ -109,8 +109,9 @@ function createItems(openapiData, options, sidebarOptions) {
109
109
  const infoIdSpaces = openapiData.info.title.replace(" ", "-").toLowerCase();
110
110
  const infoId = (0, kebabCase_1.default)(infoIdSpaces);
111
111
  const schemasOnly = (options === null || options === void 0 ? void 0 : options.schemasOnly) === true;
112
- if (openapiData.info.description || openapiData.info.title) {
113
- // Only create an info page if we have a description.
112
+ // Only create an info page if we have a description/title AND showInfoPage is not false
113
+ if ((openapiData.info.description || openapiData.info.title) &&
114
+ (options === null || options === void 0 ? void 0 : options.showInfoPage) !== false) {
114
115
  const infoDescription = (_a = openapiData.info) === null || _a === void 0 ? void 0 : _a.description;
115
116
  let splitDescription;
116
117
  if (infoDescription) {
package/lib/options.js CHANGED
@@ -44,6 +44,8 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
44
44
  sidebarOptions: sidebarOptions,
45
45
  markdownGenerators: markdownGenerators,
46
46
  showSchemas: utils_validation_1.Joi.boolean(),
47
+ showInfoPage: utils_validation_1.Joi.boolean(),
48
+ schemasOnly: utils_validation_1.Joi.boolean(),
47
49
  disableCompression: utils_validation_1.Joi.boolean(),
48
50
  maskCredentials: utils_validation_1.Joi.boolean(),
49
51
  version: utils_validation_1.Joi.string().when("versions", {
@@ -81,9 +81,18 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
81
81
  if (sidebarOptions.groupPathsBy !== "tagGroup") {
82
82
  apiTags = (0, uniq_1.default)(apiTags.concat(operationTags, schemaTags));
83
83
  }
84
- const basePath = docPath
85
- ? outputDir.split(docPath)[1].replace(/^\/+/g, "")
86
- : outputDir.slice(outputDir.indexOf("/", 1)).replace(/^\/+/g, "");
84
+ // Extract base path from outputDir, handling cases where docPath may not be in outputDir
85
+ const getBasePathFromOutput = (output, doc) => {
86
+ var _a, _b;
87
+ if (doc && output.includes(doc)) {
88
+ return (_b = (_a = output.split(doc)[1]) === null || _a === void 0 ? void 0 : _a.replace(/^\/+/g, "")) !== null && _b !== void 0 ? _b : "";
89
+ }
90
+ const slashIndex = output.indexOf("/", 1);
91
+ return slashIndex === -1
92
+ ? ""
93
+ : output.slice(slashIndex).replace(/^\/+/g, "");
94
+ };
95
+ const basePath = getBasePathFromOutput(outputDir, docPath);
87
96
  const createDocItemFnContext = {
88
97
  sidebarOptions,
89
98
  basePath,
package/lib/types.d.ts CHANGED
@@ -29,6 +29,7 @@ export interface APIOptions {
29
29
  proxy?: string;
30
30
  markdownGenerators?: MarkdownGenerator;
31
31
  showSchemas?: boolean;
32
+ showInfoPage?: boolean;
32
33
  schemasOnly?: boolean;
33
34
  disableCompression?: boolean;
34
35
  maskCredentials?: boolean;
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-1081",
4
+ "version": "0.0.0-1083",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -65,5 +65,5 @@
65
65
  "engines": {
66
66
  "node": ">=14"
67
67
  },
68
- "gitHead": "2b7184703cfbed61bafb8d671bbbb61ac5f187bc"
68
+ "gitHead": "cf5831415603ce841036073da0ff9e50db9ed9d8"
69
69
  }
package/src/index.ts CHANGED
@@ -353,9 +353,18 @@ custom_edit_url: null
353
353
  .toString("base64"));
354
354
  let infoBasePath = `${outputDir}/${item.infoId}`;
355
355
  if (docRouteBasePath) {
356
- infoBasePath = `${docRouteBasePath}/${outputDir
357
- .split(docPath!)[1]
358
- .replace(/^\/+/g, "")}/${item.infoId}`.replace(/^\/+/g, "");
356
+ // Safely extract path segment, handling cases where docPath may not be in outputDir
357
+ const outputSegment =
358
+ docPath && outputDir.includes(docPath)
359
+ ? (outputDir.split(docPath)[1]?.replace(/^\/+/g, "") ?? "")
360
+ : outputDir
361
+ .slice(outputDir.indexOf("/", 1))
362
+ .replace(/^\/+/g, "");
363
+ infoBasePath =
364
+ `${docRouteBasePath}/${outputSegment}/${item.infoId}`.replace(
365
+ /^\/+/g,
366
+ ""
367
+ );
359
368
  }
360
369
  if (item.infoId) item.infoPath = infoBasePath;
361
370
  }
@@ -97,8 +97,11 @@ function createItems(
97
97
  const infoId = kebabCase(infoIdSpaces);
98
98
  const schemasOnly = options?.schemasOnly === true;
99
99
 
100
- if (openapiData.info.description || openapiData.info.title) {
101
- // Only create an info page if we have a description.
100
+ // Only create an info page if we have a description/title AND showInfoPage is not false
101
+ if (
102
+ (openapiData.info.description || openapiData.info.title) &&
103
+ options?.showInfoPage !== false
104
+ ) {
102
105
  const infoDescription = openapiData.info?.description;
103
106
  let splitDescription: any;
104
107
  if (infoDescription) {
package/src/options.ts CHANGED
@@ -48,6 +48,8 @@ export const OptionsSchema = Joi.object({
48
48
  sidebarOptions: sidebarOptions,
49
49
  markdownGenerators: markdownGenerators,
50
50
  showSchemas: Joi.boolean(),
51
+ showInfoPage: Joi.boolean(),
52
+ schemasOnly: Joi.boolean(),
51
53
  disableCompression: Joi.boolean(),
52
54
  maskCredentials: Joi.boolean(),
53
55
  version: Joi.string().when("versions", {
@@ -125,9 +125,21 @@ function groupByTags(
125
125
  apiTags = uniq(apiTags.concat(operationTags, schemaTags));
126
126
  }
127
127
 
128
- const basePath = docPath
129
- ? outputDir.split(docPath!)[1].replace(/^\/+/g, "")
130
- : outputDir.slice(outputDir.indexOf("/", 1)).replace(/^\/+/g, "");
128
+ // Extract base path from outputDir, handling cases where docPath may not be in outputDir
129
+ const getBasePathFromOutput = (
130
+ output: string,
131
+ doc: string | undefined
132
+ ): string => {
133
+ if (doc && output.includes(doc)) {
134
+ return output.split(doc)[1]?.replace(/^\/+/g, "") ?? "";
135
+ }
136
+ const slashIndex = output.indexOf("/", 1);
137
+ return slashIndex === -1
138
+ ? ""
139
+ : output.slice(slashIndex).replace(/^\/+/g, "");
140
+ };
141
+
142
+ const basePath = getBasePathFromOutput(outputDir, docPath);
131
143
 
132
144
  const createDocItemFnContext = {
133
145
  sidebarOptions,
package/src/types.ts CHANGED
@@ -51,6 +51,7 @@ export interface APIOptions {
51
51
  proxy?: string;
52
52
  markdownGenerators?: MarkdownGenerator;
53
53
  showSchemas?: boolean;
54
+ showInfoPage?: boolean;
54
55
  schemasOnly?: boolean;
55
56
  disableCompression?: boolean;
56
57
  maskCredentials?: boolean;