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

Refs #8513
This commit is contained in:
Vladimir Gorej
2023-04-19 20:34:38 +02:00
committed by Vladimír Gorej
parent 6c5a126a46
commit 51a7f4eefd
6 changed files with 34 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ const JSONSchema = ({ schema, name }) => {
const Keyword$anchor = useComponent("Keyword$anchor") const Keyword$anchor = useComponent("Keyword$anchor")
const Keyword$dynamicAnchor = useComponent("Keyword$dynamicAnchor") const Keyword$dynamicAnchor = useComponent("Keyword$dynamicAnchor")
const Keyword$ref = useComponent("Keyword$ref") const Keyword$ref = useComponent("Keyword$ref")
const Keyword$dynamicRef = useComponent("Keyword$dynamicRef")
const KeywordProperties = useComponent("KeywordProperties") const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType") const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat") const KeywordFormat = useComponent("KeywordFormat")
@@ -107,6 +108,7 @@ const JSONSchema = ({ schema, name }) => {
<Keyword$anchor schema={schema} /> <Keyword$anchor schema={schema} />
<Keyword$dynamicAnchor schema={schema} /> <Keyword$dynamicAnchor schema={schema} />
<Keyword$ref schema={schema} /> <Keyword$ref schema={schema} />
<Keyword$dynamicRef schema={schema} />
</div> </div>
)} )}
</article> </article>

View File

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

View File

@@ -119,6 +119,7 @@ export const isExpandable = (schema) => {
schema?.$anchor || schema?.$anchor ||
schema?.$dynamicAnchor || schema?.$dynamicAnchor ||
schema?.$ref || schema?.$ref ||
schema?.$dynamicRef ||
schema?.description || schema?.description ||
schema?.properties schema?.properties
) )

View File

@@ -10,6 +10,7 @@ import Keyword$id from "./components/keywords/$id"
import Keyword$anchor from "./components/keywords/$anchor" import Keyword$anchor from "./components/keywords/$anchor"
import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor" import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor"
import Keyword$ref from "./components/keywords/$ref" import Keyword$ref from "./components/keywords/$ref"
import Keyword$dynamicRef from "./components/keywords/$dynamicRef"
import KeywordProperties from "./components/keywords/Properties" import KeywordProperties from "./components/keywords/Properties"
import KeywordType from "./components/keywords/Type/Type" import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format" import KeywordFormat from "./components/keywords/Format/Format"
@@ -37,6 +38,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
Keyword$anchor, Keyword$anchor,
Keyword$dynamicAnchor, Keyword$dynamicAnchor,
Keyword$ref, Keyword$ref,
Keyword$dynamicRef,
KeywordProperties, KeywordProperties,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,

View File

@@ -9,6 +9,7 @@ import Keyword$id from "./components/keywords/$id"
import Keyword$anchor from "./components/keywords/$anchor" import Keyword$anchor from "./components/keywords/$anchor"
import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor" import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor"
import Keyword$ref from "./components/keywords/$ref" import Keyword$ref from "./components/keywords/$ref"
import Keyword$dynamicRef from "./components/keywords/$dynamicRef"
import KeywordType from "./components/keywords/Type/Type" import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format" import KeywordFormat from "./components/keywords/Format/Format"
import KeywordTitle from "./components/keywords/Title/Title" import KeywordTitle from "./components/keywords/Title/Title"
@@ -28,6 +29,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012Keyword$anchor: Keyword$anchor, JSONSchema202012Keyword$anchor: Keyword$anchor,
JSONSchema202012Keyword$dynamicAnchor: Keyword$dynamicAnchor, JSONSchema202012Keyword$dynamicAnchor: Keyword$dynamicAnchor,
JSONSchema202012Keyword$ref: Keyword$ref, JSONSchema202012Keyword$ref: Keyword$ref,
JSONSchema202012Keyword$dynamicRef: Keyword$dynamicRef,
JSONSchema202012KeywordProperties: KeywordProperties, JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType, JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat, JSONSchema202012KeywordFormat: KeywordFormat,

View File

@@ -17,6 +17,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
"JSONSchema202012Keyword$dynamicAnchor" "JSONSchema202012Keyword$dynamicAnchor"
) )
const Keyword$ref = getComponent("JSONSchema202012Keyword$ref") const Keyword$ref = getComponent("JSONSchema202012Keyword$ref")
const Keyword$dynamicRef = getComponent("JSONSchema202012Keyword$dynamicRef")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType") const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat") const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
@@ -42,6 +43,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
Keyword$anchor, Keyword$anchor,
Keyword$dynamicAnchor, Keyword$dynamicAnchor,
Keyword$ref, Keyword$ref,
Keyword$dynamicRef,
KeywordProperties, KeywordProperties,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,