docusaurus-plugin-openapi-docs 0.0.0-610 → 0.0.0-611
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 +8 -4
- package/lib/options.js +6 -0
- package/lib/types.d.ts +6 -0
- package/package.json +2 -2
- package/src/index.ts +18 -5
- package/src/options.ts +7 -0
- package/src/types.ts +7 -0
package/lib/index.js
CHANGED
|
@@ -76,7 +76,8 @@ function pluginOpenAPIDocs(context, options) {
|
|
|
76
76
|
let docRouteBasePath = docData ? docData.routeBasePath : undefined;
|
|
77
77
|
let docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
|
|
78
78
|
async function generateApiDocs(options, pluginId) {
|
|
79
|
-
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
let { specPath, outputDir, template, markdownGenerators, downloadUrl, sidebarOptions, } = options;
|
|
80
81
|
// Remove trailing slash before proceeding
|
|
81
82
|
outputDir = outputDir.replace(/\/$/, "");
|
|
82
83
|
// Override docPath if pluginId provided
|
|
@@ -193,6 +194,9 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
193
194
|
<DocCardList items={useCurrentSidebarCategory().items}/>
|
|
194
195
|
\`\`\`
|
|
195
196
|
`;
|
|
197
|
+
const apiPageGenerator = (_a = markdownGenerators === null || markdownGenerators === void 0 ? void 0 : markdownGenerators.createApiPageMD) !== null && _a !== void 0 ? _a : markdown_1.createApiPageMD;
|
|
198
|
+
const infoPageGenerator = (_b = markdownGenerators === null || markdownGenerators === void 0 ? void 0 : markdownGenerators.createInfoPageMD) !== null && _b !== void 0 ? _b : markdown_1.createInfoPageMD;
|
|
199
|
+
const tagPageGenerator = (_c = markdownGenerators === null || markdownGenerators === void 0 ? void 0 : markdownGenerators.createTagPageMD) !== null && _c !== void 0 ? _c : markdown_1.createTagPageMD;
|
|
196
200
|
loadedApi.map(async (item) => {
|
|
197
201
|
if (item.type === "info") {
|
|
198
202
|
if (downloadUrl && isURL(downloadUrl)) {
|
|
@@ -200,10 +204,10 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
const markdown = item.type === "api"
|
|
203
|
-
? (
|
|
207
|
+
? apiPageGenerator(item)
|
|
204
208
|
: item.type === "info"
|
|
205
|
-
? (
|
|
206
|
-
: (
|
|
209
|
+
? infoPageGenerator(item)
|
|
210
|
+
: tagPageGenerator(item);
|
|
207
211
|
item.markdown = markdown;
|
|
208
212
|
if (item.type === "api") {
|
|
209
213
|
item.json = JSON.stringify(item.api);
|
package/lib/options.js
CHANGED
|
@@ -16,6 +16,11 @@ const sidebarOptions = utils_validation_1.Joi.object({
|
|
|
16
16
|
sidebarCollapsible: utils_validation_1.Joi.boolean(),
|
|
17
17
|
sidebarCollapsed: utils_validation_1.Joi.boolean(),
|
|
18
18
|
});
|
|
19
|
+
const markdownGenerators = utils_validation_1.Joi.object({
|
|
20
|
+
createApiPageMD: utils_validation_1.Joi.function(),
|
|
21
|
+
createInfoPageMD: utils_validation_1.Joi.function(),
|
|
22
|
+
createTagPageMD: utils_validation_1.Joi.function(),
|
|
23
|
+
});
|
|
19
24
|
exports.OptionsSchema = utils_validation_1.Joi.object({
|
|
20
25
|
id: utils_validation_1.Joi.string().required(),
|
|
21
26
|
docsPluginId: utils_validation_1.Joi.string().required(),
|
|
@@ -29,6 +34,7 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
|
|
|
29
34
|
hideSendButton: utils_validation_1.Joi.boolean(),
|
|
30
35
|
showExtensions: utils_validation_1.Joi.boolean(),
|
|
31
36
|
sidebarOptions: sidebarOptions,
|
|
37
|
+
markdownGenerators: markdownGenerators,
|
|
32
38
|
version: utils_validation_1.Joi.string().when("versions", {
|
|
33
39
|
is: utils_validation_1.Joi.exist(),
|
|
34
40
|
then: utils_validation_1.Joi.required(),
|
package/lib/types.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export interface APIOptions {
|
|
|
23
23
|
[key: string]: APIVersionOptions;
|
|
24
24
|
};
|
|
25
25
|
proxy?: string;
|
|
26
|
+
markdownGenerators?: MarkdownGenerator;
|
|
27
|
+
}
|
|
28
|
+
export interface MarkdownGenerator {
|
|
29
|
+
createApiPageMD?: (pageData: ApiPageMetadata) => string;
|
|
30
|
+
createInfoPageMD?: (pageData: InfoPageMetadata) => string;
|
|
31
|
+
createTagPageMD?: (pageData: TagPageMetadata) => string;
|
|
26
32
|
}
|
|
27
33
|
export interface SidebarOptions {
|
|
28
34
|
groupPathsBy?: 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-
|
|
4
|
+
"version": "0.0.0-611",
|
|
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": "1b35ad875493d06bd7028ceac72c963ecea21c25"
|
|
72
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -91,8 +91,14 @@ export default function pluginOpenAPIDocs(
|
|
|
91
91
|
let docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
|
|
92
92
|
|
|
93
93
|
async function generateApiDocs(options: APIOptions, pluginId: any) {
|
|
94
|
-
let {
|
|
95
|
-
|
|
94
|
+
let {
|
|
95
|
+
specPath,
|
|
96
|
+
outputDir,
|
|
97
|
+
template,
|
|
98
|
+
markdownGenerators,
|
|
99
|
+
downloadUrl,
|
|
100
|
+
sidebarOptions,
|
|
101
|
+
} = options;
|
|
96
102
|
|
|
97
103
|
// Remove trailing slash before proceeding
|
|
98
104
|
outputDir = outputDir.replace(/\/$/, "");
|
|
@@ -237,6 +243,13 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
237
243
|
\`\`\`
|
|
238
244
|
`;
|
|
239
245
|
|
|
246
|
+
const apiPageGenerator =
|
|
247
|
+
markdownGenerators?.createApiPageMD ?? createApiPageMD;
|
|
248
|
+
const infoPageGenerator =
|
|
249
|
+
markdownGenerators?.createInfoPageMD ?? createInfoPageMD;
|
|
250
|
+
const tagPageGenerator =
|
|
251
|
+
markdownGenerators?.createTagPageMD ?? createTagPageMD;
|
|
252
|
+
|
|
240
253
|
loadedApi.map(async (item) => {
|
|
241
254
|
if (item.type === "info") {
|
|
242
255
|
if (downloadUrl && isURL(downloadUrl)) {
|
|
@@ -245,10 +258,10 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
245
258
|
}
|
|
246
259
|
const markdown =
|
|
247
260
|
item.type === "api"
|
|
248
|
-
?
|
|
261
|
+
? apiPageGenerator(item)
|
|
249
262
|
: item.type === "info"
|
|
250
|
-
?
|
|
251
|
-
:
|
|
263
|
+
? infoPageGenerator(item)
|
|
264
|
+
: tagPageGenerator(item);
|
|
252
265
|
item.markdown = markdown;
|
|
253
266
|
if (item.type === "api") {
|
|
254
267
|
item.json = JSON.stringify(item.api);
|
package/src/options.ts
CHANGED
|
@@ -16,6 +16,12 @@ const sidebarOptions = Joi.object({
|
|
|
16
16
|
sidebarCollapsed: Joi.boolean(),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
+
const markdownGenerators = Joi.object({
|
|
20
|
+
createApiPageMD: Joi.function(),
|
|
21
|
+
createInfoPageMD: Joi.function(),
|
|
22
|
+
createTagPageMD: Joi.function(),
|
|
23
|
+
});
|
|
24
|
+
|
|
19
25
|
export const OptionsSchema = Joi.object({
|
|
20
26
|
id: Joi.string().required(),
|
|
21
27
|
docsPluginId: Joi.string().required(),
|
|
@@ -31,6 +37,7 @@ export const OptionsSchema = Joi.object({
|
|
|
31
37
|
hideSendButton: Joi.boolean(),
|
|
32
38
|
showExtensions: Joi.boolean(),
|
|
33
39
|
sidebarOptions: sidebarOptions,
|
|
40
|
+
markdownGenerators: markdownGenerators,
|
|
34
41
|
version: Joi.string().when("versions", {
|
|
35
42
|
is: Joi.exist(),
|
|
36
43
|
then: Joi.required(),
|
package/src/types.ts
CHANGED
|
@@ -43,6 +43,13 @@ export interface APIOptions {
|
|
|
43
43
|
[key: string]: APIVersionOptions;
|
|
44
44
|
};
|
|
45
45
|
proxy?: string;
|
|
46
|
+
markdownGenerators?: MarkdownGenerator;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface MarkdownGenerator {
|
|
50
|
+
createApiPageMD?: (pageData: ApiPageMetadata) => string;
|
|
51
|
+
createInfoPageMD?: (pageData: InfoPageMetadata) => string;
|
|
52
|
+
createTagPageMD?: (pageData: TagPageMetadata) => string;
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
export interface SidebarOptions {
|