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 b957717bb1a..5c80a7f0ebb 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 @@ -73,6 +73,7 @@ const JSONSchema = forwardRef( const KeywordTitle = useComponent("KeywordTitle") const KeywordDescription = useComponent("KeywordDescription") const KeywordDefault = useComponent("KeywordDefault") + const KeywordDeprecated = useComponent("KeywordDeprecated") const ExpandDeepButton = useComponent("ExpandDeepButton") /** @@ -132,6 +133,7 @@ const JSONSchema = forwardRef( ) : ( )} + {constraints.length > 0 && constraints.map((constraint) => ( diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Deprecated/Deprecated.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Deprecated/Deprecated.jsx new file mode 100644 index 00000000000..9701f5805c6 --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Deprecated/Deprecated.jsx @@ -0,0 +1,18 @@ +/** + * @prettier + */ +import React from "react" + +import { schema } from "../../../prop-types" + +const Deprecated = ({ schema }) => { + if (schema?.deprecated !== true) return null + + return deprecated +} + +Deprecated.propTypes = { + schema: schema.isRequired, +} + +export default Deprecated diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Deprecated/_deprecated.scss b/src/core/plugins/json-schema-2020-12/components/keywords/Deprecated/_deprecated.scss new file mode 100644 index 00000000000..559c59e5e69 --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Deprecated/_deprecated.scss @@ -0,0 +1,10 @@ +.json-schema-2020-12 { + &__deprecated { + @include text_code(); + color: red; + font-size: 12px; + text-transform: lowercase; + font-weight: normal; + padding-left: 10px; + } +} diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss b/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss index 4ee1591b2c5..3d105d135c2 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss +++ b/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss @@ -74,3 +74,4 @@ @import './Enum/enum'; @import './Constraint/constraint'; @import './DependentRequired/dependent-required'; +@import './Deprecated/deprecated'; diff --git a/src/core/plugins/json-schema-2020-12/hoc.jsx b/src/core/plugins/json-schema-2020-12/hoc.jsx index bca0437ccea..3be731668ab 100644 --- a/src/core/plugins/json-schema-2020-12/hoc.jsx +++ b/src/core/plugins/json-schema-2020-12/hoc.jsx @@ -39,6 +39,7 @@ import KeywordContentSchema from "./components/keywords/ContentSchema" import KeywordTitle from "./components/keywords/Title/Title" import KeywordDescription from "./components/keywords/Description/Description" import KeywordDefault from "./components/keywords/Default" +import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated" import Accordion from "./components/Accordion/Accordion" import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton" import ChevronRightIcon from "./components/icons/ChevronRight" @@ -94,6 +95,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => { KeywordTitle, KeywordDescription, KeywordDefault, + KeywordDeprecated, Accordion, ExpandDeepButton, ChevronRightIcon, diff --git a/src/core/plugins/json-schema-2020-12/index.js b/src/core/plugins/json-schema-2020-12/index.js index 1e06cd7847b..4c2e28cefc9 100644 --- a/src/core/plugins/json-schema-2020-12/index.js +++ b/src/core/plugins/json-schema-2020-12/index.js @@ -37,6 +37,7 @@ import KeywordContentSchema from "./components/keywords/ContentSchema" import KeywordTitle from "./components/keywords/Title/Title" import KeywordDescription from "./components/keywords/Description/Description" import KeywordDefault from "./components/keywords/Default" +import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated" import Accordion from "./components/Accordion/Accordion" import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton" import ChevronRightIcon from "./components/icons/ChevronRight" @@ -81,6 +82,7 @@ const JSONSchema202012Plugin = () => ({ JSONSchema202012KeywordTitle: KeywordTitle, JSONSchema202012KeywordDescription: KeywordDescription, JSONSchema202012KeywordDefault: KeywordDefault, + JSONSchema202012KeywordDeprecated: KeywordDeprecated, JSONSchema202012Accordion: Accordion, JSONSchema202012ExpandDeepButton: ExpandDeepButton, JSONSchema202012ChevronRightIcon: ChevronRightIcon, diff --git a/src/core/plugins/oas31/wrap-components/models.jsx b/src/core/plugins/oas31/wrap-components/models.jsx index eb93493ca20..0142237ff33 100644 --- a/src/core/plugins/oas31/wrap-components/models.jsx +++ b/src/core/plugins/oas31/wrap-components/models.jsx @@ -71,6 +71,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { true ) const KeywordDefault = getComponent("JSONSchema202012KeywordDefault") + const KeywordDeprecated = getComponent("JSONSchema202012KeywordDeprecated") const Accordion = getComponent("JSONSchema202012Accordion") const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton") const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon") @@ -118,6 +119,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { KeywordTitle, KeywordDescription, KeywordDefault, + KeywordDeprecated, Accordion, ExpandDeepButton, ChevronRightIcon,