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 714bdcc0055..ec807685709 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 @@ -40,6 +40,7 @@ const JSONSchema = ({ schema, name }) => { const Keyword$ref = useComponent("Keyword$ref") const Keyword$dynamicRef = useComponent("Keyword$dynamicRef") const Keyword$defs = useComponent("Keyword$defs") + const Keyword$comment = useComponent("Keyword$comment") const KeywordProperties = useComponent("KeywordProperties") const KeywordType = useComponent("KeywordType") const KeywordFormat = useComponent("KeywordFormat") @@ -111,6 +112,7 @@ const JSONSchema = ({ schema, name }) => { + )} diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx new file mode 100644 index 00000000000..844fe13e3c4 --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx @@ -0,0 +1,25 @@ +/** + * @prettier + */ +import React from "react" + +import { schema } from "../../prop-types" + +const $comment = ({ schema }) => { + if (!schema?.$comment) return null + + return ( +
+ $comment + + {schema.$comment} + +
+ ) +} + +$comment.propTypes = { + schema: schema.isRequired, +} + +export default $comment diff --git a/src/core/plugins/json-schema-2020-12/fn.js b/src/core/plugins/json-schema-2020-12/fn.js index 5b61ccdbb7c..e107a05e295 100644 --- a/src/core/plugins/json-schema-2020-12/fn.js +++ b/src/core/plugins/json-schema-2020-12/fn.js @@ -121,6 +121,7 @@ export const isExpandable = (schema) => { schema?.$ref || schema?.$dynamicRef || schema?.$defs || + schema?.$comment || schema?.description || schema?.properties ) diff --git a/src/core/plugins/json-schema-2020-12/hoc.jsx b/src/core/plugins/json-schema-2020-12/hoc.jsx index 960a13ba170..c180d969d43 100644 --- a/src/core/plugins/json-schema-2020-12/hoc.jsx +++ b/src/core/plugins/json-schema-2020-12/hoc.jsx @@ -12,6 +12,7 @@ import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor" 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 KeywordProperties from "./components/keywords/Properties/Properties" import KeywordType from "./components/keywords/Type/Type" import KeywordFormat from "./components/keywords/Format/Format" @@ -41,6 +42,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => { Keyword$ref, Keyword$dynamicRef, Keyword$defs, + Keyword$comment, KeywordProperties, KeywordType, KeywordFormat, diff --git a/src/core/plugins/json-schema-2020-12/index.js b/src/core/plugins/json-schema-2020-12/index.js index f8559795d77..f95632f63c9 100644 --- a/src/core/plugins/json-schema-2020-12/index.js +++ b/src/core/plugins/json-schema-2020-12/index.js @@ -11,6 +11,7 @@ import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor" 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 KeywordType from "./components/keywords/Type/Type" import KeywordFormat from "./components/keywords/Format/Format" import KeywordTitle from "./components/keywords/Title/Title" @@ -32,6 +33,7 @@ const JSONSchema202012Plugin = () => ({ JSONSchema202012Keyword$ref: Keyword$ref, JSONSchema202012Keyword$dynamicRef: Keyword$dynamicRef, JSONSchema202012Keyword$defs: Keyword$defs, + JSONSchema202012Keyword$comment: Keyword$comment, JSONSchema202012KeywordProperties: KeywordProperties, JSONSchema202012KeywordType: KeywordType, JSONSchema202012KeywordFormat: KeywordFormat, diff --git a/src/core/plugins/oas31/wrap-components/models.jsx b/src/core/plugins/oas31/wrap-components/models.jsx index 903a3248b25..3e5a65ed4d3 100644 --- a/src/core/plugins/oas31/wrap-components/models.jsx +++ b/src/core/plugins/oas31/wrap-components/models.jsx @@ -19,6 +19,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { const Keyword$ref = getComponent("JSONSchema202012Keyword$ref") const Keyword$dynamicRef = getComponent("JSONSchema202012Keyword$dynamicRef") const Keyword$defs = getComponent("JSONSchema202012Keyword$defs") + const Keyword$comment = getComponent("JSONSchema202012Keyword$comment") const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") const KeywordType = getComponent("JSONSchema202012KeywordType") const KeywordFormat = getComponent("JSONSchema202012KeywordFormat") @@ -46,6 +47,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { Keyword$ref, Keyword$dynamicRef, Keyword$defs, + Keyword$comment, KeywordProperties, KeywordType, KeywordFormat,