feat(json-schema-2020-12): add support for contentSchema keyword (#8645)
Refs #8513
This commit is contained in:
@@ -70,6 +70,7 @@ const JSONSchema = forwardRef(
|
||||
const KeywordConstraint = useComponent("KeywordConstraint")
|
||||
const KeywordDependentRequired = useComponent("KeywordDependentRequired")
|
||||
const KeywordFormat = useComponent("KeywordFormat")
|
||||
const KeywordContentSchema = useComponent("KeywordContentSchema")
|
||||
const KeywordTitle = useComponent("KeywordTitle")
|
||||
const KeywordDescription = useComponent("KeywordDescription")
|
||||
const ExpandDeepButton = useComponent("ExpandDeepButton")
|
||||
@@ -168,6 +169,7 @@ const JSONSchema = forwardRef(
|
||||
<KeywordItems schema={schema} />
|
||||
<KeywordUnevaluatedItems schema={schema} />
|
||||
<KeywordContains schema={schema} />
|
||||
<KeywordContentSchema schema={schema} />
|
||||
</>
|
||||
)}
|
||||
<KeywordEnum schema={schema} />
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import React from "react"
|
||||
|
||||
import { schema } from "../../prop-types"
|
||||
import { useFn, useComponent } from "../../hooks"
|
||||
|
||||
const ContentSchema = ({ schema }) => {
|
||||
const fn = useFn()
|
||||
const JSONSchema = useComponent("JSONSchema")
|
||||
|
||||
/**
|
||||
* Rendering.
|
||||
*/
|
||||
if (!fn.hasKeyword(schema, "contentSchema")) return null
|
||||
|
||||
const name = (
|
||||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--primary">
|
||||
Content schema
|
||||
</span>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--contentSchema">
|
||||
<JSONSchema name={name} schema={schema.contentSchema} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
ContentSchema.propTypes = {
|
||||
schema: schema.isRequired,
|
||||
}
|
||||
|
||||
export default ContentSchema
|
||||
@@ -161,7 +161,8 @@ export const isExpandable = (schema) => {
|
||||
fn.hasKeyword(schema, "unevaluatedProperties") ||
|
||||
schema?.description ||
|
||||
schema?.enum ||
|
||||
fn.hasKeyword(schema, "const")
|
||||
fn.hasKeyword(schema, "const") ||
|
||||
fn.hasKeyword(schema, "contentSchema")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import KeywordConst from "./components/keywords/Const"
|
||||
import KeywordConstraint from "./components/keywords/Constraint/Constraint"
|
||||
import KeywordDependentRequired from "./components/keywords/DependentRequired/DependentRequired"
|
||||
import KeywordFormat from "./components/keywords/Format/Format"
|
||||
import KeywordContentSchema from "./components/keywords/ContentSchema"
|
||||
import KeywordTitle from "./components/keywords/Title/Title"
|
||||
import KeywordDescription from "./components/keywords/Description/Description"
|
||||
import Accordion from "./components/Accordion/Accordion"
|
||||
@@ -90,6 +91,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
||||
KeywordConstraint,
|
||||
KeywordDependentRequired,
|
||||
KeywordFormat,
|
||||
KeywordContentSchema,
|
||||
KeywordTitle,
|
||||
KeywordDescription,
|
||||
Accordion,
|
||||
|
||||
@@ -34,6 +34,7 @@ import KeywordConst from "./components/keywords/Const"
|
||||
import KeywordConstraint from "./components/keywords/Constraint/Constraint"
|
||||
import KeywordDependentRequired from "./components/keywords/DependentRequired/DependentRequired"
|
||||
import KeywordFormat from "./components/keywords/Format/Format"
|
||||
import KeywordContentSchema from "./components/keywords/ContentSchema"
|
||||
import KeywordTitle from "./components/keywords/Title/Title"
|
||||
import KeywordDescription from "./components/keywords/Description/Description"
|
||||
import Accordion from "./components/Accordion/Accordion"
|
||||
@@ -77,6 +78,7 @@ const JSONSchema202012Plugin = () => ({
|
||||
JSONSchema202012KeywordConstraint: KeywordConstraint,
|
||||
JSONSchema202012KeywordDependentRequired: KeywordDependentRequired,
|
||||
JSONSchema202012KeywordFormat: KeywordFormat,
|
||||
JSONSchema202012KeywordContentSchema: KeywordContentSchema,
|
||||
JSONSchema202012KeywordTitle: KeywordTitle,
|
||||
JSONSchema202012KeywordDescription: KeywordDescription,
|
||||
JSONSchema202012Accordion: Accordion,
|
||||
|
||||
@@ -63,6 +63,9 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
||||
"JSONSchema202012KeywordDependentRequired"
|
||||
)
|
||||
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
|
||||
const KeywordContentSchema = getComponent(
|
||||
"JSONSchema202012KeywordContentSchema"
|
||||
)
|
||||
const KeywordTitle = getComponent("JSONSchema202012KeywordTitle")
|
||||
const KeywordDescription = getComponent(
|
||||
"JSONSchema202012KeywordDescription",
|
||||
@@ -112,6 +115,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
||||
KeywordConstraint,
|
||||
KeywordDependentRequired,
|
||||
KeywordFormat,
|
||||
KeywordContentSchema,
|
||||
KeywordTitle,
|
||||
KeywordDescription,
|
||||
Accordion,
|
||||
|
||||
Reference in New Issue
Block a user