docusaurus-plugin-openapi-docs 1.7.2 → 1.7.3
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/markdown/createRequestSchema.js +167 -101
- package/lib/markdown/createResponseSchema.js +167 -101
- package/lib/openapi/utils/loadAndResolveSpec.js +9 -2
- 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/markdown/createRequestSchema.ts +192 -125
- package/src/markdown/createResponseSchema.ts +192 -125
- package/src/openapi/utils/loadAndResolveSpec.ts +10 -1
- package/src/options.ts +7 -0
- package/src/types.ts +7 -0
|
@@ -48,7 +48,7 @@ exports.mergeAllOf = mergeAllOf;
|
|
|
48
48
|
*/
|
|
49
49
|
function createAnyOneOf(schema) {
|
|
50
50
|
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
51
|
-
return (0, utils_1.create)("
|
|
51
|
+
return (0, utils_1.create)("div", {
|
|
52
52
|
children: [
|
|
53
53
|
(0, utils_1.create)("span", {
|
|
54
54
|
className: "badge badge--info",
|
|
@@ -62,12 +62,15 @@ function createAnyOneOf(schema) {
|
|
|
62
62
|
const anyOneChildren = [];
|
|
63
63
|
if (anyOneSchema.properties !== undefined) {
|
|
64
64
|
anyOneChildren.push(createProperties(anyOneSchema));
|
|
65
|
+
delete anyOneSchema.properties;
|
|
65
66
|
}
|
|
66
67
|
if (anyOneSchema.allOf !== undefined) {
|
|
67
68
|
anyOneChildren.push(createNodes(anyOneSchema));
|
|
69
|
+
delete anyOneSchema.allOf;
|
|
68
70
|
}
|
|
69
71
|
if (anyOneSchema.items !== undefined) {
|
|
70
72
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
73
|
+
delete anyOneSchema.items;
|
|
71
74
|
}
|
|
72
75
|
if (anyOneSchema.type === "string" ||
|
|
73
76
|
anyOneSchema.type === "number" ||
|
|
@@ -145,6 +148,18 @@ function createAdditionalProperties(schema) {
|
|
|
145
148
|
// }
|
|
146
149
|
const additionalProperties = schema.additionalProperties;
|
|
147
150
|
const type = additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.type;
|
|
151
|
+
// Handle free-form objects
|
|
152
|
+
if (String(additionalProperties) === "true" && schema.type === "object") {
|
|
153
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
154
|
+
name: "property name*",
|
|
155
|
+
required: false,
|
|
156
|
+
schemaName: "any",
|
|
157
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema.additionalProperties),
|
|
158
|
+
schema: schema,
|
|
159
|
+
collapsible: false,
|
|
160
|
+
discriminator: false,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
148
163
|
if ((type === "object" || type === "array") &&
|
|
149
164
|
((additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.properties) ||
|
|
150
165
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.items) ||
|
|
@@ -153,9 +168,9 @@ function createAdditionalProperties(schema) {
|
|
|
153
168
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.oneOf) ||
|
|
154
169
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.anyOf))) {
|
|
155
170
|
const title = additionalProperties.title;
|
|
156
|
-
const schemaName =
|
|
171
|
+
const schemaName = (0, schema_1.getSchemaName)(additionalProperties);
|
|
157
172
|
const required = (_a = schema.required) !== null && _a !== void 0 ? _a : false;
|
|
158
|
-
return createDetailsNode("property name*", schemaName, additionalProperties, required, schema.nullable);
|
|
173
|
+
return createDetailsNode("property name*", title !== null && title !== void 0 ? title : schemaName, additionalProperties, required, schema.nullable);
|
|
159
174
|
}
|
|
160
175
|
if (((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "string" ||
|
|
161
176
|
((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "object" ||
|
|
@@ -165,41 +180,26 @@ function createAdditionalProperties(schema) {
|
|
|
165
180
|
const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
|
|
166
181
|
if (additionalProperties !== undefined) {
|
|
167
182
|
const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
|
|
168
|
-
const
|
|
169
|
-
return (0, utils_1.create)("
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
(0, utils_1.guard)(format, (format) => (0, utils_1.create)("span", {
|
|
178
|
-
style: { opacity: "0.6" },
|
|
179
|
-
children: ` (${format})`,
|
|
180
|
-
})),
|
|
181
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.additionalProperties), (message) => (0, utils_1.create)("div", {
|
|
182
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
183
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
184
|
-
})),
|
|
185
|
-
],
|
|
186
|
-
}),
|
|
183
|
+
const schemaName = (0, schema_1.getSchemaName)((_k = schema.additionalProperties) === null || _k === void 0 ? void 0 : _k.additionalProperties);
|
|
184
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
185
|
+
name: "property name*",
|
|
186
|
+
required: false,
|
|
187
|
+
schemaName: schemaName !== null && schemaName !== void 0 ? schemaName : type,
|
|
188
|
+
qualifierMessage: (_l = schema.additionalProperties) !== null && _l !== void 0 ? _l : (0, schema_1.getQualifierMessage)(schema.additionalProperties),
|
|
189
|
+
schema: schema,
|
|
190
|
+
collapsible: false,
|
|
191
|
+
discriminator: false,
|
|
187
192
|
});
|
|
188
193
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
199
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
200
|
-
})),
|
|
201
|
-
],
|
|
202
|
-
}),
|
|
194
|
+
const schemaName = (0, schema_1.getSchemaName)(schema.additionalProperties);
|
|
195
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
196
|
+
name: "property name*",
|
|
197
|
+
required: false,
|
|
198
|
+
schemaName: schemaName,
|
|
199
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
200
|
+
schema: schema.additionalProperties,
|
|
201
|
+
collapsible: false,
|
|
202
|
+
discriminator: false,
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
return Object.entries(schema.additionalProperties).map(([key, val]) => createEdges({
|
|
@@ -443,6 +443,86 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
443
443
|
],
|
|
444
444
|
});
|
|
445
445
|
}
|
|
446
|
+
function createOneOfProperty(name, schemaName, schema, required, nullable) {
|
|
447
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
448
|
+
collapsible: true,
|
|
449
|
+
className: "schemaItem",
|
|
450
|
+
children: [
|
|
451
|
+
(0, createDetails_1.createDetails)({
|
|
452
|
+
children: [
|
|
453
|
+
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
454
|
+
children: [
|
|
455
|
+
(0, utils_1.create)("strong", { children: name }),
|
|
456
|
+
(0, utils_1.create)("span", {
|
|
457
|
+
style: { opacity: "0.6" },
|
|
458
|
+
children: ` ${schemaName}`,
|
|
459
|
+
}),
|
|
460
|
+
(0, utils_1.guard)((schema.nullable && schema.nullable === true) ||
|
|
461
|
+
(nullable && nullable === true), () => [
|
|
462
|
+
(0, utils_1.create)("strong", {
|
|
463
|
+
style: {
|
|
464
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
465
|
+
color: "var(--openapi-nullable)",
|
|
466
|
+
},
|
|
467
|
+
children: " nullable",
|
|
468
|
+
}),
|
|
469
|
+
]),
|
|
470
|
+
(0, utils_1.guard)(Array.isArray(required)
|
|
471
|
+
? required.includes(name)
|
|
472
|
+
: required === true, () => [
|
|
473
|
+
(0, utils_1.create)("strong", {
|
|
474
|
+
style: {
|
|
475
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
476
|
+
color: "var(--openapi-required)",
|
|
477
|
+
},
|
|
478
|
+
children: " required",
|
|
479
|
+
}),
|
|
480
|
+
]),
|
|
481
|
+
],
|
|
482
|
+
}),
|
|
483
|
+
(0, utils_1.create)("div", {
|
|
484
|
+
style: { marginLeft: "1rem" },
|
|
485
|
+
children: [
|
|
486
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
487
|
+
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
488
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
489
|
+
})),
|
|
490
|
+
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
491
|
+
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
492
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
493
|
+
})),
|
|
494
|
+
],
|
|
495
|
+
}),
|
|
496
|
+
(0, utils_1.create)("div", {
|
|
497
|
+
children: [
|
|
498
|
+
(0, utils_1.create)("span", {
|
|
499
|
+
className: "badge badge--info",
|
|
500
|
+
children: "oneOf",
|
|
501
|
+
}),
|
|
502
|
+
(0, utils_1.create)("SchemaTabs", {
|
|
503
|
+
children: schema["oneOf"].map((property, index) => {
|
|
504
|
+
var _a;
|
|
505
|
+
const label = (_a = property.type) !== null && _a !== void 0 ? _a : `MOD${index + 1}`;
|
|
506
|
+
return (0, utils_1.create)("TabItem", {
|
|
507
|
+
label: label,
|
|
508
|
+
value: `${index}-property`,
|
|
509
|
+
children: [
|
|
510
|
+
(0, utils_1.create)("p", { children: label }),
|
|
511
|
+
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
512
|
+
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
513
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
514
|
+
})),
|
|
515
|
+
],
|
|
516
|
+
});
|
|
517
|
+
}),
|
|
518
|
+
}),
|
|
519
|
+
],
|
|
520
|
+
}),
|
|
521
|
+
],
|
|
522
|
+
}),
|
|
523
|
+
],
|
|
524
|
+
});
|
|
525
|
+
}
|
|
446
526
|
/**
|
|
447
527
|
* For handling discriminators that map to a same-level property (like 'petType').
|
|
448
528
|
* Note: These should only be encountered while iterating through properties.
|
|
@@ -454,53 +534,26 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
454
534
|
if (discriminator.mapping === undefined) {
|
|
455
535
|
return undefined;
|
|
456
536
|
}
|
|
457
|
-
return (0, utils_1.create)("
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
children:
|
|
473
|
-
})
|
|
474
|
-
]),
|
|
475
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(discriminator), (message) => (0, utils_1.create)("div", {
|
|
476
|
-
style: {
|
|
477
|
-
paddingLeft: "1rem",
|
|
478
|
-
},
|
|
479
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
480
|
-
})),
|
|
481
|
-
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
482
|
-
style: {
|
|
483
|
-
paddingLeft: "1rem",
|
|
484
|
-
},
|
|
485
|
-
children: (0, createDescription_1.createDescription)(description),
|
|
486
|
-
})),
|
|
487
|
-
(0, utils_1.create)("DiscriminatorTabs", {
|
|
488
|
-
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
489
|
-
const label = key;
|
|
490
|
-
return (0, utils_1.create)("TabItem", {
|
|
491
|
-
label: label,
|
|
492
|
-
value: `${index}-item-discriminator`,
|
|
493
|
-
children: [
|
|
494
|
-
(0, utils_1.create)("div", {
|
|
495
|
-
style: { marginLeft: "-4px" },
|
|
496
|
-
children: createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key]),
|
|
497
|
-
}),
|
|
498
|
-
],
|
|
499
|
-
});
|
|
500
|
-
}),
|
|
537
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
538
|
+
name,
|
|
539
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
540
|
+
schemaName: schemaName,
|
|
541
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
542
|
+
schema: schema,
|
|
543
|
+
collapsible: false,
|
|
544
|
+
discriminator: true,
|
|
545
|
+
children: [
|
|
546
|
+
(0, utils_1.create)("DiscriminatorTabs", {
|
|
547
|
+
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
548
|
+
const label = key;
|
|
549
|
+
return (0, utils_1.create)("TabItem", {
|
|
550
|
+
label: label,
|
|
551
|
+
value: `${index}-item-discriminator`,
|
|
552
|
+
children: createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key]),
|
|
553
|
+
});
|
|
501
554
|
}),
|
|
502
|
-
|
|
503
|
-
|
|
555
|
+
}),
|
|
556
|
+
],
|
|
504
557
|
});
|
|
505
558
|
}
|
|
506
559
|
/**
|
|
@@ -513,7 +566,7 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
513
566
|
return createPropertyDiscriminator(name, "string", schema, discriminator, required);
|
|
514
567
|
}
|
|
515
568
|
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
516
|
-
return
|
|
569
|
+
return createOneOfProperty(name, schemaName, schema, required, schema.nullable);
|
|
517
570
|
}
|
|
518
571
|
if (schema.allOf !== undefined) {
|
|
519
572
|
const { mergedSchemas, required, } = mergeAllOf(schema.allOf);
|
|
@@ -605,24 +658,37 @@ function createNodes(schema) {
|
|
|
605
658
|
}
|
|
606
659
|
// primitive
|
|
607
660
|
if (schema.type !== undefined) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
661
|
+
if (schema.allOf) {
|
|
662
|
+
//handle circular result in allOf
|
|
663
|
+
if (schema.allOf.length && typeof schema.allOf[0] === "string") {
|
|
664
|
+
return (0, utils_1.create)("div", {
|
|
665
|
+
style: {
|
|
666
|
+
marginTop: ".5rem",
|
|
667
|
+
marginBottom: ".5rem",
|
|
668
|
+
marginLeft: "1rem",
|
|
669
|
+
},
|
|
670
|
+
children: (0, createDescription_1.createDescription)(schema.allOf[0]),
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return (0, utils_1.create)("div", {
|
|
675
|
+
style: {
|
|
676
|
+
marginTop: ".5rem",
|
|
677
|
+
marginBottom: ".5rem",
|
|
678
|
+
marginLeft: "1rem",
|
|
679
|
+
},
|
|
680
|
+
children: (0, createDescription_1.createDescription)(schema.type),
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
// handle circular references
|
|
684
|
+
if (typeof schema === "string") {
|
|
685
|
+
return (0, utils_1.create)("div", {
|
|
686
|
+
style: {
|
|
687
|
+
marginTop: ".5rem",
|
|
688
|
+
marginBottom: ".5rem",
|
|
689
|
+
marginLeft: "1rem",
|
|
690
|
+
},
|
|
691
|
+
children: [(0, createDescription_1.createDescription)(schema)],
|
|
626
692
|
});
|
|
627
693
|
}
|
|
628
694
|
// Unknown node/schema type should return undefined
|
|
@@ -74,7 +74,6 @@ function convertSwagger2OpenAPI(spec) {
|
|
|
74
74
|
}
|
|
75
75
|
exports.convertSwagger2OpenAPI = convertSwagger2OpenAPI;
|
|
76
76
|
async function resolveJsonRefs(specUrlOrObject) {
|
|
77
|
-
var _a, _b;
|
|
78
77
|
try {
|
|
79
78
|
let schema = await json_schema_ref_parser_1.default.dereference(specUrlOrObject, {
|
|
80
79
|
continueOnError: true,
|
|
@@ -92,7 +91,15 @@ async function resolveJsonRefs(specUrlOrObject) {
|
|
|
92
91
|
return schema;
|
|
93
92
|
}
|
|
94
93
|
catch (err) {
|
|
95
|
-
|
|
94
|
+
let errorMsg = "";
|
|
95
|
+
if (err.errors[0] !== undefined) {
|
|
96
|
+
const error = err.errors[0];
|
|
97
|
+
errorMsg = `Error: [${error.message}] with footprint [${error.footprint}]`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
errorMsg = err;
|
|
101
|
+
}
|
|
102
|
+
console.error(chalk_1.default.yellow(errorMsg));
|
|
96
103
|
return;
|
|
97
104
|
}
|
|
98
105
|
}
|
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": "1.7.
|
|
4
|
+
"version": "1.7.3",
|
|
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": "b30ae6acf881863cb2422bce775f1d9fe6f0fcb6"
|
|
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);
|