docusaurus-plugin-openapi-docs 0.0.0-463 → 0.0.0-466
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 +18 -8
- package/package.json +2 -2
- package/src/index.ts +19 -8
package/lib/index.js
CHANGED
|
@@ -68,11 +68,17 @@ function pluginOpenAPIDocs(context, options) {
|
|
|
68
68
|
const presets = siteConfig.presets;
|
|
69
69
|
const plugins = siteConfig.plugins;
|
|
70
70
|
const presetsPlugins = presets.concat(plugins);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
async function generateApiDocs(options) {
|
|
71
|
+
let docData = getDocsPluginConfig(presetsPlugins, docsPluginId);
|
|
72
|
+
let docRouteBasePath = docData ? docData.routeBasePath : undefined;
|
|
73
|
+
let docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
|
|
74
|
+
async function generateApiDocs(options, pluginId) {
|
|
75
75
|
let { specPath, outputDir, template, sidebarOptions } = options;
|
|
76
|
+
// Override docPath if pluginId provided
|
|
77
|
+
if (pluginId) {
|
|
78
|
+
docData = getDocsPluginConfig(presetsPlugins, pluginId);
|
|
79
|
+
docRouteBasePath = docData ? docData.routeBasePath : undefined;
|
|
80
|
+
docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
|
|
81
|
+
}
|
|
76
82
|
const contentPath = isURL(specPath)
|
|
77
83
|
? specPath
|
|
78
84
|
: path_1.default.resolve(siteDir, specPath);
|
|
@@ -315,10 +321,12 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
315
321
|
const pluginId = options.pluginId;
|
|
316
322
|
const pluginInstances = getPluginInstances(plugins);
|
|
317
323
|
let targetConfig;
|
|
324
|
+
let targetDocsPluginId;
|
|
318
325
|
if (pluginId) {
|
|
319
326
|
try {
|
|
320
327
|
const pluginConfig = getPluginConfig(plugins, pluginId);
|
|
321
328
|
targetConfig = (_a = pluginConfig.config) !== null && _a !== void 0 ? _a : {};
|
|
329
|
+
targetDocsPluginId = pluginConfig.docsPluginId;
|
|
322
330
|
}
|
|
323
331
|
catch {
|
|
324
332
|
console.error(chalk_1.default.red(`OpenAPI docs plugin ID '${pluginId}' not found.`));
|
|
@@ -338,7 +346,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
338
346
|
}
|
|
339
347
|
else {
|
|
340
348
|
Object.keys(targetConfig).forEach(async function (key) {
|
|
341
|
-
await generateApiDocs(targetConfig[key]);
|
|
349
|
+
await generateApiDocs(targetConfig[key], targetDocsPluginId);
|
|
342
350
|
});
|
|
343
351
|
}
|
|
344
352
|
}
|
|
@@ -346,7 +354,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
346
354
|
console.error(chalk_1.default.red(`ID '${id}' does not exist in OpenAPI docs config.`));
|
|
347
355
|
}
|
|
348
356
|
else {
|
|
349
|
-
await generateApiDocs(targetConfig[id]);
|
|
357
|
+
await generateApiDocs(targetConfig[id], targetDocsPluginId);
|
|
350
358
|
}
|
|
351
359
|
});
|
|
352
360
|
cli
|
|
@@ -361,10 +369,12 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
361
369
|
const pluginId = options.pluginId;
|
|
362
370
|
const pluginInstances = getPluginInstances(plugins);
|
|
363
371
|
let targetConfig;
|
|
372
|
+
let targetDocsPluginId;
|
|
364
373
|
if (pluginId) {
|
|
365
374
|
try {
|
|
366
375
|
const pluginConfig = getPluginConfig(plugins, pluginId);
|
|
367
376
|
targetConfig = (_a = pluginConfig.config) !== null && _a !== void 0 ? _a : {};
|
|
377
|
+
targetDocsPluginId = pluginConfig.docsPluginId;
|
|
368
378
|
}
|
|
369
379
|
catch {
|
|
370
380
|
console.error(chalk_1.default.red(`OpenAPI docs plugin ID '${pluginId}' not found.`));
|
|
@@ -405,7 +415,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
405
415
|
...parentConfig,
|
|
406
416
|
...versionConfig,
|
|
407
417
|
};
|
|
408
|
-
await generateApiDocs(mergedConfig);
|
|
418
|
+
await generateApiDocs(mergedConfig, targetDocsPluginId);
|
|
409
419
|
});
|
|
410
420
|
}
|
|
411
421
|
}
|
|
@@ -419,7 +429,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
419
429
|
...versionConfig,
|
|
420
430
|
};
|
|
421
431
|
await generateVersions(mergedVersions, parentConfig.outputDir);
|
|
422
|
-
await generateApiDocs(mergedConfig);
|
|
432
|
+
await generateApiDocs(mergedConfig, targetDocsPluginId);
|
|
423
433
|
}
|
|
424
434
|
});
|
|
425
435
|
cli
|
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-
|
|
4
|
+
"version": "0.0.0-466",
|
|
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": "
|
|
71
|
+
"gitHead": "dfacb06c8340963e1eda0c8a26a174ff61c566d4"
|
|
72
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -79,13 +79,20 @@ export default function pluginOpenAPIDocs(
|
|
|
79
79
|
const presets: any = siteConfig.presets;
|
|
80
80
|
const plugins: any = siteConfig.plugins;
|
|
81
81
|
const presetsPlugins = presets.concat(plugins);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
let docData: any = getDocsPluginConfig(presetsPlugins, docsPluginId);
|
|
83
|
+
let docRouteBasePath = docData ? docData.routeBasePath : undefined;
|
|
84
|
+
let docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
|
|
85
85
|
|
|
86
|
-
async function generateApiDocs(options: APIOptions) {
|
|
86
|
+
async function generateApiDocs(options: APIOptions, pluginId: any) {
|
|
87
87
|
let { specPath, outputDir, template, sidebarOptions } = options;
|
|
88
88
|
|
|
89
|
+
// Override docPath if pluginId provided
|
|
90
|
+
if (pluginId) {
|
|
91
|
+
docData = getDocsPluginConfig(presetsPlugins, pluginId);
|
|
92
|
+
docRouteBasePath = docData ? docData.routeBasePath : undefined;
|
|
93
|
+
docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
89
96
|
const contentPath = isURL(specPath)
|
|
90
97
|
? specPath
|
|
91
98
|
: path.resolve(siteDir, specPath);
|
|
@@ -414,10 +421,12 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
414
421
|
const pluginId = options.pluginId;
|
|
415
422
|
const pluginInstances = getPluginInstances(plugins);
|
|
416
423
|
let targetConfig: any;
|
|
424
|
+
let targetDocsPluginId: any;
|
|
417
425
|
if (pluginId) {
|
|
418
426
|
try {
|
|
419
427
|
const pluginConfig = getPluginConfig(plugins, pluginId);
|
|
420
428
|
targetConfig = pluginConfig.config ?? {};
|
|
429
|
+
targetDocsPluginId = pluginConfig.docsPluginId;
|
|
421
430
|
} catch {
|
|
422
431
|
console.error(
|
|
423
432
|
chalk.red(`OpenAPI docs plugin ID '${pluginId}' not found.`)
|
|
@@ -445,7 +454,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
445
454
|
);
|
|
446
455
|
} else {
|
|
447
456
|
Object.keys(targetConfig).forEach(async function (key) {
|
|
448
|
-
await generateApiDocs(targetConfig[key]);
|
|
457
|
+
await generateApiDocs(targetConfig[key], targetDocsPluginId);
|
|
449
458
|
});
|
|
450
459
|
}
|
|
451
460
|
} else if (!targetConfig[id]) {
|
|
@@ -453,7 +462,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
453
462
|
chalk.red(`ID '${id}' does not exist in OpenAPI docs config.`)
|
|
454
463
|
);
|
|
455
464
|
} else {
|
|
456
|
-
await generateApiDocs(targetConfig[id]);
|
|
465
|
+
await generateApiDocs(targetConfig[id], targetDocsPluginId);
|
|
457
466
|
}
|
|
458
467
|
});
|
|
459
468
|
|
|
@@ -470,10 +479,12 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
470
479
|
const pluginId = options.pluginId;
|
|
471
480
|
const pluginInstances = getPluginInstances(plugins);
|
|
472
481
|
let targetConfig: any;
|
|
482
|
+
let targetDocsPluginId: any;
|
|
473
483
|
if (pluginId) {
|
|
474
484
|
try {
|
|
475
485
|
const pluginConfig = getPluginConfig(plugins, pluginId);
|
|
476
486
|
targetConfig = pluginConfig.config ?? {};
|
|
487
|
+
targetDocsPluginId = pluginConfig.docsPluginId;
|
|
477
488
|
} catch {
|
|
478
489
|
console.error(
|
|
479
490
|
chalk.red(`OpenAPI docs plugin ID '${pluginId}' not found.`)
|
|
@@ -526,7 +537,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
526
537
|
...parentConfig,
|
|
527
538
|
...versionConfig,
|
|
528
539
|
};
|
|
529
|
-
await generateApiDocs(mergedConfig);
|
|
540
|
+
await generateApiDocs(mergedConfig, targetDocsPluginId);
|
|
530
541
|
});
|
|
531
542
|
}
|
|
532
543
|
} else if (!versions[versionId]) {
|
|
@@ -542,7 +553,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
542
553
|
...versionConfig,
|
|
543
554
|
};
|
|
544
555
|
await generateVersions(mergedVersions, parentConfig.outputDir);
|
|
545
|
-
await generateApiDocs(mergedConfig);
|
|
556
|
+
await generateApiDocs(mergedConfig, targetDocsPluginId);
|
|
546
557
|
}
|
|
547
558
|
});
|
|
548
559
|
|