docusaurus-theme-openapi-docs 0.0.0-1068 → 0.0.0-1069

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.
@@ -13,7 +13,6 @@ var __importDefault =
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  const react_1 = __importDefault(require("react"));
15
15
  const Translate_1 = require("@docusaurus/Translate");
16
- const translationIds_1 = require("@theme/translationIds");
17
16
  const ArrayBrackets_1 = require("@theme/ArrayBrackets");
18
17
  const Details_1 = __importDefault(require("@theme/Details"));
19
18
  const DiscriminatorTabs_1 = __importDefault(
@@ -23,6 +22,7 @@ const Markdown_1 = __importDefault(require("@theme/Markdown"));
23
22
  const SchemaItem_1 = __importDefault(require("@theme/SchemaItem"));
24
23
  const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
25
24
  const TabItem_1 = __importDefault(require("@theme/TabItem"));
25
+ const translationIds_1 = require("@theme/translationIds");
26
26
  // eslint-disable-next-line import/no-extraneous-dependencies
27
27
  const allof_merge_1 = require("allof-merge");
28
28
  const clsx_1 = __importDefault(require("clsx"));
@@ -116,6 +116,11 @@ const AnyOneOf = ({ schema, schemaType }) => {
116
116
  id: translationIds_1.OPENAPI_SCHEMA_ITEM.ANY_OF,
117
117
  message: "anyOf",
118
118
  });
