diff --git a/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx b/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx index ff845387f1d..e1458249735 100644 --- a/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx +++ b/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx @@ -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( + )} diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/ContentSchema.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/ContentSchema.jsx new file mode 100644 index 00000000000..661ca348176 --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/ContentSchema.jsx @@ -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 = ( + + Content schema + + ) + + return ( +
+ +
+ ) +} + +ContentSchema.propTypes = { + schema: schema.isRequired, +} + +export default ContentSchema diff --git a/src/core/plugins/json-schema-2020-12/fn.js b/src/core/plugins/json-schema-2020-12/fn.js index 505726b7d77..1d5a768a5ee 100644 --- a/src/core/plugins/json-schema-2020-12/fn.js +++ b/src/core/plugins/json-schema-2020-12/fn.js @@ -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") ) } diff --git a/src/core/plugins/json-schema-2020-12/hoc.jsx b/src/core/plugins/json-schema-2020-12/hoc.jsx index 65af863a666..aa6655a79d7 100644 --- a/src/core/plugins/json-schema-2020-12/hoc.jsx +++ b/src/core/plugins/json-schema-2020-12/hoc.jsx @@ -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, diff --git a/src/core/plugins/json-schema-2020-12/index.js b/src/core/plugins/json-schema-2020-12/index.js index bcb0b0be7db..5da6c18bf50 100644 --- a/src/core/plugins/json-schema-2020-12/index.js +++ b/src/core/plugins/json-schema-2020-12/index.js @@ -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, diff --git a/src/core/plugins/oas31/wrap-components/models.jsx b/src/core/plugins/oas31/wrap-components/models.jsx index 9c5ec2dc8e0..c9e8a2ec5ac 100644 --- a/src/core/plugins/oas31/wrap-components/models.jsx +++ b/src/core/plugins/oas31/wrap-components/models.jsx @@ -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,