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 9f35fb86b66..a4fe47fc165 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 @@ -36,6 +36,7 @@ const JSONSchema = ({ schema, name }) => { const Keyword$vocabulary = useComponent("Keyword$vocabulary") const Keyword$id = useComponent("Keyword$id") const Keyword$anchor = useComponent("Keyword$anchor") + const Keyword$dynamicAnchor = useComponent("Keyword$dynamicAnchor") const KeywordProperties = useComponent("KeywordProperties") const KeywordType = useComponent("KeywordType") const KeywordFormat = useComponent("KeywordFormat") @@ -103,6 +104,7 @@ const JSONSchema = ({ schema, name }) => { + )} diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx new file mode 100644 index 00000000000..4029616873e --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx @@ -0,0 +1,25 @@ +/** + * @prettier + */ +import React from "react" + +import { schema } from "../../prop-types" + +const $dynamicAnchor = ({ schema }) => { + if (!schema?.$dynamicAnchor) return null + + return ( +
+ $dynamicAnchor + + {schema.$dynamicAnchor} + +
+ ) +} + +$dynamicAnchor.propTypes = { + schema: schema.isRequired, +} + +export default $dynamicAnchor diff --git a/src/core/plugins/json-schema-2020-12/fn.js b/src/core/plugins/json-schema-2020-12/fn.js index 223e4dfcb1a..894d9990f2e 100644 --- a/src/core/plugins/json-schema-2020-12/fn.js +++ b/src/core/plugins/json-schema-2020-12/fn.js @@ -117,6 +117,7 @@ export const isExpandable = (schema) => { schema?.$vocabulary || schema?.$id || schema?.$anchor || + schema?.$dynamicAnchor || 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 19cb7bd3e8d..61b194e88aa 100644 --- a/src/core/plugins/json-schema-2020-12/hoc.jsx +++ b/src/core/plugins/json-schema-2020-12/hoc.jsx @@ -8,6 +8,7 @@ import Keyword$schema from "./components/keywords/$schema" import Keyword$vocabulary from "./components/keywords/$vocabulary/$vocabulary" import Keyword$id from "./components/keywords/$id" import Keyword$anchor from "./components/keywords/$anchor" +import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor" import KeywordProperties from "./components/keywords/Properties" import KeywordType from "./components/keywords/Type/Type" import KeywordFormat from "./components/keywords/Format/Format" @@ -33,6 +34,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => { Keyword$vocabulary, Keyword$id, Keyword$anchor, + Keyword$dynamicAnchor, 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 a5c7c9508f3..d03441b0634 100644 --- a/src/core/plugins/json-schema-2020-12/index.js +++ b/src/core/plugins/json-schema-2020-12/index.js @@ -7,6 +7,7 @@ import Keyword$schema from "./components/keywords/$schema" import Keyword$vocabulary from "./components/keywords/$vocabulary/$vocabulary" import Keyword$id from "./components/keywords/$id" import Keyword$anchor from "./components/keywords/$anchor" +import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor" import KeywordType from "./components/keywords/Type/Type" import KeywordFormat from "./components/keywords/Format/Format" import KeywordTitle from "./components/keywords/Title/Title" @@ -24,6 +25,7 @@ const JSONSchema202012Plugin = () => ({ JSONSchema202012Keyword$vocabulary: Keyword$vocabulary, JSONSchema202012Keyword$id: Keyword$id, JSONSchema202012Keyword$anchor: Keyword$anchor, + JSONSchema202012Keyword$dynamicAnchor: Keyword$dynamicAnchor, 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 1e7008f7cc0..cf4c558569c 100644 --- a/src/core/plugins/oas31/wrap-components/models.jsx +++ b/src/core/plugins/oas31/wrap-components/models.jsx @@ -13,6 +13,9 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { const Keyword$vocabulary = getComponent("JSONSchema202012Keyword$vocabulary") const Keyword$id = getComponent("JSONSchema202012Keyword$id") const Keyword$anchor = getComponent("JSONSchema202012Keyword$anchor") + const Keyword$dynamicAnchor = getComponent( + "JSONSchema202012Keyword$dynamicAnchor" + ) const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") const KeywordType = getComponent("JSONSchema202012KeywordType") const KeywordFormat = getComponent("JSONSchema202012KeywordFormat") @@ -36,6 +39,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { Keyword$vocabulary, Keyword$id, Keyword$anchor, + Keyword$dynamicAnchor, KeywordProperties, KeywordType, KeywordFormat,