119
+ // Generate a unique ID for this anyOf/oneOf to prevent tab value collisions
120
+ const uniqueId = react_1.default.useMemo(
121
+ () => Math.random().toString(36).substring(7),
122
+ []
123
+ );
119
124
  return react_1.default.createElement(
120
125
  react_1.default.Fragment,
121
126
  null,
@@ -126,14 +131,31 @@ const AnyOneOf = ({ schema, schemaType }) => {
126
131
  ),
127
132
  react_1.default.createElement(
128
133
  SchemaTabs_1.default,
129
- null,
134
+ { groupId: `schema-${uniqueId}`, lazy: true },
130
135
  schema[key]?.map((anyOneSchema, index) => {
131
- const label = anyOneSchema.title || anyOneSchema.type;
136
+ // Determine label for the tab
137
+ // If schema is just oneOf/anyOf without title/type, use a generic label
138
+ let label = anyOneSchema.title || anyOneSchema.type;
139
+ if (!label) {
140
+ if (anyOneSchema.oneOf) {
141
+ label = (0, Translate_1.translate)({
142
+ id: translationIds_1.OPENAPI_SCHEMA_ITEM.ONE_OF,
143
+ message: "oneOf",
144
+ });
145
+ } else if (anyOneSchema.anyOf) {
146
+ label = (0, Translate_1.translate)({
147
+ id: translationIds_1.OPENAPI_SCHEMA_ITEM.ANY_OF,
148
+ message: "anyOf",
149
+ });
150
+ } else {
151
+ label = `Option ${index + 1}`;
152
+ }
153
+ }
132
154
  return (
133
155
  // @ts-ignore
134
156
  react_1.default.createElement(
135
157
  TabItem_1.default,
136
- { key: index, label: label, value: `${index}-item-properties` },
158
+ { key: index, label: label, value: `${uniqueId}-${index}-item` },
137
159
  (isPrimitive(anyOneSchema) || anyOneSchema.const) &&
138
160
  react_1.default.createElement(SchemaItem_1.default, {
139
161
  collapsible: false,
@@ -162,7 +184,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
162
184
  discriminator: false,
163
185
  children: null,
164
186
  }),
165
- anyOneSchema.type === "object" &&
187
+ (anyOneSchema.type === "object" || !anyOneSchema.type) &&
166
188
  anyOneSchema.properties &&
167
189
  react_1.default.createElement(Properties, {
168
190
  schema: anyOneSchema,
@@ -141,7 +141,10 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
141
141
  };
142
142
  return react_1.default.createElement(
143
143
  "div",
144
- { className: "openapi-tabs__schema-tabs-container" },
144
+ {
145
+ className: "openapi-tabs__schema-tabs-container",
146
+ style: { marginBottom: "1rem" },
147
+ },
145
148
  showTabArrows &&
146
149
  react_1.default.createElement("button", {
147
150
  className: "openapi-tabs__arrow left",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-theme-openapi-docs",
3
3
  "description": "OpenAPI theme for Docusaurus.",
4
- "version": "0.0.0-1068",
4
+ "version": "0.0.0-1069",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -38,7 +38,7 @@
38
38
  "@types/postman-collection": "^3.5.11",
39
39
  "@types/react-modal": "^3.16.3",
40
40
  "concurrently": "^9.2.0",
41
- "docusaurus-plugin-openapi-docs": "0.0.0-1068",
41
+ "docusaurus-plugin-openapi-docs": "0.0.0-1069",
42
42
  "docusaurus-plugin-sass": "^0.2.6",
43
43
  "eslint-plugin-prettier": "^5.5.1"
44
44
  },
@@ -81,5 +81,5 @@
81
81
  "engines": {
82
82
  "node": ">=14"
83
83
  },
84
- "gitHead": "d18835ed938d31e72d4c57d272902a3818eac708"
84
+ "gitHead": "68650d41c8460a20c228d851f869e495c5608796"
85
85
  }
@@ -8,8 +8,6 @@
8
8
  import React from "react";
9
9
 
10
10
  import { translate } from "@docusaurus/Translate";
11
- import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
12
-
13
11
  import { ClosingArrayBracket, OpeningArrayBracket } from "@theme/ArrayBrackets";
14
12
  import Details from "@theme/Details";
15
13
  import DiscriminatorTabs from "@theme/DiscriminatorTabs";
@@ -17,6 +15,7 @@ import Markdown from "@theme/Markdown";
17
15
  import SchemaItem from "@theme/SchemaItem";
18
16
  import SchemaTabs from "@theme/SchemaTabs";
19
17
  import TabItem from "@theme/TabItem";
18
+ import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
20
19
  // eslint-disable-next-line import/no-extraneous-dependencies
21
20
  import { merge } from "allof-merge";
22
21
  import clsx from "clsx";
@@ -132,20 +131,44 @@ const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
132
131
  const type = schema.oneOf
133
132
  ? translate({ id: OPENAPI_SCHEMA_ITEM.ONE_OF, message: "oneOf" })
134
133
  : translate({ id: OPENAPI_SCHEMA_ITEM.ANY_OF, message: "anyOf" });
134
+
135
+ // Generate a unique ID for this anyOf/oneOf to prevent tab value collisions
136
+ const uniqueId = React.useMemo(
137
+ () => Math.random().toString(36).substring(7),
138
+ []
139
+ );
140
+
135
141
  return (
136
142
  <>
137
143
  <span className="badge badge--info" style={{ marginBottom: "1rem" }}>
138
144
  {type}
139
145
  </span>
140
- <SchemaTabs>
146
+ <SchemaTabs groupId={`schema-${uniqueId}`} lazy>
141
147
  {schema[key]?.map((anyOneSchema: any, index: number) => {
142
- const label = anyOneSchema.title || anyOneSchema.type;
148
+ // Determine label for the tab
149
+ // If schema is just oneOf/anyOf without title/type, use a generic label
150
+ let label = anyOneSchema.title || anyOneSchema.type;
151
+ if (!label) {
152
+ if (anyOneSchema.oneOf) {
153
+ label = translate({
154
+ id: OPENAPI_SCHEMA_ITEM.ONE_OF,
155
+ message: "oneOf",
156
+ });
157
+ } else if (anyOneSchema.anyOf) {
158
+ label = translate({
159
+ id: OPENAPI_SCHEMA_ITEM.ANY_OF,
160
+ message: "anyOf",
161
+ });
162
+ } else {
163
+ label = `Option ${index + 1}`;
164
+ }
165
+ }
143
166
  return (
144
167
  // @ts-ignore
145
168
  <TabItem
146
169
  key={index}
147
170
  label={label}
148
- value={`${index}-item-properties`}
171
+ value={`${uniqueId}-${index}-item`}
149
172
  >
150
173
  {/* Handle primitive types directly */}
151
174
  {(isPrimitive(anyOneSchema) || anyOneSchema.const) && (
@@ -178,9 +201,11 @@ const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
178
201
  )}
179
202
 
180
203
  {/* Handle actual object types with properties or nested schemas */}
181
- {anyOneSchema.type === "object" && anyOneSchema.properties && (
182
- <Properties schema={anyOneSchema} schemaType={schemaType} />
183
- )}
204
+ {/* Note: In OpenAPI, properties implies type: object even if not explicitly set */}
205
+ {(anyOneSchema.type === "object" || !anyOneSchema.type) &&
206
+ anyOneSchema.properties && (
207
+ <Properties schema={anyOneSchema} schemaType={schemaType} />
208
+ )}
184
209
  {anyOneSchema.allOf && (
185
210
  <SchemaNode schema={anyOneSchema} schemaType={schemaType} />
186
211
  )}
@@ -115,7 +115,10 @@ function TabList({
115
115
  };
116
116
 
117
117
  return (
118
- <div className="openapi-tabs__schema-tabs-container">
118
+ <div
119
+ className="openapi-tabs__schema-tabs-container"
120
+ style={{ marginBottom: "1rem" }}
121
+ >
119
122
  {showTabArrows && (
120
123
  <button
121
124
  className="openapi-tabs__arrow left"