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

Refs #8513
This commit is contained in:
Vladimir Gorej
2023-04-24 14:24:05 +02:00
committed by Vladimír Gorej
parent 1f1f045b2b
commit 31a1fed11e
6 changed files with 39 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ const JSONSchema = ({ schema, name }) => {
const KeywordDependentSchemas = useComponent("KeywordDependentSchemas") const KeywordDependentSchemas = useComponent("KeywordDependentSchemas")
const KeywordPrefixItems = useComponent("KeywordPrefixItems") const KeywordPrefixItems = useComponent("KeywordPrefixItems")
const KeywordItems = useComponent("KeywordItems") const KeywordItems = useComponent("KeywordItems")
const KeywordContains = useComponent("KeywordContains")
const KeywordProperties = useComponent("KeywordProperties") const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType") const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat") const KeywordFormat = useComponent("KeywordFormat")
@@ -125,6 +126,7 @@ const JSONSchema = ({ schema, name }) => {
<KeywordDependentSchemas schema={schema} /> <KeywordDependentSchemas schema={schema} />
<KeywordPrefixItems schema={schema} /> <KeywordPrefixItems schema={schema} />
<KeywordItems schema={schema} /> <KeywordItems schema={schema} />
<KeywordContains schema={schema} />
<Keyword$schema schema={schema} /> <Keyword$schema schema={schema} />
<Keyword$vocabulary schema={schema} /> <Keyword$vocabulary schema={schema} />
<Keyword$id schema={schema} /> <Keyword$id schema={schema} />

View File

@@ -0,0 +1,30 @@
/**
* @prettier
*/
import React from "react"
import { schema } from "../../prop-types"
import { useComponent } from "../../hooks"
const Contains = ({ schema }) => {
if (!schema?.contains) return null
const JSONSchema = useComponent("JSONSchema")
const name = (
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--primary">
Contains
</span>
)
return (
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--contains">
<JSONSchema name={name} schema={schema.contains} />
</div>
)
}
Contains.propTypes = {
schema: schema.isRequired,
}
export default Contains

View File

@@ -143,6 +143,7 @@ export const isExpandable = (schema) => {
schema?.dependentSchemas || schema?.dependentSchemas ||
schema?.prefixItems || schema?.prefixItems ||
schema?.items || schema?.items ||
schema?.contains ||
schema?.description || schema?.description ||
schema?.properties schema?.properties
) )

View File

@@ -23,6 +23,7 @@ import KeywordElse from "./components/keywords/Else"
import KeywordDependentSchemas from "./components/keywords/DependentSchemas" import KeywordDependentSchemas from "./components/keywords/DependentSchemas"
import KeywordPrefixItems from "./components/keywords/PrefixItems" import KeywordPrefixItems from "./components/keywords/PrefixItems"
import KeywordItems from "./components/keywords/Items" import KeywordItems from "./components/keywords/Items"
import KeywordContains from "./components/keywords/Contains"
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"
@@ -63,6 +64,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
KeywordDependentSchemas, KeywordDependentSchemas,
KeywordPrefixItems, KeywordPrefixItems,
KeywordItems, KeywordItems,
KeywordContains,
KeywordProperties, KeywordProperties,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,

View File

@@ -22,6 +22,7 @@ import KeywordElse from "./components/keywords/Else"
import KeywordDependentSchemas from "./components/keywords/DependentSchemas" import KeywordDependentSchemas from "./components/keywords/DependentSchemas"
import KeywordPrefixItems from "./components/keywords/PrefixItems" import KeywordPrefixItems from "./components/keywords/PrefixItems"
import KeywordItems from "./components/keywords/Items" import KeywordItems from "./components/keywords/Items"
import KeywordContains from "./components/keywords/Contains"
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"
@@ -54,6 +55,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012KeywordDependentSchemas: KeywordDependentSchemas, JSONSchema202012KeywordDependentSchemas: KeywordDependentSchemas,
JSONSchema202012KeywordPrefixItems: KeywordPrefixItems, JSONSchema202012KeywordPrefixItems: KeywordPrefixItems,
JSONSchema202012KeywordItems: KeywordItems, JSONSchema202012KeywordItems: KeywordItems,
JSONSchema202012KeywordContains: KeywordContains,
JSONSchema202012KeywordProperties: KeywordProperties, JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType, JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat, JSONSchema202012KeywordFormat: KeywordFormat,

View File

@@ -32,6 +32,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
) )
const KeywordPrefixItems = getComponent("JSONSchema202012KeywordPrefixItems") const KeywordPrefixItems = getComponent("JSONSchema202012KeywordPrefixItems")
const KeywordItems = getComponent("JSONSchema202012KeywordItems") const KeywordItems = getComponent("JSONSchema202012KeywordItems")
const KeywordContains = getComponent("JSONSchema202012KeywordContains")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType") const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat") const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
@@ -70,6 +71,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
KeywordDependentSchemas, KeywordDependentSchemas,
KeywordPrefixItems, KeywordPrefixItems,
KeywordItems, KeywordItems,
KeywordContains,
KeywordProperties, KeywordProperties,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,