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

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

View File

@@ -37,6 +37,7 @@ const JSONSchema = ({ schema, name }) => {
const Keyword$id = useComponent("Keyword$id")
const Keyword$anchor = useComponent("Keyword$anchor")
const Keyword$dynamicAnchor = useComponent("Keyword$dynamicAnchor")
const Keyword$ref = useComponent("Keyword$ref")
const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat")
@@ -105,6 +106,7 @@ const JSONSchema = ({ schema, name }) => {
<Keyword$id schema={schema} />
<Keyword$anchor schema={schema} />
<Keyword$dynamicAnchor schema={schema} />
<Keyword$ref schema={schema} />
</div>
)}
</article>

View File

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

View File

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

View File

@@ -9,6 +9,7 @@ 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 Keyword$ref from "./components/keywords/$ref"
import KeywordProperties from "./components/keywords/Properties"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
@@ -35,6 +36,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
Keyword$id,
Keyword$anchor,
Keyword$dynamicAnchor,
Keyword$ref,
KeywordProperties,
KeywordType,
KeywordFormat,

View File

@@ -8,6 +8,7 @@ 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 Keyword$ref from "./components/keywords/$ref"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
import KeywordTitle from "./components/keywords/Title/Title"
@@ -26,6 +27,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012Keyword$id: Keyword$id,
JSONSchema202012Keyword$anchor: Keyword$anchor,
JSONSchema202012Keyword$dynamicAnchor: Keyword$dynamicAnchor,
JSONSchema202012Keyword$ref: Keyword$ref,
JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat,

View File

@@ -16,6 +16,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
const Keyword$dynamicAnchor = getComponent(
"JSONSchema202012Keyword$dynamicAnchor"
)
const Keyword$ref = getComponent("JSONSchema202012Keyword$ref")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
@@ -40,6 +41,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
Keyword$id,
Keyword$anchor,
Keyword$dynamicAnchor,
Keyword$ref,
KeywordProperties,
KeywordType,
KeywordFormat,