committed by
Vladimír Gorej
parent
ff2d4b2311
commit
15830794f1
@@ -43,6 +43,7 @@ const JSONSchema = ({ schema, name }) => {
|
|||||||
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 KeywordAnyOf = useComponent("KeywordAnyOf")
|
||||||
|
const KeywordOneOf = useComponent("KeywordOneOf")
|
||||||
const KeywordProperties = useComponent("KeywordProperties")
|
const KeywordProperties = useComponent("KeywordProperties")
|
||||||
const KeywordType = useComponent("KeywordType")
|
const KeywordType = useComponent("KeywordType")
|
||||||
const KeywordFormat = useComponent("KeywordFormat")
|
const KeywordFormat = useComponent("KeywordFormat")
|
||||||
@@ -109,6 +110,7 @@ const JSONSchema = ({ schema, name }) => {
|
|||||||
)}
|
)}
|
||||||
<KeywordAllOf schema={schema} />
|
<KeywordAllOf schema={schema} />
|
||||||
<KeywordAnyOf schema={schema} />
|
<KeywordAnyOf schema={schema} />
|
||||||
|
<KeywordOneOf 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} />
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
@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/AnyOf/any-of';
|
||||||
|
@import './keywords/OneOf/one-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';
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
.json-schema-2020-12 {
|
.json-schema-2020-12 {
|
||||||
&__anyOf {
|
&__anyOf {
|
||||||
margin: 5px 0 5px 0;
|
@extend .json-schema-2020-12__allOf;
|
||||||
|
|
||||||
& > ul {
|
|
||||||
@include expansion-border;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&-core-keyword {
|
&-core-keyword {
|
||||||
&--anyOf {
|
&--anyOf {
|
||||||
color: $text-code-default-font-color;
|
@extend .json-schema-2020-12-core-keyword--allOf;
|
||||||
font-style: normal;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
|
import React, { useCallback, useState } from "react"
|
||||||
|
|
||||||
|
import { schema } from "../../../prop-types"
|
||||||
|
import { useFn, useComponent, useIsExpandedDeeply } from "../../../hooks"
|
||||||
|
|
||||||
|
const OneOf = ({ schema }) => {
|
||||||
|
const oneOf = schema?.oneOf || []
|
||||||
|
|
||||||
|
if (!Array.isArray(oneOf) || oneOf.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__oneOf">
|
||||||
|
<Accordion expanded={expanded} onChange={handleExpansion}>
|
||||||
|
<span className="json-schema-2020-12-core-keyword json-schema-2020-12-core-keyword--oneOf">
|
||||||
|
OneOf
|
||||||
|
</span>
|
||||||
|
<span className="json-schema-2020-12__type">
|
||||||
|
{fn.getType({ oneOf })}
|
||||||
|
</span>
|
||||||
|
</Accordion>
|
||||||
|
{expanded && (
|
||||||
|
<ul>
|
||||||
|
{oneOf.map((schema, index) => (
|
||||||
|
<li key={`#${index}`} className="json-schema-2020-12-property">
|
||||||
|
<JSONSchema
|
||||||
|
name={`#${index} ${fn.getTitle(schema)}`}
|
||||||
|
schema={schema}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
OneOf.propTypes = {
|
||||||
|
schema: schema.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default OneOf
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
.json-schema-2020-12 {
|
||||||
|
&__oneOf {
|
||||||
|
@extend .json-schema-2020-12__allOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-core-keyword {
|
||||||
|
&--oneOf {
|
||||||
|
@extend .json-schema-2020-12-core-keyword--allOf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,6 +124,7 @@ export const isExpandable = (schema) => {
|
|||||||
schema?.$comment ||
|
schema?.$comment ||
|
||||||
schema?.allOf ||
|
schema?.allOf ||
|
||||||
schema?.anyOf ||
|
schema?.anyOf ||
|
||||||
|
schema?.oneOf ||
|
||||||
schema?.description ||
|
schema?.description ||
|
||||||
schema?.properties
|
schema?.properties
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ 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 KeywordAnyOf from "./components/keywords/AnyOf/AnyOf"
|
||||||
|
import KeywordOneOf from "./components/keywords/OneOf/OneOf"
|
||||||
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"
|
||||||
@@ -47,6 +48,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
|||||||
Keyword$comment,
|
Keyword$comment,
|
||||||
KeywordAllOf,
|
KeywordAllOf,
|
||||||
KeywordAnyOf,
|
KeywordAnyOf,
|
||||||
|
KeywordOneOf,
|
||||||
KeywordProperties,
|
KeywordProperties,
|
||||||
KeywordType,
|
KeywordType,
|
||||||
KeywordFormat,
|
KeywordFormat,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ 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 KeywordAnyOf from "./components/keywords/AnyOf/AnyOf"
|
||||||
|
import KeywordOneOf from "./components/keywords/OneOf/OneOf"
|
||||||
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"
|
||||||
@@ -38,6 +39,7 @@ const JSONSchema202012Plugin = () => ({
|
|||||||
JSONSchema202012Keyword$comment: Keyword$comment,
|
JSONSchema202012Keyword$comment: Keyword$comment,
|
||||||
JSONSchema202012KeywordAllOf: KeywordAllOf,
|
JSONSchema202012KeywordAllOf: KeywordAllOf,
|
||||||
JSONSchema202012KeywordAnyOf: KeywordAnyOf,
|
JSONSchema202012KeywordAnyOf: KeywordAnyOf,
|
||||||
|
JSONSchema202012KeywordOneOf: KeywordOneOf,
|
||||||
JSONSchema202012KeywordProperties: KeywordProperties,
|
JSONSchema202012KeywordProperties: KeywordProperties,
|
||||||
JSONSchema202012KeywordType: KeywordType,
|
JSONSchema202012KeywordType: KeywordType,
|
||||||
JSONSchema202012KeywordFormat: KeywordFormat,
|
JSONSchema202012KeywordFormat: KeywordFormat,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
|||||||
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 KeywordAnyOf = getComponent("JSONSchema202012KeywordAnyOf")
|
||||||
|
const KeywordOneOf = getComponent("JSONSchema202012KeywordOneOf")
|
||||||
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
|
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
|
||||||
const KeywordType = getComponent("JSONSchema202012KeywordType")
|
const KeywordType = getComponent("JSONSchema202012KeywordType")
|
||||||
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
|
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
|
||||||
@@ -52,6 +53,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
|||||||
Keyword$comment,
|
Keyword$comment,
|
||||||
KeywordAllOf,
|
KeywordAllOf,
|
||||||
KeywordAnyOf,
|
KeywordAnyOf,
|
||||||
|
KeywordOneOf,
|
||||||
KeywordProperties,
|
KeywordProperties,
|
||||||
KeywordType,
|
KeywordType,
|
||||||
KeywordFormat,
|
KeywordFormat,
|
||||||
|
|||||||
Reference in New Issue
Block a user