committed by
Vladimír Gorej
parent
f41c6ba0d7
commit
ff2d4b2311
@@ -42,6 +42,7 @@ const JSONSchema = ({ schema, name }) => {
|
|||||||
const Keyword$defs = useComponent("Keyword$defs")
|
const Keyword$defs = useComponent("Keyword$defs")
|
||||||
const Keyword$comment = useComponent("Keyword$comment")
|
const Keyword$comment = useComponent("Keyword$comment")
|
||||||
const KeywordAllOf = useComponent("KeywordAllOf")
|
const KeywordAllOf = useComponent("KeywordAllOf")
|
||||||
|
const KeywordAnyOf = useComponent("KeywordAnyOf")
|
||||||
const KeywordProperties = useComponent("KeywordProperties")
|
const KeywordProperties = useComponent("KeywordProperties")
|
||||||
const KeywordType = useComponent("KeywordType")
|
const KeywordType = useComponent("KeywordType")
|
||||||
const KeywordFormat = useComponent("KeywordFormat")
|
const KeywordFormat = useComponent("KeywordFormat")
|
||||||
@@ -107,6 +108,7 @@ const JSONSchema = ({ schema, name }) => {
|
|||||||
<KeywordProperties schema={schema} />
|
<KeywordProperties schema={schema} />
|
||||||
)}
|
)}
|
||||||
<KeywordAllOf schema={schema} />
|
<KeywordAllOf schema={schema} />
|
||||||
|
<KeywordAnyOf schema={schema} />
|
||||||
<Keyword$schema schema={schema} />
|
<Keyword$schema schema={schema} />
|
||||||
<Keyword$vocabulary schema={schema} />
|
<Keyword$vocabulary schema={schema} />
|
||||||
<Keyword$id schema={schema} />
|
<Keyword$id schema={schema} />
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
@import './keywords/$vocabulary/$vocabulary';
|
@import './keywords/$vocabulary/$vocabulary';
|
||||||
@import './keywords/$defs/$defs';
|
@import './keywords/$defs/$defs';
|
||||||
@import './keywords/AllOf/all-of';
|
@import './keywords/AllOf/all-of';
|
||||||
|
@import './keywords/AnyOf/any-of';
|
||||||
@import './keywords/Type/type';
|
@import './keywords/Type/type';
|
||||||
@import './keywords/Format/format';
|
@import './keywords/Format/format';
|
||||||
@import './keywords/Description/description';
|
@import './keywords/Description/description';
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
|
import React, { useCallback, useState } from "react"
|
||||||
|
|
||||||
|
import { schema } from "../../../prop-types"
|
||||||
|
import { useFn, useComponent, useIsExpandedDeeply } from "../../../hooks"
|
||||||
|
|
||||||
|
const AnyOf = ({ schema }) => {
|
||||||
|
const anyOf = schema?.anyOf || []
|
||||||
|
|
||||||
|
if (!Array.isArray(anyOf) || anyOf.length === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn = useFn()
|
||||||
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
|
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||||
|
const Accordion = useComponent("Accordion")
|
||||||
|
const JSONSchema = useComponent("JSONSchema")
|
||||||
|
|
||||||
|
const handleExpansion = useCallback(() => {
|
||||||
|
setExpanded((prev) => !prev)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="json-schema-2020-12__anyOf">
|
||||||
|
<Accordion expanded={expanded} onChange={handleExpansion}>
|
||||||
|
<span className="json-schema-2020-12-core-keyword json-schema-2020-12-core-keyword--anyOf">
|
||||||
|
AnyOf
|
||||||
|
</span>
|
||||||
|
<span className="json-schema-2020-12__type">
|
||||||
|
{fn.getType({ anyOf })}
|
||||||
|
</span>
|
||||||
|
</Accordion>
|
||||||
|
{expanded && (
|
||||||
|
<ul>
|
||||||
|
{anyOf.map((schema, index) => (
|
||||||
|
<li key={`#${index}`} className="json-schema-2020-12-property">
|
||||||
|
<JSONSchema
|
||||||
|
name={`#${index} ${fn.getTitle(schema)}`}
|
||||||
|
schema={schema}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
AnyOf.propTypes = {
|
||||||
|
schema: schema.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AnyOf
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
.json-schema-2020-12 {
|
||||||
|
&__anyOf {
|
||||||
|
margin: 5px 0 5px 0;
|
||||||
|
|
||||||
|
& > ul {
|
||||||
|
@include expansion-border;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-core-keyword {
|
||||||
|
&--anyOf {
|
||||||
|
color: $text-code-default-font-color;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,6 +123,7 @@ export const isExpandable = (schema) => {
|
|||||||
schema?.$defs ||
|
schema?.$defs ||
|
||||||
schema?.$comment ||
|
schema?.$comment ||
|
||||||
schema?.allOf ||
|
schema?.allOf ||
|
||||||
|
schema?.anyOf ||
|
||||||
schema?.description ||
|
schema?.description ||
|
||||||
schema?.properties
|
schema?.properties
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import Keyword$dynamicRef from "./components/keywords/$dynamicRef"
|
|||||||
import Keyword$defs from "./components/keywords/$defs/$defs"
|
import Keyword$defs from "./components/keywords/$defs/$defs"
|
||||||
import Keyword$comment from "./components/keywords/$comment"
|
import Keyword$comment from "./components/keywords/$comment"
|
||||||
import KeywordAllOf from "./components/keywords/AllOf/AllOf"
|
import KeywordAllOf from "./components/keywords/AllOf/AllOf"
|
||||||
|
import KeywordAnyOf from "./components/keywords/AnyOf/AnyOf"
|
||||||
import KeywordProperties from "./components/keywords/Properties/Properties"
|
import KeywordProperties from "./components/keywords/Properties/Properties"
|
||||||
import KeywordType from "./components/keywords/Type/Type"
|
import KeywordType from "./components/keywords/Type/Type"
|
||||||
import KeywordFormat from "./components/keywords/Format/Format"
|
import KeywordFormat from "./components/keywords/Format/Format"
|
||||||
@@ -45,6 +46,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
|||||||
Keyword$defs,
|
Keyword$defs,
|
||||||
Keyword$comment,
|
Keyword$comment,
|
||||||
KeywordAllOf,
|
KeywordAllOf,
|
||||||
|
KeywordAnyOf,
|
||||||
KeywordProperties,
|
KeywordProperties,
|
||||||
KeywordType,
|
KeywordType,
|
||||||
KeywordFormat,
|
KeywordFormat,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import Keyword$dynamicRef from "./components/keywords/$dynamicRef"
|
|||||||
import Keyword$defs from "./components/keywords/$defs/$defs"
|
import Keyword$defs from "./components/keywords/$defs/$defs"
|
||||||
import Keyword$comment from "./components/keywords/$comment"
|
import Keyword$comment from "./components/keywords/$comment"
|
||||||
import KeywordAllOf from "./components/keywords/AllOf/AllOf"
|
import KeywordAllOf from "./components/keywords/AllOf/AllOf"
|
||||||
|
import KeywordAnyOf from "./components/keywords/AnyOf/AnyOf"
|
||||||
import KeywordType from "./components/keywords/Type/Type"
|
import KeywordType from "./components/keywords/Type/Type"
|
||||||
import KeywordFormat from "./components/keywords/Format/Format"
|
import KeywordFormat from "./components/keywords/Format/Format"
|
||||||
import KeywordTitle from "./components/keywords/Title/Title"
|
import KeywordTitle from "./components/keywords/Title/Title"
|
||||||
@@ -36,6 +37,7 @@ const JSONSchema202012Plugin = () => ({
|
|||||||
JSONSchema202012Keyword$defs: Keyword$defs,
|
JSONSchema202012Keyword$defs: Keyword$defs,
|
||||||
JSONSchema202012Keyword$comment: Keyword$comment,
|
JSONSchema202012Keyword$comment: Keyword$comment,
|
||||||
JSONSchema202012KeywordAllOf: KeywordAllOf,
|
JSONSchema202012KeywordAllOf: KeywordAllOf,
|
||||||
|
JSONSchema202012KeywordAnyOf: KeywordAnyOf,
|
||||||
JSONSchema202012KeywordProperties: KeywordProperties,
|
JSONSchema202012KeywordProperties: KeywordProperties,
|
||||||
JSONSchema202012KeywordType: KeywordType,
|
JSONSchema202012KeywordType: KeywordType,
|
||||||
JSONSchema202012KeywordFormat: KeywordFormat,
|
JSONSchema202012KeywordFormat: KeywordFormat,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
|||||||
const Keyword$defs = getComponent("JSONSchema202012Keyword$defs")
|
const Keyword$defs = getComponent("JSONSchema202012Keyword$defs")
|
||||||
const Keyword$comment = getComponent("JSONSchema202012Keyword$comment")
|
const Keyword$comment = getComponent("JSONSchema202012Keyword$comment")
|
||||||
const KeywordAllOf = getComponent("JSONSchema202012KeywordAllOf")
|
const KeywordAllOf = getComponent("JSONSchema202012KeywordAllOf")
|
||||||
|
const KeywordAnyOf = getComponent("JSONSchema202012KeywordAnyOf")
|
||||||
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
|
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
|
||||||
const KeywordType = getComponent("JSONSchema202012KeywordType")
|
const KeywordType = getComponent("JSONSchema202012KeywordType")
|
||||||
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
|
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
|
||||||
@@ -50,6 +51,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
|||||||
Keyword$defs,
|
Keyword$defs,
|
||||||
Keyword$comment,
|
Keyword$comment,
|
||||||
KeywordAllOf,
|
KeywordAllOf,
|
||||||
|
KeywordAnyOf,
|
||||||
KeywordProperties,
|
KeywordProperties,
|
||||||
KeywordType,
|
KeywordType,
|
||||||
KeywordFormat,
|
KeywordFormat,
|
||||||
|
|||||||
Reference in New Issue
Block a user