docusaurus-plugin-openapi-docs 0.0.0-beta.663 → 0.0.0-beta.665
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/markdown/createSchema.js +96 -43
- package/package.json +2 -2
- package/src/markdown/createSchema.ts +105 -48
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.createNodes = exports.mergeAllOf = void 0;
|
|
13
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
10
14
|
const createArrayBracket_1 = require("./createArrayBracket");
|
|
11
15
|
const createDescription_1 = require("./createDescription");
|
|
12
16
|
const createDetails_1 = require("./createDetails");
|
|
@@ -279,35 +283,54 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
279
283
|
className: "schemaItem",
|
|
280
284
|
children: [
|
|
281
285
|
(0, createDetails_1.createDetails)({
|
|
286
|
+
className: "openapi-markdown__details",
|
|
282
287
|
children: [
|
|
283
288
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
284
289
|
children: [
|
|
285
|
-
(0, utils_1.create)("strong", { children: name }),
|
|
286
290
|
(0, utils_1.create)("span", {
|
|
287
|
-
|
|
288
|
-
children:
|
|
291
|
+
className: "openapi-schema__container",
|
|
292
|
+
children: [
|
|
293
|
+
(0, utils_1.create)("strong", {
|
|
294
|
+
className: (0, clsx_1.default)("openapi-schema__property", {
|
|
295
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
296
|
+
}),
|
|
297
|
+
children: name,
|
|
298
|
+
}),
|
|
299
|
+
(0, utils_1.create)("span", {
|
|
300
|
+
className: "openapi-schema__name",
|
|
301
|
+
children: ` ${schemaName}`,
|
|
302
|
+
}),
|
|
303
|
+
(0, utils_1.guard)((Array.isArray(required)
|
|
304
|
+
? required.includes(name)
|
|
305
|
+
: required === true) ||
|
|
306
|
+
schema.deprecated ||
|
|
307
|
+
nullable, () => [
|
|
308
|
+
(0, utils_1.create)("span", {
|
|
309
|
+
className: "openapi-schema__divider",
|
|
310
|
+
}),
|
|
311
|
+
]),
|
|
312
|
+
(0, utils_1.guard)(nullable, () => [
|
|
313
|
+
(0, utils_1.create)("span", {
|
|
314
|
+
className: "openapi-schema__nullable",
|
|
315
|
+
children: "nullable",
|
|
316
|
+
}),
|
|
317
|
+
]),
|
|
318
|
+
(0, utils_1.guard)(Array.isArray(required)
|
|
319
|
+
? required.includes(name)
|
|
320
|
+
: required === true, () => [
|
|
321
|
+
(0, utils_1.create)("span", {
|
|
322
|
+
className: "openapi-schema__required",
|
|
323
|
+
children: "required",
|
|
324
|
+
}),
|
|
325
|
+
]),
|
|
326
|
+
(0, utils_1.guard)(schema.deprecated, () => [
|
|
327
|
+
(0, utils_1.create)("span", {
|
|
328
|
+
className: "openapi-schema__deprecated",
|
|
329
|
+
children: "deprecated",
|
|
330
|
+
}),
|
|
331
|
+
]),
|
|
332
|
+
],
|
|
289
333
|
}),
|
|
290
|
-
(0, utils_1.guard)((schema.nullable && schema.nullable === true) ||
|
|
291
|
-
(nullable && nullable === true), () => [
|
|
292
|
-
(0, utils_1.create)("strong", {
|
|
293
|
-
style: {
|
|
294
|
-
fontSize: "var(--ifm-code-font-size)",
|
|
295
|
-
color: "var(--openapi-nullable)",
|
|
296
|
-
},
|
|
297
|
-
children: " nullable",
|
|
298
|
-
}),
|
|
299
|
-
]),
|
|
300
|
-
(0, utils_1.guard)(Array.isArray(required)
|
|
301
|
-
? required.includes(name)
|
|
302
|
-
: required === true, () => [
|
|
303
|
-
(0, utils_1.create)("strong", {
|
|
304
|
-
style: {
|
|
305
|
-
fontSize: "var(--ifm-code-font-size)",
|
|
306
|
-
color: "var(--openapi-required)",
|
|
307
|
-
},
|
|
308
|
-
children: " required",
|
|
309
|
-
}),
|
|
310
|
-
]),
|
|
311
334
|
],
|
|
312
335
|
}),
|
|
313
336
|
(0, utils_1.create)("div", {
|
|
@@ -340,6 +363,7 @@ function createAnyOneOfProperty(name, schemaName, schema, required, nullable) {
|
|
|
340
363
|
className: "schemaItem",
|
|
341
364
|
children: [
|
|
342
365
|
(0, createDetails_1.createDetails)({
|
|
366
|
+
className: "openapi-markdown__details",
|
|
343
367
|
children: [
|
|
344
368
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
345
369
|
children: [
|
|
@@ -432,26 +456,55 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
432
456
|
if (discriminator.mapping === undefined) {
|
|
433
457
|
return undefined;
|
|
434
458
|
}
|
|
435
|
-
return (0, utils_1.create)("
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
459
|
+
return (0, utils_1.create)("div", {
|
|
460
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
461
|
+
children: (0, utils_1.create)("div", {
|
|
462
|
+
children: [
|
|
463
|
+
(0, utils_1.create)("span", {
|
|
464
|
+
className: "openapi-schema__container",
|
|
465
|
+
children: [
|
|
466
|
+
(0, utils_1.create)("strong", {
|
|
467
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
468
|
+
children: name,
|
|
469
|
+
}),
|
|
470
|
+
(0, utils_1.guard)(schemaName, (name) => (0, utils_1.create)("span", {
|
|
471
|
+
className: "openapi-schema__name",
|
|
472
|
+
children: ` ${schemaName}`,
|
|
473
|
+
})),
|
|
474
|
+
(0, utils_1.guard)(required, () => [
|
|
475
|
+
(0, utils_1.create)("span", {
|
|
476
|
+
className: "openapi-schema__required",
|
|
477
|
+
children: "required",
|
|
478
|
+
}),
|
|
479
|
+
]),
|
|
480
|
+
],
|
|
452
481
|
}),
|
|
453
|
-
|
|
454
|
-
|
|
482
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(discriminator), (message) => (0, utils_1.create)("div", {
|
|
483
|
+
style: {
|
|
484
|
+
paddingLeft: "1rem",
|
|
485
|
+
},
|
|
486
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
487
|
+
})),
|
|
488
|
+
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
489
|
+
style: {
|
|
490
|
+
paddingLeft: "1rem",
|
|
491
|
+
},
|
|
492
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
493
|
+
})),
|
|
494
|
+
(0, utils_1.create)("DiscriminatorTabs", {
|
|
495
|
+
className: "openapi-tabs__discriminator",
|
|
496
|
+
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
497
|
+
const label = key;
|
|
498
|
+
return (0, utils_1.create)("TabItem", {
|
|
499
|
+
// className: "openapi-tabs__discriminator-item",
|
|
500
|
+
label: label,
|
|
501
|
+
value: `${index}-item-discriminator`,
|
|
502
|
+
children: [createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key])],
|
|
503
|
+
});
|
|
504
|
+
}),
|
|
505
|
+
}),
|
|
506
|
+
],
|
|
507
|
+
}),
|
|
455
508
|
});
|
|
456
509
|
}
|
|
457
510
|
/**
|
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.
|
|
4
|
+
"version": "0.0.0-beta.665",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=14"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "4a6fb40ab26563fec58509e1f0c3eeb9c82a6f6d"
|
|
64
64
|
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
|
|
8
10
|
import { SchemaObject } from "../openapi/types";
|
|
9
11
|
import {
|
|
10
12
|
createClosingArrayBracket,
|
|
@@ -338,41 +340,60 @@ function createDetailsNode(
|
|
|
338
340
|
className: "schemaItem",
|
|
339
341
|
children: [
|
|
340
342
|
createDetails({
|
|
343
|
+
className: "openapi-markdown__details",
|
|
341
344
|
children: [
|
|
342
345
|
createDetailsSummary({
|
|
343
346
|
children: [
|
|
344
|
-
create("strong", { children: name }),
|
|
345
347
|
create("span", {
|
|
346
|
-
|
|
347
|
-
children:
|
|
348
|
-
}),
|
|
349
|
-
guard(
|
|
350
|
-
(schema.nullable && schema.nullable === true) ||
|
|
351
|
-
(nullable && nullable === true),
|
|
352
|
-
() => [
|
|
348
|
+
className: "openapi-schema__container",
|
|
349
|
+
children: [
|
|
353
350
|
create("strong", {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
children: " nullable",
|
|
351
|
+
className: clsx("openapi-schema__property", {
|
|
352
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
353
|
+
}),
|
|
354
|
+
children: name,
|
|
359
355
|
}),
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
Array.isArray(required)
|
|
364
|
-
? required.includes(name)
|
|
365
|
-
: required === true,
|
|
366
|
-
() => [
|
|
367
|
-
create("strong", {
|
|
368
|
-
style: {
|
|
369
|
-
fontSize: "var(--ifm-code-font-size)",
|
|
370
|
-
color: "var(--openapi-required)",
|
|
371
|
-
},
|
|
372
|
-
children: " required",
|
|
356
|
+
create("span", {
|
|
357
|
+
className: "openapi-schema__name",
|
|
358
|
+
children: ` ${schemaName}`,
|
|
373
359
|
}),
|
|
374
|
-
|
|
375
|
-
|
|
360
|
+
guard(
|
|
361
|
+
(Array.isArray(required)
|
|
362
|
+
? required.includes(name)
|
|
363
|
+
: required === true) ||
|
|
364
|
+
schema.deprecated ||
|
|
365
|
+
nullable,
|
|
366
|
+
() => [
|
|
367
|
+
create("span", {
|
|
368
|
+
className: "openapi-schema__divider",
|
|
369
|
+
}),
|
|
370
|
+
]
|
|
371
|
+
),
|
|
372
|
+
guard(nullable, () => [
|
|
373
|
+
create("span", {
|
|
374
|
+
className: "openapi-schema__nullable",
|
|
375
|
+
children: "nullable",
|
|
376
|
+
}),
|
|
377
|
+
]),
|
|
378
|
+
guard(
|
|
379
|
+
Array.isArray(required)
|
|
380
|
+
? required.includes(name)
|
|
381
|
+
: required === true,
|
|
382
|
+
() => [
|
|
383
|
+
create("span", {
|
|
384
|
+
className: "openapi-schema__required",
|
|
385
|
+
children: "required",
|
|
386
|
+
}),
|
|
387
|
+
]
|
|
388
|
+
),
|
|
389
|
+
guard(schema.deprecated, () => [
|
|
390
|
+
create("span", {
|
|
391
|
+
className: "openapi-schema__deprecated",
|
|
392
|
+
children: "deprecated",
|
|
393
|
+
}),
|
|
394
|
+
]),
|
|
395
|
+
],
|
|
396
|
+
}),
|
|
376
397
|
],
|
|
377
398
|
}),
|
|
378
399
|
create("div", {
|
|
@@ -416,6 +437,7 @@ function createAnyOneOfProperty(
|
|
|
416
437
|
className: "schemaItem",
|
|
417
438
|
children: [
|
|
418
439
|
createDetails({
|
|
440
|
+
className: "openapi-markdown__details",
|
|
419
441
|
children: [
|
|
420
442
|
createDetailsSummary({
|
|
421
443
|
children: [
|
|
@@ -519,7 +541,7 @@ function createPropertyDiscriminator(
|
|
|
519
541
|
schema: SchemaObject,
|
|
520
542
|
discriminator: any,
|
|
521
543
|
required: string[] | boolean
|
|
522
|
-
) {
|
|
544
|
+
): any {
|
|
523
545
|
if (schema === undefined) {
|
|
524
546
|
return undefined;
|
|
525
547
|
}
|
|
@@ -528,26 +550,61 @@ function createPropertyDiscriminator(
|
|
|
528
550
|
return undefined;
|
|
529
551
|
}
|
|
530
552
|
|
|
531
|
-
return create("
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
553
|
+
return create("div", {
|
|
554
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
555
|
+
children: create("div", {
|
|
556
|
+
children: [
|
|
557
|
+
create("span", {
|
|
558
|
+
className: "openapi-schema__container",
|
|
559
|
+
children: [
|
|
560
|
+
create("strong", {
|
|
561
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
562
|
+
children: name,
|
|
563
|
+
}),
|
|
564
|
+
guard(schemaName, (name) =>
|
|
565
|
+
create("span", {
|
|
566
|
+
className: "openapi-schema__name",
|
|
567
|
+
children: ` ${schemaName}`,
|
|
568
|
+
})
|
|
569
|
+
),
|
|
570
|
+
guard(required, () => [
|
|
571
|
+
create("span", {
|
|
572
|
+
className: "openapi-schema__required",
|
|
573
|
+
children: "required",
|
|
574
|
+
}),
|
|
575
|
+
]),
|
|
576
|
+
],
|
|
548
577
|
}),
|
|
549
|
-
|
|
550
|
-
|
|
578
|
+
guard(getQualifierMessage(discriminator), (message) =>
|
|
579
|
+
create("div", {
|
|
580
|
+
style: {
|
|
581
|
+
paddingLeft: "1rem",
|
|
582
|
+
},
|
|
583
|
+
children: createDescription(message),
|
|
584
|
+
})
|
|
585
|
+
),
|
|
586
|
+
guard(schema.description, (description) =>
|
|
587
|
+
create("div", {
|
|
588
|
+
style: {
|
|
589
|
+
paddingLeft: "1rem",
|
|
590
|
+
},
|
|
591
|
+
children: createDescription(description),
|
|
592
|
+
})
|
|
593
|
+
),
|
|
594
|
+
create("DiscriminatorTabs", {
|
|
595
|
+
className: "openapi-tabs__discriminator",
|
|
596
|
+
children: Object.keys(discriminator?.mapping!).map((key, index) => {
|
|
597
|
+
const label = key;
|
|
598
|
+
return create("TabItem", {
|
|
599
|
+
// className: "openapi-tabs__discriminator-item",
|
|
600
|
+
label: label,
|
|
601
|
+
value: `${index}-item-discriminator`,
|
|
602
|
+
children: [createNodes(discriminator?.mapping[key])],
|
|
603
|
+
});
|
|
604
|
+
}),
|
|
605
|
+
}),
|
|
606
|
+
],
|
|
607
|
+
}),
|
|
551
608
|
});
|
|
552
609
|
}
|
|
553
610
|
|