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 d31daadd15c..16ea51fbe48 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 @@ -29,6 +29,7 @@ const JSONSchema = ({ schema, name }) => { const Accordion = useComponent("Accordion") const KeywordProperties = useComponent("KeywordProperties") const KeywordType = useComponent("KeywordType") + const KeywordFormat = useComponent("KeywordFormat") const ExpandDeepButton = useComponent("ExpandDeepButton") /** @@ -80,6 +81,7 @@ const JSONSchema = ({ schema, name }) => { onClick={handleExpansionDeep} /> + {expanded && (
diff --git a/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss b/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss index 171aee80f6a..a9024932130 100644 --- a/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss +++ b/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss @@ -43,21 +43,6 @@ font-size: 12px; } - &__format { - @include text_code(); - margin-left: 10px; - line-height: 1.5; - padding: 1px; - color: white; - background-color: #D69E2E; - border-radius: 4px; - text-transform: lowercase; - - &:before { - content: "format: "; - } - } - &__limit { @include text_code(); margin-left: 10px; diff --git a/src/core/plugins/json-schema-2020-12/components/_all.scss b/src/core/plugins/json-schema-2020-12/components/_all.scss index b0ecf8c8c11..c04c48e9952 100644 --- a/src/core/plugins/json-schema-2020-12/components/_all.scss +++ b/src/core/plugins/json-schema-2020-12/components/_all.scss @@ -3,3 +3,4 @@ @import './Accordion/accordion'; @import './ExpandDeepButton/expand-deep-button'; @import './keywords/Type/type'; +@import './keywords/Format/format'; diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Format/Format.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Format/Format.jsx new file mode 100644 index 00000000000..0486c42ea98 --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Format/Format.jsx @@ -0,0 +1,18 @@ +/** + * @prettier + */ +import React from "react" + +import { schema } from "../../../prop-types" + +const Format = ({ schema }) => { + if (!schema.format) return null + + return {schema.format} +} + +Format.propTypes = { + schema: schema.isRequired, +} + +export default Format diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Format/_format.scss b/src/core/plugins/json-schema-2020-12/components/keywords/Format/_format.scss new file mode 100644 index 00000000000..027a27c4d74 --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Format/_format.scss @@ -0,0 +1,14 @@ +.json-schema-2020-12__format { + @include text_code(); + margin-left: 10px; + line-height: 1.5; + padding: 1px; + color: white; + background-color: #D69E2E; + border-radius: 4px; + text-transform: lowercase; + + &:before { + content: "format: "; + } +} diff --git a/src/core/plugins/json-schema-2020-12/hoc.jsx b/src/core/plugins/json-schema-2020-12/hoc.jsx index 7b528663fc0..5f8c897b6de 100644 --- a/src/core/plugins/json-schema-2020-12/hoc.jsx +++ b/src/core/plugins/json-schema-2020-12/hoc.jsx @@ -7,6 +7,7 @@ import JSONSchema from "./components/JSONSchema/JSONSchema" import BooleanJSONSchema from "./components/BooleanJSONSchema/BooleanJSONSchema" import KeywordProperties from "./components/keywords/Properties" import KeywordType from "./components/keywords/Type/Type" +import KeywordFormat from "./components/keywords/Format/Format" import Accordion from "./components/Accordion/Accordion" import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton" import ChevronRightIcon from "./components/icons/ChevronRight" @@ -20,6 +21,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => { BooleanJSONSchema, KeywordProperties, KeywordType, + KeywordFormat, 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 d9c78406a16..cb33bff4a5b 100644 --- a/src/core/plugins/json-schema-2020-12/index.js +++ b/src/core/plugins/json-schema-2020-12/index.js @@ -5,6 +5,7 @@ import JSONSchema from "./components/JSONSchema/JSONSchema" import BooleanJSONSchema from "./components/BooleanJSONSchema/BooleanJSONSchema" import KeywordProperties from "./components/keywords/Properties" import KeywordType from "./components/keywords/Type/Type" +import KeywordFormat from "./components/keywords/Format/Format" import Accordion from "./components/Accordion/Accordion" import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton" import ChevronRightIcon from "./components/icons/ChevronRight" @@ -17,6 +18,7 @@ const JSONSchema202012Plugin = () => ({ BooleanJSONSchema202012: BooleanJSONSchema, JSONSchema202012KeywordProperties: KeywordProperties, JSONSchema202012KeywordType: KeywordType, + JSONSchema202012KeywordFormat: KeywordFormat, 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 0a48a6ca8d1..2f1dcbfeb0c 100644 --- a/src/core/plugins/oas31/wrap-components/models.jsx +++ b/src/core/plugins/oas31/wrap-components/models.jsx @@ -12,6 +12,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { const BooleanJSONSchema = getComponent("BooleanJSONSchema202012") const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") const KeywordType = getComponent("JSONSchema202012KeywordType") + const KeywordFormat = getComponent("JSONSchema202012KeywordFormat") const Accordion = getComponent("JSONSchema202012Accordion") const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton") const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon") @@ -25,6 +26,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { BooleanJSONSchema, KeywordProperties, KeywordType, + KeywordFormat, Accordion, ExpandDeepButton, ChevronRightIcon,