committed by
Vladimír Gorej
parent
2f08f6424b
commit
4ea28a9310
@@ -41,6 +41,7 @@ const JSONSchema = ({ schema, name }) => {
|
||||
const Keyword$dynamicRef = useComponent("Keyword$dynamicRef")
|
||||
const Keyword$defs = useComponent("Keyword$defs")
|
||||
const Keyword$comment = useComponent("Keyword$comment")
|
||||
const KeywordAllOf = useComponent("KeywordAllOf")
|
||||
const KeywordProperties = useComponent("KeywordProperties")
|
||||
const KeywordType = useComponent("KeywordType")
|
||||
const KeywordFormat = useComponent("KeywordFormat")
|
||||
@@ -104,14 +105,17 @@ const JSONSchema = ({ schema, name }) => {
|
||||
{!isCircular && isExpandable && (
|
||||
<KeywordProperties schema={schema} />
|
||||
)}
|
||||
<KeywordAllOf schema={schema} />
|
||||
<Keyword$schema schema={schema} />
|
||||
<Keyword$vocabulary schema={schema} />
|
||||
<Keyword$id schema={schema} />
|
||||
<Keyword$anchor schema={schema} />
|
||||
<Keyword$dynamicAnchor schema={schema} />
|
||||
<Keyword$ref schema={schema} />
|
||||
{!isCircular && isExpandable && (
|
||||
<Keyword$defs schema={schema} />
|
||||
)}
|
||||
<Keyword$dynamicRef schema={schema} />
|
||||
<Keyword$defs schema={schema} />
|
||||
<Keyword$comment schema={schema} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
@import './ExpandDeepButton/expand-deep-button';
|
||||
@import './keywords/$vocabulary/$vocabulary';
|
||||
@import './keywords/$defs/$defs';
|
||||
@import './keywords/AllOf/all-of';
|
||||
@import './keywords/Type/type';
|
||||
@import './keywords/Format/format';
|
||||
@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 AllOf = ({ schema }) => {
|
||||
const allOf = schema?.allOf || []
|
||||
|
||||
if (!Array.isArray(allOf) || allOf.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__allOf">
|
||||
<Accordion expanded={expanded} onChange={handleExpansion}>
|
||||
<span className="json-schema-2020-12-core-keyword json-schema-2020-12-core-keyword--allOf">
|
||||
AllOf
|
||||
</span>
|
||||
<span className="json-schema-2020-12__type">
|
||||
{fn.getType({ allOf })}
|
||||
</span>
|
||||
</Accordion>
|
||||
{expanded && (
|
||||
<ul>
|
||||
{allOf.map((schema, index) => (
|
||||
<li key={`#${index}`} className="json-schema-2020-12-property">
|
||||
<JSONSchema
|
||||
name={`#${index} ${fn.getTitle(schema)}`}
|
||||
schema={schema}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
AllOf.propTypes = {
|
||||
schema: schema.isRequired,
|
||||
}
|
||||
|
||||
export default AllOf
|
||||
@@ -0,0 +1,18 @@
|
||||
.json-schema-2020-12 {
|
||||
&__allOf {
|
||||
& ul {
|
||||
padding: 0;
|
||||
margin: 0 0 0 20px;
|
||||
border-left: 1px dashed rgba($section-models-model-container-background-color, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
&-core-keyword {
|
||||
&--allOf {
|
||||
color: $text-code-default-font-color;
|
||||
font-style: normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ export const isExpandable = (schema) => {
|
||||
schema?.$dynamicRef ||
|
||||
schema?.$defs ||
|
||||
schema?.$comment ||
|
||||
schema?.allOf ||
|
||||
schema?.description ||
|
||||
schema?.properties
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ import Keyword$ref from "./components/keywords/$ref"
|
||||
import Keyword$dynamicRef from "./components/keywords/$dynamicRef"
|
||||
import Keyword$defs from "./components/keywords/$defs/$defs"
|
||||
import Keyword$comment from "./components/keywords/$comment"
|
||||
import KeywordAllOf from "./components/keywords/AllOf/AllOf"
|
||||
import KeywordProperties from "./components/keywords/Properties/Properties"
|
||||
import KeywordType from "./components/keywords/Type/Type"
|
||||
import KeywordFormat from "./components/keywords/Format/Format"
|
||||
@@ -43,6 +44,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
||||
Keyword$dynamicRef,
|
||||
Keyword$defs,
|
||||
Keyword$comment,
|
||||
KeywordAllOf,
|
||||
KeywordProperties,
|
||||
KeywordType,
|
||||
KeywordFormat,
|
||||
|
||||
@@ -12,6 +12,7 @@ import Keyword$ref from "./components/keywords/$ref"
|
||||
import Keyword$dynamicRef from "./components/keywords/$dynamicRef"
|
||||
import Keyword$defs from "./components/keywords/$defs/$defs"
|
||||
import Keyword$comment from "./components/keywords/$comment"
|
||||
import KeywordAllOf from "./components/keywords/AllOf/AllOf"
|
||||
import KeywordType from "./components/keywords/Type/Type"
|
||||
import KeywordFormat from "./components/keywords/Format/Format"
|
||||
import KeywordTitle from "./components/keywords/Title/Title"
|
||||
@@ -34,6 +35,7 @@ const JSONSchema202012Plugin = () => ({
|
||||
JSONSchema202012Keyword$dynamicRef: Keyword$dynamicRef,
|
||||
JSONSchema202012Keyword$defs: Keyword$defs,
|
||||
JSONSchema202012Keyword$comment: Keyword$comment,
|
||||
JSONSchema202012KeywordAllOf: KeywordAllOf,
|
||||
JSONSchema202012KeywordProperties: KeywordProperties,
|
||||
JSONSchema202012KeywordType: KeywordType,
|
||||
JSONSchema202012KeywordFormat: KeywordFormat,
|
||||
|
||||
@@ -20,6 +20,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
||||
const Keyword$dynamicRef = getComponent("JSONSchema202012Keyword$dynamicRef")
|
||||
const Keyword$defs = getComponent("JSONSchema202012Keyword$defs")
|
||||
const Keyword$comment = getComponent("JSONSchema202012Keyword$comment")
|
||||
const KeywordAllOf = getComponent("JSONSchema202012KeywordAllOf")
|
||||
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
|
||||
const KeywordType = getComponent("JSONSchema202012KeywordType")
|
||||
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
|
||||
@@ -48,6 +49,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
||||
Keyword$dynamicRef,
|
||||
Keyword$defs,
|
||||
Keyword$comment,
|
||||
KeywordAllOf,
|
||||
KeywordProperties,
|
||||
KeywordType,
|
||||
KeywordFormat,
|
||||
|
||||
Reference in New Issue
Block a user