generated from rdilweb/template-docusaurus-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
oneOfSchema.tsx
45 lines (37 loc) · 1.27 KB
/
oneOfSchema.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from "react"
// https://docusaurus.io/docs/swizzling#wrapping
import TabItem from "@theme-original/TabItem"
import Tabs from "@theme-original/Tabs"
import { CreateNodes } from "@theme/JSONSchemaViewer/components"
import { SchemaHierarchyComponent } from "@theme/JSONSchemaViewer/contexts"
import { GenerateFriendlyName } from "@theme/JSONSchemaViewer/utils"
import type { JSONSchema } from "@theme/JSONSchemaViewer/types"
type Props = {
schema: Exclude<JSONSchema, true | false>
[x: string]: any
}
export default function OneOfSchema(props: Props): JSX.Element {
const { schema } = props
let typedSchema = schema.oneOf!
let typeOf = "oneOf"
return (
<div>
<span className="badge badge--info">{typeOf}</span>
<Tabs>
{typedSchema.map((compositeSchema, index) => {
return (
<TabItem
key={`schema_${typeOf}_${index}`}
value={`schema_${typeOf}_${index}`}
label={<GenerateFriendlyName schema={compositeSchema} />}
>
<SchemaHierarchyComponent innerJsonPointer={`/oneOf/${index}`}>
<CreateNodes schema={compositeSchema} />
</SchemaHierarchyComponent>
</TabItem>
)
})}
</Tabs>
</div>
)
}