docusaurus-plugin-openapi-docs 0.0.0-723 → 0.0.0-726
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 +30 -20
- package/lib/markdown/utils.d.ts +3 -0
- package/lib/markdown/utils.js +22 -1
- package/package.json +2 -2
- package/src/markdown/createSchema.ts +36 -24
- package/src/markdown/utils.ts +22 -0
|
@@ -483,6 +483,16 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
483
483
|
*/
|
|
484
484
|
function createEdges({ name, schema, required, discriminator, }) {
|
|
485
485
|
var _a, _b, _c, _d;
|
|
486
|
+
if (SCHEMA_TYPE === "request") {
|
|
487
|
+
if (schema.readOnly && schema.readOnly === true) {
|
|
488
|
+
return undefined;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (SCHEMA_TYPE === "response") {
|
|
492
|
+
if (schema.writeOnly && schema.writeOnly === true) {
|
|
493
|
+
return undefined;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
486
496
|
const schemaName = (0, schema_1.getSchemaName)(schema);
|
|
487
497
|
if (discriminator !== undefined && discriminator.propertyName === name) {
|
|
488
498
|
return createPropertyDiscriminator(name, "string", schema, discriminator, required);
|
|
@@ -492,6 +502,16 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
492
502
|
}
|
|
493
503
|
if (schema.allOf !== undefined) {
|
|
494
504
|
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
505
|
+
if (SCHEMA_TYPE === "request") {
|
|
506
|
+
if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
|
|
507
|
+
return undefined;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (SCHEMA_TYPE === "response") {
|
|
511
|
+
if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
|
|
512
|
+
return undefined;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
495
515
|
const mergedSchemaName = (0, schema_1.getSchemaName)(mergedSchemas);
|
|
496
516
|
if (mergedSchemas.oneOf !== undefined ||
|
|
497
517
|
mergedSchemas.anyOf !== undefined) {
|
|
@@ -507,16 +527,6 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
507
527
|
if (((_a = mergedSchemas.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
|
|
508
528
|
return createDetailsNode(name, mergedSchemaName, mergedSchemas, required, schema.nullable);
|
|
509
529
|
}
|
|
510
|
-
if (SCHEMA_TYPE === "request") {
|
|
511
|
-
if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
|
|
512
|
-
return undefined;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
if (SCHEMA_TYPE === "response") {
|
|
516
|
-
if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
|
|
517
|
-
return undefined;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
530
|
return (0, utils_1.create)("SchemaItem", {
|
|
521
531
|
collapsible: false,
|
|
522
532
|
name,
|
|
@@ -539,16 +549,6 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
539
549
|
if (((_c = schema.items) === null || _c === void 0 ? void 0 : _c.anyOf) !== undefined || ((_d = schema.items) === null || _d === void 0 ? void 0 : _d.oneOf) !== undefined) {
|
|
540
550
|
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
541
551
|
}
|
|
542
|
-
if (SCHEMA_TYPE === "request") {
|
|
543
|
-
if (schema.readOnly && schema.readOnly === true) {
|
|
544
|
-
return undefined;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
if (SCHEMA_TYPE === "response") {
|
|
548
|
-
if (schema.writeOnly && schema.writeOnly === true) {
|
|
549
|
-
return undefined;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
552
|
// primitives and array of non-objects
|
|
553
553
|
return (0, utils_1.create)("SchemaItem", {
|
|
554
554
|
collapsible: false,
|
|
@@ -564,6 +564,16 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
564
564
|
*/
|
|
565
565
|
function createNodes(schema, schemaType) {
|
|
566
566
|
SCHEMA_TYPE = schemaType;
|
|
567
|
+
if (SCHEMA_TYPE === "request") {
|
|
568
|
+
if (schema.readOnly && schema.readOnly === true) {
|
|
569
|
+
return undefined;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if (SCHEMA_TYPE === "response") {
|
|
573
|
+
if (schema.writeOnly && schema.writeOnly === true) {
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
567
577
|
const nodes = [];
|
|
568
578
|
// if (schema.discriminator !== undefined) {
|
|
569
579
|
// return createDiscriminator(schema);
|
package/lib/markdown/utils.d.ts
CHANGED
|
@@ -8,3 +8,6 @@ export declare function render(children: Children): string;
|
|
|
8
8
|
export declare const lessThan: RegExp;
|
|
9
9
|
export declare const greaterThan: RegExp;
|
|
10
10
|
export declare const codeFence: RegExp;
|
|
11
|
+
export declare const curlyBrackets: RegExp;
|
|
12
|
+
export declare const codeBlock: RegExp;
|
|
13
|
+
export declare function clean(value: string | undefined): string;
|
package/lib/markdown/utils.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.codeFence = exports.greaterThan = exports.lessThan = exports.render = exports.guard = exports.create = void 0;
|
|
9
|
+
exports.clean = exports.codeBlock = exports.curlyBrackets = exports.codeFence = exports.greaterThan = exports.lessThan = exports.render = exports.guard = exports.create = void 0;
|
|
10
10
|
function create(tag, props) {
|
|
11
11
|
const { children, ...rest } = props;
|
|
12
12
|
let propString = "";
|
|
@@ -38,3 +38,24 @@ exports.render = render;
|
|
|
38
38
|
exports.lessThan = /<(?!(=|button|\s?\/button|code|\s?\/code|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|thead|\s?\/thead|tbody|\s?\/tbody|td|\s?\/td|tr|\s?\/tr|th|\s?\/th|h1|\s?\/h1|h2|\s?\/h2|h3|\s?\/h3|h4|\s?\/h4|h5|\s?\/h5|h6|\s?\/h6|title|\s?\/title|p|\s?\/p|em|\s?\/em|b|\s?\/b|i|\s?\/i|u|\s?\/u|strike|\s?\/strike|bold|\s?\/bold|a|\s?\/a|table|\s?\/table|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|svg|\s?\/svg|div|\s?\/div|center|\s?\/center))/gu;
|
|
39
39
|
exports.greaterThan = /(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|bold|a|li|ol|ul|img|svg|div|center|\/|\s|"|'))>/gu;
|
|
40
40
|
exports.codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
|
|
41
|
+
exports.curlyBrackets = /([{}])/g;
|
|
42
|
+
exports.codeBlock = /(^```.*[\s\S]*?```$|`[^`].+?`)/gm;
|
|
43
|
+
function clean(value) {
|
|
44
|
+
if (!value) {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
let sections = value.split(exports.codeBlock);
|
|
48
|
+
for (let sectionIndex in sections) {
|
|
49
|
+
if (!sections[sectionIndex].startsWith("`")) {
|
|
50
|
+
sections[sectionIndex] = sections[sectionIndex]
|
|
51
|
+
.replace(exports.lessThan, "<")
|
|
52
|
+
.replace(exports.greaterThan, ">")
|
|
53
|
+
.replace(exports.codeFence, function (match) {
|
|
54
|
+
return match.replace(/\\>/g, ">");
|
|
55
|
+
})
|
|
56
|
+
.replace(exports.curlyBrackets, "\\$1");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return sections.join("");
|
|
60
|
+
}
|
|
61
|
+
exports.clean = clean;
|
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-726",
|
|
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": "39c0a0f621f4595e62c79565a54ca50bc6f9908d"
|
|
64
64
|
}
|
|
@@ -594,6 +594,18 @@ function createEdges({
|
|
|
594
594
|
required,
|
|
595
595
|
discriminator,
|
|
596
596
|
}: EdgeProps): any {
|
|
597
|
+
if (SCHEMA_TYPE === "request") {
|
|
598
|
+
if (schema.readOnly && schema.readOnly === true) {
|
|
599
|
+
return undefined;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if (SCHEMA_TYPE === "response") {
|
|
604
|
+
if (schema.writeOnly && schema.writeOnly === true) {
|
|
605
|
+
return undefined;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
597
609
|
const schemaName = getSchemaName(schema);
|
|
598
610
|
if (discriminator !== undefined && discriminator.propertyName === name) {
|
|
599
611
|
return createPropertyDiscriminator(
|
|
@@ -619,6 +631,19 @@ function createEdges({
|
|
|
619
631
|
const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
|
|
620
632
|
schema.allOf
|
|
621
633
|
);
|
|
634
|
+
|
|
635
|
+
if (SCHEMA_TYPE === "request") {
|
|
636
|
+
if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
|
|
637
|
+
return undefined;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
if (SCHEMA_TYPE === "response") {
|
|
642
|
+
if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
|
|
643
|
+
return undefined;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
622
647
|
const mergedSchemaName = getSchemaName(mergedSchemas);
|
|
623
648
|
if (
|
|
624
649
|
mergedSchemas.oneOf !== undefined ||
|
|
@@ -664,18 +689,6 @@ function createEdges({
|
|
|
664
689
|
);
|
|
665
690
|
}
|
|
666
691
|
|
|
667
|
-
if (SCHEMA_TYPE === "request") {
|
|
668
|
-
if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
|
|
669
|
-
return undefined;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
if (SCHEMA_TYPE === "response") {
|
|
674
|
-
if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
|
|
675
|
-
return undefined;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
692
|
return create("SchemaItem", {
|
|
680
693
|
collapsible: false,
|
|
681
694
|
name,
|
|
@@ -727,18 +740,6 @@ function createEdges({
|
|
|
727
740
|
);
|
|
728
741
|
}
|
|
729
742
|
|
|
730
|
-
if (SCHEMA_TYPE === "request") {
|
|
731
|
-
if (schema.readOnly && schema.readOnly === true) {
|
|
732
|
-
return undefined;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
if (SCHEMA_TYPE === "response") {
|
|
737
|
-
if (schema.writeOnly && schema.writeOnly === true) {
|
|
738
|
-
return undefined;
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
|
|
742
743
|
// primitives and array of non-objects
|
|
743
744
|
return create("SchemaItem", {
|
|
744
745
|
collapsible: false,
|
|
@@ -758,6 +759,17 @@ export function createNodes(
|
|
|
758
759
|
schemaType: "request" | "response"
|
|
759
760
|
): any {
|
|
760
761
|
SCHEMA_TYPE = schemaType;
|
|
762
|
+
if (SCHEMA_TYPE === "request") {
|
|
763
|
+
if (schema.readOnly && schema.readOnly === true) {
|
|
764
|
+
return undefined;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
if (SCHEMA_TYPE === "response") {
|
|
769
|
+
if (schema.writeOnly && schema.writeOnly === true) {
|
|
770
|
+
return undefined;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
761
773
|
const nodes = [];
|
|
762
774
|
// if (schema.discriminator !== undefined) {
|
|
763
775
|
// return createDiscriminator(schema);
|
package/src/markdown/utils.ts
CHANGED
|
@@ -47,3 +47,25 @@ export const lessThan =
|
|
|
47
47
|
export const greaterThan =
|
|
48
48
|
/(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|bold|a|li|ol|ul|img|svg|div|center|\/|\s|"|'))>/gu;
|
|
49
49
|
export const codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
|
|
50
|
+
export const curlyBrackets = /([{}])/g;
|
|
51
|
+
export const codeBlock = /(^```.*[\s\S]*?```$|`[^`].+?`)/gm;
|
|
52
|
+
|
|
53
|
+
export function clean(value: string | undefined): string {
|
|
54
|
+
if (!value) {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let sections = value.split(codeBlock);
|
|
59
|
+
for (let sectionIndex in sections) {
|
|
60
|
+
if (!sections[sectionIndex].startsWith("`")) {
|
|
61
|
+
sections[sectionIndex] = sections[sectionIndex]
|
|
62
|
+
.replace(lessThan, "<")
|
|
63
|
+
.replace(greaterThan, ">")
|
|
64
|
+
.replace(codeFence, function (match) {
|
|
65
|
+
return match.replace(/\\>/g, ">");
|
|
66
|
+
})
|
|
67
|
+
.replace(curlyBrackets, "\\$1");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return sections.join("");
|
|
71
|
+
}
|