feat(json-schema-2020-12): add support for dynamicAnchor keyword

Refs #8513
This commit is contained in:
Vladimir Gorej
2023-04-19 20:24:58 +02:00
committed by Vladimír Gorej
parent 628f029b3d
commit 06bb79d5f6
6 changed files with 36 additions and 0 deletions

View File

@@ -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 }) => {
<Keyword$vocabulary schema={schema} />
<Keyword$id schema={schema} />
<Keyword$anchor schema={schema} />
<Keyword$dynamicAnchor schema={schema} />
</div>
)}
</article>

View File

@@ -0,0 +1,25 @@
/**
* @prettier
*/
import React from "react"
import { schema } from "../../prop-types"
const $dynamicAnchor = ({ schema }) => {
if (!schema?.$dynamicAnchor) return null
return (
<div className="json-schema-2020-12__$dynamicAnchor">
<span className="json-schema-2020-12-core-keyword">$dynamicAnchor</span>
<span className="json-schema-2020-12-core-keyword__value">
{schema.$dynamicAnchor}
</span>
</div>
)
}
$dynamicAnchor.propTypes = {
schema: schema.isRequired,
}
export default $dynamicAnchor

View File

@@ -117,6 +117,7 @@ export const isExpandable = (schema) => {
schema?.$vocabulary ||
schema?.$id ||
schema?.$anchor ||
schema?.$dynamicAnchor ||
schema?.description ||
schema?.properties
)

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,