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

Refs #8513
This commit is contained in:
Vladimir Gorej
2023-04-20 12:52:40 +02:00
committed by Vladimír Gorej
parent daa0506163
commit 2f08f6424b
6 changed files with 34 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ const JSONSchema = ({ schema, name }) => {
const Keyword$ref = useComponent("Keyword$ref") const Keyword$ref = useComponent("Keyword$ref")
const Keyword$dynamicRef = useComponent("Keyword$dynamicRef") const Keyword$dynamicRef = useComponent("Keyword$dynamicRef")
const Keyword$defs = useComponent("Keyword$defs") const Keyword$defs = useComponent("Keyword$defs")
const Keyword$comment = useComponent("Keyword$comment")
const KeywordProperties = useComponent("KeywordProperties") const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType") const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat") const KeywordFormat = useComponent("KeywordFormat")
@@ -111,6 +112,7 @@ const JSONSchema = ({ schema, name }) => {
<Keyword$ref schema={schema} /> <Keyword$ref schema={schema} />
<Keyword$dynamicRef schema={schema} /> <Keyword$dynamicRef schema={schema} />
<Keyword$defs schema={schema} /> <Keyword$defs schema={schema} />
<Keyword$comment schema={schema} />
</div> </div>
)} )}
</article> </article>

View File

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

View File

@@ -121,6 +121,7 @@ export const isExpandable = (schema) => {
schema?.$ref || schema?.$ref ||
schema?.$dynamicRef || schema?.$dynamicRef ||
schema?.$defs || schema?.$defs ||
schema?.$comment ||
schema?.description || schema?.description ||
schema?.properties schema?.properties
) )

View File

@@ -12,6 +12,7 @@ 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 Keyword$dynamicRef from "./components/keywords/$dynamicRef"
import Keyword$defs from "./components/keywords/$defs/$defs" import Keyword$defs from "./components/keywords/$defs/$defs"
import Keyword$comment from "./components/keywords/$comment"
import KeywordProperties from "./components/keywords/Properties/Properties" import KeywordProperties from "./components/keywords/Properties/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"
@@ -41,6 +42,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
Keyword$ref, Keyword$ref,
Keyword$dynamicRef, Keyword$dynamicRef,
Keyword$defs, Keyword$defs,
Keyword$comment,
KeywordProperties, KeywordProperties,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,

View File

@@ -11,6 +11,7 @@ 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 Keyword$dynamicRef from "./components/keywords/$dynamicRef"
import Keyword$defs from "./components/keywords/$defs/$defs" import Keyword$defs from "./components/keywords/$defs/$defs"
import Keyword$comment from "./components/keywords/$comment"
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"
@@ -32,6 +33,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012Keyword$ref: Keyword$ref, JSONSchema202012Keyword$ref: Keyword$ref,
JSONSchema202012Keyword$dynamicRef: Keyword$dynamicRef, JSONSchema202012Keyword$dynamicRef: Keyword$dynamicRef,
JSONSchema202012Keyword$defs: Keyword$defs, JSONSchema202012Keyword$defs: Keyword$defs,
JSONSchema202012Keyword$comment: Keyword$comment,
JSONSchema202012KeywordProperties: KeywordProperties, JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType, JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat, JSONSchema202012KeywordFormat: KeywordFormat,

View File

@@ -19,6 +19,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
const Keyword$ref = getComponent("JSONSchema202012Keyword$ref") const Keyword$ref = getComponent("JSONSchema202012Keyword$ref")
const Keyword$dynamicRef = getComponent("JSONSchema202012Keyword$dynamicRef") const Keyword$dynamicRef = getComponent("JSONSchema202012Keyword$dynamicRef")
const Keyword$defs = getComponent("JSONSchema202012Keyword$defs") const Keyword$defs = getComponent("JSONSchema202012Keyword$defs")
const Keyword$comment = getComponent("JSONSchema202012Keyword$comment")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType") const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat") const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
@@ -46,6 +47,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
Keyword$ref, Keyword$ref,
Keyword$dynamicRef, Keyword$dynamicRef,
Keyword$defs, Keyword$defs,
Keyword$comment,
KeywordProperties, KeywordProperties,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,