docusaurus-plugin-openapi-docs 0.0.0-724 → 0.0.0-727

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.
@@ -88,12 +88,6 @@ function createRequestSchema({ title, body, ...rest }) {
88
88
  if (firstBody === undefined) {
89
89
  return undefined;
90
90
  }
91
- // we don't show the table if there is no properties to show
92
- if (firstBody.properties !== undefined) {
93
- if (Object.keys(firstBody.properties).length === 0) {
94
- return undefined;
95
- }
96
- }
97
91
  return (0, utils_1.create)("MimeTabs", {
98
92
  className: "openapi-tabs__mime",
99
93
  children: [
@@ -36,11 +36,6 @@ function createResponseSchema({ title, body, ...rest }) {
36
36
  responseExamples === undefined) {
37
37
  return undefined;
38
38
  }
39
- if ((firstBody === null || firstBody === void 0 ? void 0 : firstBody.properties) !== undefined) {
40
- if (Object.keys(firstBody === null || firstBody === void 0 ? void 0 : firstBody.properties).length === 0) {
41
- return undefined;
42
- }
43
- }
44
39
  return (0, utils_1.create)("TabItem", {
45
40
  label: `${mimeType}`,
46
41
  value: `${mimeType}`,
@@ -116,6 +116,16 @@ function createAnyOneOf(schema) {
116
116
  */
117
117
  function createProperties(schema) {
118
118
  const discriminator = schema.discriminator;
119
+ if (Object.keys(schema.properties).length === 0) {
120
+ return (0, utils_1.create)("SchemaItem", {
121
+ collapsible: false,
122
+ name: "",
123
+ required: false,
124
+ schemaName: "object",
125
+ qualifierMessage: undefined,
126
+ schema: {},
127
+ });
128
+ }
119
129
  return Object.entries(schema.properties).map(([key, val]) => {
120
130
  return createEdges({
121
131
  name: key,
@@ -483,6 +493,16 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
483
493
  */
484
494
  function createEdges({ name, schema, required, discriminator, }) {
485
495
  var _a, _b, _c, _d;
496
+ if (SCHEMA_TYPE === "request") {
497
+ if (schema.readOnly && schema.readOnly === true) {
498
+ return undefined;
499
+ }
500
+ }
501
+ if (SCHEMA_TYPE === "response") {
502
+ if (schema.writeOnly && schema.writeOnly === true) {
503
+ return undefined;
504
+ }
505
+ }
486
506
  const schemaName = (0, schema_1.getSchemaName)(schema);
487
507
  if (discriminator !== undefined && discriminator.propertyName === name) {
488
508
  return createPropertyDiscriminator(name, "string", schema, discriminator, required);
@@ -492,6 +512,16 @@ function createEdges({ name, schema, required, discriminator, }) {
492
512
  }
493
513
  if (schema.allOf !== undefined) {
494
514
  const { mergedSchemas } = mergeAllOf(schema.allOf);
515
+ if (SCHEMA_TYPE === "request") {
516
+ if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
517
+ return undefined;
518
+ }
519
+ }
520
+ if (SCHEMA_TYPE === "response") {
521
+ if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
522
+ return undefined;
523
+ }
524
+ }
495
525
  const mergedSchemaName = (0, schema_1.getSchemaName)(mergedSchemas);
496
526
  if (mergedSchemas.oneOf !== undefined ||
497
527
  mergedSchemas.anyOf !== undefined) {
@@ -507,16 +537,6 @@ function createEdges({ name, schema, required, discriminator, }) {
507
537
  if (((_a = mergedSchemas.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
508
538
  return createDetailsNode(name, mergedSchemaName, mergedSchemas, required, schema.nullable);
509
539
  }
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
540
  return (0, utils_1.create)("SchemaItem", {
521
541
  collapsible: false,
522
542
  name,
@@ -539,16 +559,6 @@ function createEdges({ name, schema, required, discriminator, }) {
539
559
  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
560
  return createDetailsNode(name, schemaName, schema, required, schema.nullable);
541
561
  }
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
562
  // primitives and array of non-objects
553
563
  return (0, utils_1.create)("SchemaItem", {
554
564
  collapsible: false,
@@ -564,6 +574,16 @@ function createEdges({ name, schema, required, discriminator, }) {
564
574
  */
565
575
  function createNodes(schema, schemaType) {
566
576
  SCHEMA_TYPE = schemaType;
577
+ if (SCHEMA_TYPE === "request") {
578
+ if (schema.readOnly && schema.readOnly === true) {
579
+ return undefined;
580
+ }
581
+ }
582
+ if (SCHEMA_TYPE === "response") {
583
+ if (schema.writeOnly && schema.writeOnly === true) {
584
+ return undefined;
585
+ }
586
+ }
567
587
  const nodes = [];
568
588
  // if (schema.discriminator !== undefined) {
569
589
  // return createDiscriminator(schema);
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-724",
4
+ "version": "0.0.0-727",
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": "210bdf060a30737037cd96cf410991c2401d7d45"
63
+ "gitHead": "aecd4b5fa86c36310c4176dad9961d7fb8386edf"
64
64
  }
@@ -108,12 +108,6 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
108
108
  return undefined;
109
109
  }
110
110
 
111
- // we don't show the table if there is no properties to show
112
- if (firstBody.properties !== undefined) {
113
- if (Object.keys(firstBody.properties).length === 0) {
114
- return undefined;
115
- }
116
- }
117
111
  return create("MimeTabs", {
118
112
  className: "openapi-tabs__mime",
119
113
  children: [
@@ -60,12 +60,6 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
60
60
  return undefined;
61
61
  }
62
62
 
63
- if (firstBody?.properties !== undefined) {
64
- if (Object.keys(firstBody?.properties).length === 0) {
65
- return undefined;
66
- }
67
- }
68
-
69
63
  return create("TabItem", {
70
64
  label: `${mimeType}`,
71
65
  value: `${mimeType}`,
@@ -129,6 +129,16 @@ function createAnyOneOf(schema: SchemaObject): any {
129
129
  */
130
130
  function createProperties(schema: SchemaObject) {
131
131
  const discriminator = schema.discriminator;
132
+ if (Object.keys(schema.properties!).length === 0) {
133
+ return create("SchemaItem", {
134
+ collapsible: false,
135
+ name: "",
136
+ required: false,
137
+ schemaName: "object",
138
+ qualifierMessage: undefined,
139
+ schema: {},
140
+ });
141
+ }
132
142
  return Object.entries(schema.properties!).map(([key, val]) => {
133
143
  return createEdges({
134
144
  name: key,
@@ -594,6 +604,18 @@ function createEdges({
594
604
  required,
595
605
  discriminator,
596
606
  }: EdgeProps): any {
607
+ if (SCHEMA_TYPE === "request") {
608
+ if (schema.readOnly && schema.readOnly === true) {
609
+ return undefined;
610
+ }
611
+ }
612
+
613
+ if (SCHEMA_TYPE === "response") {
614
+ if (schema.writeOnly && schema.writeOnly === true) {
615
+ return undefined;
616
+ }
617
+ }
618
+
597
619
  const schemaName = getSchemaName(schema);
598
620
  if (discriminator !== undefined && discriminator.propertyName === name) {
599
621
  return createPropertyDiscriminator(
@@ -619,6 +641,19 @@ function createEdges({
619
641
  const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
620
642
  schema.allOf
621
643
  );
644
+
645
+ if (SCHEMA_TYPE === "request") {
646
+ if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
647
+ return undefined;
648
+ }
649
+ }
650
+
651
+ if (SCHEMA_TYPE === "response") {
652
+ if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
653
+ return undefined;
654
+ }
655
+ }
656
+
622
657
  const mergedSchemaName = getSchemaName(mergedSchemas);
623
658
  if (
624
659
  mergedSchemas.oneOf !== undefined ||
@@ -664,18 +699,6 @@ function createEdges({
664
699
  );
665
700
  }
666
701
 
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
702
  return create("SchemaItem", {
680
703
  collapsible: false,
681
704
  name,
@@ -727,18 +750,6 @@ function createEdges({
727
750
  );
728
751
  }
729
752
 
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
753
  // primitives and array of non-objects
743
754
  return create("SchemaItem", {
744
755
  collapsible: false,
@@ -758,6 +769,17 @@ export function createNodes(
758
769
  schemaType: "request" | "response"
759
770
  ): any {
760
771
  SCHEMA_TYPE = schemaType;
772
+ if (SCHEMA_TYPE === "request") {
773
+ if (schema.readOnly && schema.readOnly === true) {
774
+ return undefined;
775
+ }
776
+ }
777
+
778
+ if (SCHEMA_TYPE === "response") {
779
+ if (schema.writeOnly && schema.writeOnly === true) {
780
+ return undefined;
781
+ }
782
+ }
761
783
  const nodes = [];
762
784
  // if (schema.discriminator !== undefined) {
763
785
  // return createDiscriminator(schema);