docusaurus-theme-openapi-docs 0.0.0-939 → 0.0.0-941

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.
@@ -53,6 +53,7 @@ function DocItemLayout({ children }) {
53
53
  const { metadata } = (0, client_1.useDoc)();
54
54
  const { frontMatter } = (0, client_1.useDoc)();
55
55
  const api = frontMatter.api;
56
+ const schema = frontMatter.schema;
56
57
  return react_1.default.createElement(
57
58
  "div",
58
59
  { className: "row" },
@@ -86,7 +87,7 @@ function DocItemLayout({ children }) {
86
87
  {
87
88
  className: (0, clsx_1.default)(
88
89
  "col",
89
- api ? "col--7" : "col--12"
90
+ api || schema ? "col--7" : "col--12"
90
91
  ),
91
92
  },
92
93
  react_1.default.createElement(Footer_1.default, null)
@@ -99,7 +100,10 @@ function DocItemLayout({ children }) {
99
100
  react_1.default.createElement(
100
101
  "div",
101
102
  {
102
- className: (0, clsx_1.default)("col", api ? "col--7" : "col--12"),
103
+ className: (0, clsx_1.default)(
104
+ "col",
105
+ api || schema ? "col--7" : "col--12"
106
+ ),
103
107
  },
104
108
  react_1.default.createElement(Paginator_1.default, null)
105
109
  )
@@ -26,6 +26,7 @@ const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
26
26
  const slice_1 = require("@theme/ApiExplorer/Authorization/slice");
27
27
  const persistanceMiddleware_1 = require("@theme/ApiExplorer/persistanceMiddleware");
28
28
  const Layout_1 = __importDefault(require("@theme/ApiItem/Layout"));
29
+ const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
29
30
  const Metadata_1 = __importDefault(require("@theme/DocItem/Metadata"));
30
31
  const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
31
32
  const clsx_1 = __importDefault(require("clsx"));
@@ -43,6 +44,7 @@ function ApiItem(props) {
43
44
  const { info_path: infoPath } = frontMatter;
44
45
  let { api } = frontMatter;
45
46
  const { schema } = frontMatter;
47
+ const { sample } = frontMatter;
46
48
  // decompress and parse
47
49
  if (api) {
48
50
  try {
@@ -183,8 +185,17 @@ function ApiItem(props) {
183
185
  { className: (0, clsx_1.default)("row", "theme-api-markdown") },
184
186
  react_1.default.createElement(
185
187
  "div",
186
- { className: "col col--12" },
188
+ { className: "col col--7 openapi-left-panel__container schema" },
187
189
  react_1.default.createElement(MDXComponent, null)
190
+ ),
191
+ react_1.default.createElement(
192
+ "div",
193
+ { className: "col col--5 openapi-right-panel__container" },
194
+ react_1.default.createElement(
195
+ CodeBlock_1.default,
196
+ { language: "json", title: `${frontMatter.title}` },
197
+ JSON.stringify(sample, null, 2)
198
+ )
188
199
  )
189
200
  )
190
201
  )
@@ -6,7 +6,6 @@
6
6
  * ========================================================================== */
7
7
  .openapi-tabs__container {
8
8
  margin-left: -1px;
9
- margin-bottom: var(--ifm-leading);
10
9
  }
11
10
 
12
11
  .openapi-tabs__response-header {
@@ -183,6 +183,20 @@ const AnyOneOf = ({ schema, schemaType }) => {
183
183
  };
184
184
  const Properties = ({ schema, schemaType }) => {
185
185
  const discriminator = schema.discriminator;
186
+ if (discriminator && !discriminator.mapping) {
187
+ const anyOneOf = schema.oneOf ?? schema.anyOf ?? {};
188
+ const inferredMapping = {};
189
+ Object.entries(anyOneOf).map(([_, anyOneSchema]) => {
190
+ // ensure discriminated property only renders once
191
+ if (
192
+ schema.properties[discriminator.propertyName] &&
193
+ anyOneSchema.properties[discriminator.propertyName]
194
+ )
195
+ delete anyOneSchema.properties[discriminator.propertyName];
196
+ return (inferredMapping[anyOneSchema.title] = anyOneSchema);
197
+ });
198
+ discriminator["mapping"] = inferredMapping;
199
+ }
186
200
  if (Object.keys(schema.properties).length === 0) {
187
201
  return react_1.default.createElement(SchemaItem_1.default, {
188
202
  collapsible: false,
@@ -221,71 +235,143 @@ const PropertyDiscriminator = ({
221
235
  if (!schema) {
222
236
  return null;
223
237
  }
224
- if (discriminator.mapping === undefined) {
225
- return react_1.default.createElement(SchemaEdge, {
226
- name: name,
227
- schema: schema,
228
- required: required,
229
- schemaName: schemaName,
230
- schemaType: schemaType,
231
- });
232
- }
233
238
  return react_1.default.createElement(
234
- "div",
235
- { className: "openapi-discriminator__item openapi-schema__list-item" },
239
+ react_1.default.Fragment,
240
+ null,
236
241
  react_1.default.createElement(
237
242
  "div",
238
- null,
243
+ { className: "openapi-discriminator__item openapi-schema__list-item" },
239
244
  react_1.default.createElement(
240
- "span",
241
- { className: "openapi-schema__container" },
245
+ "div",
246
+ null,
242
247
  react_1.default.createElement(
243
- "strong",
244
- { className: "openapi-discriminator__name openapi-schema__property" },
245
- name
246
- ),
247
- schemaName &&
248
+ "span",
249
+ { className: "openapi-schema__container" },
248
250
  react_1.default.createElement(
249
- "span",
250
- { className: "openapi-schema__name" },
251
- " ",
252
- schemaName
251
+ "strong",
252
+ {
253
+ className: "openapi-discriminator__name openapi-schema__property",
254
+ },
255
+ name
253
256
  ),
254
- required &&
255
- react_1.default.createElement(
256
- "span",
257
- { className: "openapi-schema__required" },
258
- "required"
259
- )
260
- ),
261
- react_1.default.createElement(
262
- "div",
263
- { style: { marginLeft: "1rem" } },
264
- schema.description &&
265
- react_1.default.createElement(Markdown, { text: schema.description }),
266
- (0, schema_1.getQualifierMessage)(discriminator) &&
267
- react_1.default.createElement(Markdown, {
268
- text: (0, schema_1.getQualifierMessage)(discriminator),
269
- })
270
- ),
271
- react_1.default.createElement(
272
- DiscriminatorTabs_1.default,
273
- { className: "openapi-tabs__discriminator" },
274
- Object.keys(discriminator.mapping).map((key, index) =>
275
- // @ts-ignore
276
- react_1.default.createElement(
277
- TabItem_1.default,
278
- { key: index, label: key, value: `${index}-item-discriminator` },
279
- react_1.default.createElement(SchemaNode, {
280
- schema: discriminator.mapping[key],
281
- schemaType: schemaType,
257
+ schemaName &&
258
+ react_1.default.createElement(
259
+ "span",
260
+ { className: "openapi-schema__name" },
261
+ " ",
262
+ schemaName
263
+ ),
264
+ required &&
265
+ react_1.default.createElement("span", {
266
+ className: "openapi-schema__divider",
267
+ }),
268
+ required &&
269
+ react_1.default.createElement(
270
+ "span",
271
+ { className: "openapi-schema__required" },
272
+ "required"
273
+ )
274
+ ),
275
+ react_1.default.createElement(
276
+ "div",
277
+ { style: { marginLeft: "1rem" } },
278
+ schema.description &&
279
+ react_1.default.createElement(Markdown, {
280
+ text: schema.description,
281
+ }),
282
+ (0, schema_1.getQualifierMessage)(discriminator) &&
283
+ react_1.default.createElement(Markdown, {
284
+ text: (0, schema_1.getQualifierMessage)(discriminator),
282
285
  })
286
+ ),
287
+ react_1.default.createElement(
288
+ DiscriminatorTabs_1.default,
289
+ { className: "openapi-tabs__discriminator" },
290
+ Object.keys(discriminator.mapping).map((key, index) =>
291
+ // @ts-ignore
292
+ react_1.default.createElement(
293
+ TabItem_1.default,
294
+ { key: index, label: key, value: `${index}-item-discriminator` },
295
+ react_1.default.createElement(SchemaNode, {
296
+ schema: discriminator.mapping[key],
297
+ schemaType: schemaType,
298
+ })
299
+ )
283
300
  )
284
301
  )
285
302
  )
286
- )
303
+ ),
304
+ schema.properties &&
305
+ Object.entries(schema.properties).map(
306
+ ([key, val]) =>
307
+ key !== discriminator.propertyName &&
308
+ react_1.default.createElement(SchemaEdge, {
309
+ key: key,
310
+ name: key,
311
+ schema: val,
312
+ required: Array.isArray(schema.required)
313
+ ? schema.required.includes(key)
314
+ : false,
315
+ discriminator: false,
316
+ schemaType: schemaType,
317
+ })
318
+ )
287
319
  );
288
320
  };
321
+ const DiscriminatorNode = ({ discriminator, schema, schemaType }) => {
322
+ let discriminatedSchemas = {};
323
+ let inferredMapping = {};
324
+ const discriminatorProperty = schema.properties[discriminator.propertyName];
325
+ if (schema.allOf) {
326
+ const mergedSchemas = mergeAllOf(schema);
327
+ if (mergedSchemas.oneOf || mergedSchemas.anyOf) {
328
+ discriminatedSchemas = mergedSchemas.oneOf || mergedSchemas.anyOf;
329
+ }
330
+ } else if (schema.oneOf || schema.anyOf) {
331
+ discriminatedSchemas = schema.oneOf || schema.anyOf;
332
+ }
333
+ // Handle case where no mapping is defined
334
+ if (!discriminator.mapping) {
335
+ Object.entries(discriminatedSchemas).forEach(([_, subschema], index) => {
336
+ inferredMapping[subschema.title ?? `PROP${index}`] = subschema;
337
+ });
338
+ discriminator.mapping = inferredMapping;
339
+ }
340
+ // Merge sub schema discriminator property with parent
341
+ Object.keys(discriminator.mapping).forEach((key) => {
342
+ const subSchema = discriminator.mapping[key];
343
+ // Handle discriminated schema with allOf
344
+ let mergedSubSchema = {};
345
+ if (subSchema.allOf) {
346
+ mergedSubSchema = mergeAllOf(subSchema);
347
+ }
348
+ const subProperties = subSchema.properties || mergedSubSchema.properties;
349
+ if (subProperties[discriminator.propertyName]) {
350
+ schema.properties[discriminator.propertyName] = {
351
+ ...schema.properties[discriminator.propertyName],
352
+ ...subProperties[discriminator.propertyName],
353
+ };
354
+ if (subSchema.required && !schema.required) {
355
+ schema.required = subSchema.required;
356
+ }
357
+ // Avoid duplicating property
358
+ delete subProperties[discriminator.propertyName];
359
+ }
360
+ });
361
+ const name = discriminator.propertyName;
362
+ const schemaName = (0, schema_1.getSchemaName)(discriminatorProperty);
363
+ // Default case for discriminator without oneOf/anyOf/allOf
364
+ return react_1.default.createElement(PropertyDiscriminator, {
365
+ name: name,
366
+ schemaName: schemaName,
367
+ schema: schema,
368
+ schemaType: schemaType,
369
+ discriminator: discriminator,
370
+ required: Array.isArray(schema.required)
371
+ ? schema.required.includes(name)
372
+ : schema.required,
373
+ });
374
+ };
289
375
  const AdditionalProperties = ({ schema, schemaType }) => {
290
376
  const additionalProperties = schema.additionalProperties;
291
377
  if (!additionalProperties) return null;
@@ -690,6 +776,15 @@ const SchemaNode = ({ schema, schemaType }) => {
690
776
  ) {
691
777
  return null;
692
778
  }
779
+ if (schema.discriminator) {
780
+ const { discriminator } = schema;
781
+ return react_1.default.createElement(DiscriminatorNode, {
782
+ discriminator: discriminator,
783
+ schema: schema,
784
+ schemaType: schemaType,
785
+ });
786
+ }
787
+ // Handle allOf, oneOf, anyOf without discriminators
693
788
  if (schema.allOf) {
694
789
  const mergedSchemas = mergeAllOf(schema);
695
790
  if (
@@ -723,6 +818,12 @@ const SchemaNode = ({ schema, schemaType }) => {
723
818
  })
724
819
  );
725
820
  }
821
+ if (schema.oneOf || schema.anyOf) {
822
+ return react_1.default.createElement(AnyOneOf, {
823
+ schema: schema,
824
+ schemaType: schemaType,
825
+ });
826
+ }
726
827
  // Handle primitives
727
828
  if (
728
829
  schema.type &&
@@ -93,16 +93,16 @@
93
93
  height: 100%;
94
94
  }
95
95
 
96
- @media (min-width: 997px) {
97
- .docItemCol {
98
- max-width: 75% !important;
99
- }
100
-
101
- /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
102
- .tocMobile {
103
- display: none;
104
- }
105
- }
96
+ // @media (min-width: 997px) {
97
+ // .docItemCol {
98
+ // max-width: 75% !important;
99
+ // }
100
+
101
+ // /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
102
+ // .tocMobile {
103
+ // display: none;
104
+ // }
105
+ // }
106
106
 
107
107
  /* Begin OpenAPI theme styles */
108
108
  // [data-theme="dark"] {
@@ -161,6 +161,12 @@
161
161
  border-right: thin solid var(--ifm-toc-border-color);
162
162
  }
163
163
 
164
+ @media (max-width: 997px) {
165
+ .schema {
166
+ margin-bottom: 1rem;
167
+ }
168
+ }
169
+
164
170
  .openapi-tabs__heading {
165
171
  margin-bottom: 1rem;
166
172
  }
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-939",
4
+ "version": "0.0.0-941",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -43,7 +43,7 @@
43
43
  "clsx": "^1.1.1",
44
44
  "copy-text-to-clipboard": "^3.1.0",
45
45
  "crypto-js": "^4.1.1",
46
- "docusaurus-plugin-openapi-docs": "0.0.0-939",
46
+ "docusaurus-plugin-openapi-docs": "0.0.0-941",
47
47
  "docusaurus-plugin-sass": "^0.2.3",
48
48
  "file-saver": "^2.0.5",
49
49
  "lodash": "^4.17.20",
@@ -59,8 +59,8 @@
59
59
  "react-redux": "^7.2.0",
60
60
  "rehype-raw": "^6.1.1",
61
61
  "remark-gfm": "3.0.1",
62
- "sass": "^1.58.1",
63
- "sass-loader": "^13.3.2",
62
+ "sass": "^1.80.4",
63
+ "sass-loader": "^16.0.2",
64
64
  "webpack": "^5.61.0",
65
65
  "xml-formatter": "^2.6.1"
66
66
  },
@@ -71,5 +71,5 @@
71
71
  "engines": {
72
72
  "node": ">=14"
73
73
  },
74
- "gitHead": "a5d3c2f5f5615038a44bb175811196f8be913503"
74
+ "gitHead": "64f0f2dd6de011ae7970b6340fa63e41d79a9232"
75
75
  }
@@ -52,6 +52,7 @@ export default function DocItemLayout({ children }: Props): JSX.Element {
52
52
  const { metadata } = useDoc();
53
53
  const { frontMatter } = useDoc();
54
54
  const api = frontMatter.api;
55
+ const schema = frontMatter.schema;
55
56
  return (
56
57
  <div className="row">
57
58
  <div className={clsx("col", !docTOC.hidden && styles.docItemCol)}>
@@ -64,13 +65,15 @@ export default function DocItemLayout({ children }: Props): JSX.Element {
64
65
  {docTOC.mobile}
65
66
  <DocItemContent>{children}</DocItemContent>
66
67
  <div className="row">
67
- <div className={clsx("col", api ? "col--7" : "col--12")}>
68
+ <div
69
+ className={clsx("col", api || schema ? "col--7" : "col--12")}
70
+ >
68
71
  <DocItemFooter />
69
72
  </div>
70
73
  </div>
71
74
  </article>
72
75
  <div className="row">
73
- <div className={clsx("col", api ? "col--7" : "col--12")}>
76
+ <div className={clsx("col", api || schema ? "col--7" : "col--12")}>
74
77
  <DocItemPaginator />
75
78
  </div>
76
79
  </div>
@@ -18,6 +18,7 @@ import useIsBrowser from "@docusaurus/useIsBrowser";
18
18
  import { createAuth } from "@theme/ApiExplorer/Authorization/slice";
19
19
  import { createPersistanceMiddleware } from "@theme/ApiExplorer/persistanceMiddleware";
20
20
  import DocItemLayout from "@theme/ApiItem/Layout";
21
+ import CodeBlock from "@theme/CodeBlock";
21
22
  import type { Props } from "@theme/DocItem";
22
23
  import DocItemMetadata from "@theme/DocItem/Metadata";
23
24
  import SkeletonLoader from "@theme/SkeletonLoader";
@@ -47,6 +48,10 @@ interface SchemaFrontMatter extends DocFrontMatter {
47
48
  readonly schema?: boolean;
48
49
  }
49
50
 
51
+ interface SampleFrontMatter extends DocFrontMatter {
52
+ readonly sample?: any;
53
+ }
54
+
50
55
  // @ts-ignore
51
56
  export default function ApiItem(props: Props): JSX.Element {
52
57
  const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
@@ -55,6 +60,7 @@ export default function ApiItem(props: Props): JSX.Element {
55
60
  const { info_path: infoPath } = frontMatter as DocFrontMatter;
56
61
  let { api } = frontMatter as ApiFrontMatter;
57
62
  const { schema } = frontMatter as SchemaFrontMatter;
63
+ const { sample } = frontMatter as SampleFrontMatter;
58
64
  // decompress and parse
59
65
  if (api) {
60
66
  try {
@@ -172,9 +178,14 @@ export default function ApiItem(props: Props): JSX.Element {
172
178
  <DocItemMetadata />
173
179
  <DocItemLayout>
174
180
  <div className={clsx("row", "theme-api-markdown")}>
175
- <div className="col col--12">
181
+ <div className="col col--7 openapi-left-panel__container schema">
176
182
  <MDXComponent />
177
183
  </div>
184
+ <div className="col col--5 openapi-right-panel__container">
185
+ <CodeBlock language="json" title={`${frontMatter.title}`}>
186
+ {JSON.stringify(sample, null, 2)}
187
+ </CodeBlock>
188
+ </div>
178
189
  </div>
179
190
  </DocItemLayout>
180
191
  </HtmlClassNameProvider>
@@ -6,7 +6,6 @@
6
6
  * ========================================================================== */
7
7
  .openapi-tabs__container {
8
8
  margin-left: -1px;
9
- margin-bottom: var(--ifm-leading);
10
9
  }
11
10
 
12
11
  .openapi-tabs__response-header {
@@ -184,6 +184,20 @@ const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
184
184
 
185
185
  const Properties: React.FC<SchemaProps> = ({ schema, schemaType }) => {
186
186
  const discriminator = schema.discriminator;
187
+ if (discriminator && !discriminator.mapping) {
188
+ const anyOneOf = schema.oneOf ?? schema.anyOf ?? {};
189
+ const inferredMapping = {} as any;
190
+ Object.entries(anyOneOf).map(([_, anyOneSchema]: [string, any]) => {
191
+ // ensure discriminated property only renders once
192
+ if (
193
+ schema.properties![discriminator.propertyName] &&
194
+ anyOneSchema.properties[discriminator.propertyName]
195
+ )
196
+ delete anyOneSchema.properties[discriminator.propertyName];
197
+ return (inferredMapping[anyOneSchema.title] = anyOneSchema);
198
+ });
199
+ discriminator["mapping"] = inferredMapping;
200
+ }
187
201
  if (Object.keys(schema.properties as {}).length === 0) {
188
202
  return (
189
203
  <SchemaItem
@@ -196,6 +210,7 @@ const Properties: React.FC<SchemaProps> = ({ schema, schemaType }) => {
196
210
  />
197
211
  );
198
212
  }
213
+
199
214
  return (
200
215
  <>
201
216
  {Object.entries(schema.properties as {}).map(
@@ -230,55 +245,143 @@ const PropertyDiscriminator: React.FC<SchemaEdgeProps> = ({
230
245
  return null;
231
246
  }
232
247
 
233
- if (discriminator.mapping === undefined) {
234
- return (
235
- <SchemaEdge
236
- name={name}
237
- schema={schema}
238
- required={required}
239
- schemaName={schemaName}
240
- schemaType={schemaType}
241
- />
242
- );
243
- }
244
-
245
248
  return (
246
- <div className="openapi-discriminator__item openapi-schema__list-item">
247
- <div>
248
- <span className="openapi-schema__container">
249
- <strong className="openapi-discriminator__name openapi-schema__property">
250
- {name}
251
- </strong>
252
- {schemaName && (
253
- <span className="openapi-schema__name"> {schemaName}</span>
254
- )}
255
- {required && (
256
- <span className="openapi-schema__required">required</span>
257
- )}
258
- </span>
259
- <div style={{ marginLeft: "1rem" }}>
260
- {schema.description && <Markdown text={schema.description} />}
261
- {getQualifierMessage(discriminator) && (
262
- <Markdown text={getQualifierMessage(discriminator)} />
263
- )}
249
+ <>
250
+ <div className="openapi-discriminator__item openapi-schema__list-item">
251
+ <div>
252
+ <span className="openapi-schema__container">
253
+ <strong className="openapi-discriminator__name openapi-schema__property">
254
+ {name}
255
+ </strong>
256
+ {schemaName && (
257
+ <span className="openapi-schema__name"> {schemaName}</span>
258
+ )}
259
+ {required && <span className="openapi-schema__divider"></span>}
260
+ {required && (
261
+ <span className="openapi-schema__required">required</span>
262
+ )}
263
+ </span>
264
+ <div style={{ marginLeft: "1rem" }}>
265
+ {schema.description && <Markdown text={schema.description} />}
266
+ {getQualifierMessage(discriminator) && (
267
+ <Markdown text={getQualifierMessage(discriminator)} />
268
+ )}
269
+ </div>
270
+ <DiscriminatorTabs className="openapi-tabs__discriminator">
271
+ {Object.keys(discriminator.mapping).map((key, index) => (
272
+ // @ts-ignore
273
+ <TabItem
274
+ key={index}
275
+ label={key}
276
+ value={`${index}-item-discriminator`}
277
+ >
278
+ <SchemaNode
279
+ schema={discriminator.mapping[key]}
280
+ schemaType={schemaType}
281
+ />
282
+ </TabItem>
283
+ ))}
284
+ </DiscriminatorTabs>
264
285
  </div>
265
- <DiscriminatorTabs className="openapi-tabs__discriminator">
266
- {Object.keys(discriminator.mapping).map((key, index) => (
267
- // @ts-ignore
268
- <TabItem
269
- key={index}
270
- label={key}
271
- value={`${index}-item-discriminator`}
272
- >
273
- <SchemaNode
274
- schema={discriminator.mapping[key]}
286
+ </div>
287
+ {schema.properties &&
288
+ Object.entries(schema.properties as {}).map(
289
+ ([key, val]: [string, any]) =>
290
+ key !== discriminator.propertyName && (
291
+ <SchemaEdge
292
+ key={key}
293
+ name={key}
294
+ schema={val}
295
+ required={
296
+ Array.isArray(schema.required)
297
+ ? schema.required.includes(key)
298
+ : false
299
+ }
300
+ discriminator={false}
275
301
  schemaType={schemaType}
276
302
  />
277
- </TabItem>
278
- ))}
279
- </DiscriminatorTabs>
280
- </div>
281
- </div>
303
+ )
304
+ )}
305
+ </>
306
+ );
307
+ };
308
+
309
+ interface DiscriminatorNodeProps {
310
+ discriminator: any;
311
+ schema: SchemaObject;
312
+ schemaType: "request" | "response";
313
+ }
314
+
315
+ const DiscriminatorNode: React.FC<DiscriminatorNodeProps> = ({
316
+ discriminator,
317
+ schema,
318
+ schemaType,
319
+ }) => {
320
+ let discriminatedSchemas: any = {};
321
+ let inferredMapping: any = {};
322
+
323
+ const discriminatorProperty = schema.properties![discriminator.propertyName];
324
+
325
+ if (schema.allOf) {
326
+ const mergedSchemas = mergeAllOf(schema) as SchemaObject;
327
+ if (mergedSchemas.oneOf || mergedSchemas.anyOf) {
328
+ discriminatedSchemas = mergedSchemas.oneOf || mergedSchemas.anyOf;
329
+ }
330
+ } else if (schema.oneOf || schema.anyOf) {
331
+ discriminatedSchemas = schema.oneOf || schema.anyOf;
332
+ }
333
+
334
+ // Handle case where no mapping is defined
335
+ if (!discriminator.mapping) {
336
+ Object.entries(discriminatedSchemas).forEach(
337
+ ([_, subschema]: [string, any], index) => {
338
+ inferredMapping[subschema.title ?? `PROP${index}`] = subschema;
339
+ }
340
+ );
341
+ discriminator.mapping = inferredMapping;
342
+ }
343
+
344
+ // Merge sub schema discriminator property with parent
345
+ Object.keys(discriminator.mapping).forEach((key) => {
346
+ const subSchema = discriminator.mapping[key];
347
+
348
+ // Handle discriminated schema with allOf
349
+ let mergedSubSchema = {} as SchemaObject;
350
+ if (subSchema.allOf) {
351
+ mergedSubSchema = mergeAllOf(subSchema) as SchemaObject;
352
+ }
353
+
354
+ const subProperties = subSchema.properties || mergedSubSchema.properties;
355
+ if (subProperties[discriminator.propertyName]) {
356
+ schema.properties![discriminator.propertyName] = {
357
+ ...schema.properties![discriminator.propertyName],
358
+ ...subProperties[discriminator.propertyName],
359
+ };
360
+ if (subSchema.required && !schema.required) {
361
+ schema.required = subSchema.required;
362
+ }
363
+ // Avoid duplicating property
364
+ delete subProperties[discriminator.propertyName];
365
+ }
366
+ });
367
+
368
+ const name = discriminator.propertyName;
369
+ const schemaName = getSchemaName(discriminatorProperty);
370
+
371
+ // Default case for discriminator without oneOf/anyOf/allOf
372
+ return (
373
+ <PropertyDiscriminator
374
+ name={name}
375
+ schemaName={schemaName}
376
+ schema={schema}
377
+ schemaType={schemaType}
378
+ discriminator={discriminator}
379
+ required={
380
+ Array.isArray(schema.required)
381
+ ? schema.required.includes(name)
382
+ : schema.required
383
+ }
384
+ />
282
385
  );
283
386
  };
284
387
 
@@ -738,6 +841,18 @@ const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
738
841
  return null;
739
842
  }
740
843
 
844
+ if (schema.discriminator) {
845
+ const { discriminator } = schema;
846
+ return (
847
+ <DiscriminatorNode
848
+ discriminator={discriminator}
849
+ schema={schema}
850
+ schemaType={schemaType}
851
+ />
852
+ );
853
+ }
854
+
855
+ // Handle allOf, oneOf, anyOf without discriminators
741
856
  if (schema.allOf) {
742
857
  const mergedSchemas = mergeAllOf(schema) as SchemaObject;
743
858
 
@@ -766,6 +881,10 @@ const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
766
881
  );
767
882
  }
768
883
 
884
+ if (schema.oneOf || schema.anyOf) {
885
+ return <AnyOneOf schema={schema} schemaType={schemaType} />;
886
+ }
887
+
769
888
  // Handle primitives
770
889
  if (
771
890
  schema.type &&
@@ -93,16 +93,16 @@
93
93
  height: 100%;
94
94
  }
95
95
 
96
- @media (min-width: 997px) {
97
- .docItemCol {
98
- max-width: 75% !important;
99
- }
100
-
101
- /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
102
- .tocMobile {
103
- display: none;
104
- }
105
- }
96
+ // @media (min-width: 997px) {
97
+ // .docItemCol {
98
+ // max-width: 75% !important;
99
+ // }
100
+
101
+ // /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
102
+ // .tocMobile {
103
+ // display: none;
104
+ // }
105
+ // }
106
106
 
107
107
  /* Begin OpenAPI theme styles */
108
108
  // [data-theme="dark"] {
@@ -161,6 +161,12 @@
161
161
  border-right: thin solid var(--ifm-toc-border-color);
162
162
  }
163
163
 
164
+ @media (max-width: 997px) {
165
+ .schema {
166
+ margin-bottom: 1rem;
167
+ }
168
+ }
169
+
164
170
  .openapi-tabs__heading {
165
171
  margin-bottom: 1rem;
166
172
  }