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

Refs #8513
This commit is contained in:
Vladimir Gorej
2023-04-19 20:20:34 +02:00
committed by Vladimír Gorej
parent 19f58ef3f3
commit 628f029b3d
10 changed files with 41 additions and 3 deletions

View File

@@ -35,6 +35,7 @@ const JSONSchema = ({ schema, name }) => {
const Keyword$schema = useComponent("Keyword$schema") const Keyword$schema = useComponent("Keyword$schema")
const Keyword$vocabulary = useComponent("Keyword$vocabulary") const Keyword$vocabulary = useComponent("Keyword$vocabulary")
const Keyword$id = useComponent("Keyword$id") const Keyword$id = useComponent("Keyword$id")
const Keyword$anchor = useComponent("Keyword$anchor")
const KeywordProperties = useComponent("KeywordProperties") const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType") const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat") const KeywordFormat = useComponent("KeywordFormat")
@@ -101,6 +102,7 @@ const JSONSchema = ({ schema, name }) => {
<Keyword$schema schema={schema} /> <Keyword$schema schema={schema} />
<Keyword$vocabulary schema={schema} /> <Keyword$vocabulary schema={schema} />
<Keyword$id schema={schema} /> <Keyword$id schema={schema} />
<Keyword$anchor schema={schema} />
</div> </div>
)} )}
</article> </article>

View File

@@ -55,4 +55,8 @@
//} //}
} }
.json-schema-2020-12-core-keyword + .json-schema-2020-12-core-keyword__value::before {
content: '='
}

View File

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

View File

@@ -12,7 +12,7 @@ const $id = ({ schema }) => {
<div className="json-schema-2020-12__$id"> <div className="json-schema-2020-12__$id">
<span className="json-schema-2020-12-core-keyword">$id</span> <span className="json-schema-2020-12-core-keyword">$id</span>
<span className="json-schema-2020-12-core-keyword__value"> <span className="json-schema-2020-12-core-keyword__value">
={schema.$id} {schema.$id}
</span> </span>
</div> </div>
) )

View File

@@ -12,7 +12,7 @@ const $schema = ({ schema }) => {
<div className="json-schema-2020-12__$schema"> <div className="json-schema-2020-12__$schema">
<span className="json-schema-2020-12-core-keyword">$schema</span> <span className="json-schema-2020-12-core-keyword">$schema</span>
<span className="json-schema-2020-12-core-keyword__value"> <span className="json-schema-2020-12-core-keyword__value">
={schema.$schema} {schema.$schema}
</span> </span>
</div> </div>
) )

View File

@@ -8,7 +8,7 @@
border-radius: 4px; border-radius: 4px;
text-transform: lowercase; text-transform: lowercase;
&:before { &::before {
content: "format: "; content: "format: ";
} }
} }

View File

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

View File

@@ -7,6 +7,7 @@ import JSONSchema from "./components/JSONSchema/JSONSchema"
import Keyword$schema from "./components/keywords/$schema" import Keyword$schema from "./components/keywords/$schema"
import Keyword$vocabulary from "./components/keywords/$vocabulary/$vocabulary" import Keyword$vocabulary from "./components/keywords/$vocabulary/$vocabulary"
import Keyword$id from "./components/keywords/$id" import Keyword$id from "./components/keywords/$id"
import Keyword$anchor from "./components/keywords/$anchor"
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"
@@ -31,6 +32,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
Keyword$schema, Keyword$schema,
Keyword$vocabulary, Keyword$vocabulary,
Keyword$id, Keyword$id,
Keyword$anchor,
KeywordProperties, KeywordProperties,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,

View File

@@ -6,6 +6,7 @@ import KeywordProperties from "./components/keywords/Properties"
import Keyword$schema from "./components/keywords/$schema" import Keyword$schema from "./components/keywords/$schema"
import Keyword$vocabulary from "./components/keywords/$vocabulary/$vocabulary" import Keyword$vocabulary from "./components/keywords/$vocabulary/$vocabulary"
import Keyword$id from "./components/keywords/$id" import Keyword$id from "./components/keywords/$id"
import Keyword$anchor from "./components/keywords/$anchor"
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"
@@ -22,6 +23,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012Keyword$schema: Keyword$schema, JSONSchema202012Keyword$schema: Keyword$schema,
JSONSchema202012Keyword$vocabulary: Keyword$vocabulary, JSONSchema202012Keyword$vocabulary: Keyword$vocabulary,
JSONSchema202012Keyword$id: Keyword$id, JSONSchema202012Keyword$id: Keyword$id,
JSONSchema202012Keyword$anchor: Keyword$anchor,
JSONSchema202012KeywordProperties: KeywordProperties, JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType, JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat, JSONSchema202012KeywordFormat: KeywordFormat,

View File

@@ -12,6 +12,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
const Keyword$schema = getComponent("JSONSchema202012Keyword$schema") const Keyword$schema = getComponent("JSONSchema202012Keyword$schema")
const Keyword$vocabulary = getComponent("JSONSchema202012Keyword$vocabulary") const Keyword$vocabulary = getComponent("JSONSchema202012Keyword$vocabulary")
const Keyword$id = getComponent("JSONSchema202012Keyword$id") const Keyword$id = getComponent("JSONSchema202012Keyword$id")
const Keyword$anchor = getComponent("JSONSchema202012Keyword$anchor")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType") const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat") const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
@@ -34,6 +35,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
Keyword$schema, Keyword$schema,
Keyword$vocabulary, Keyword$vocabulary,
Keyword$id, Keyword$id,
Keyword$anchor,
KeywordProperties, KeywordProperties,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,