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

Refs #8513
This commit is contained in:
Vladimir Gorej
2023-04-25 08:04:43 +02:00
committed by Vladimír Gorej
parent 7f9ac83f16
commit aba7f986ad
6 changed files with 44 additions and 0 deletions

View File

@@ -58,6 +58,7 @@ const JSONSchema = ({ schema, name }) => {
"KeywordAdditionalProperties" "KeywordAdditionalProperties"
) )
const KeywordPropertyNames = useComponent("KeywordPropertyNames") const KeywordPropertyNames = useComponent("KeywordPropertyNames")
const KeywordUnevaluatedItems = useComponent("KeywordUnevaluatedItems")
const KeywordType = useComponent("KeywordType") const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat") const KeywordFormat = useComponent("KeywordFormat")
const KeywordTitle = useComponent("KeywordTitle") const KeywordTitle = useComponent("KeywordTitle")
@@ -134,6 +135,7 @@ const JSONSchema = ({ schema, name }) => {
<KeywordDependentSchemas schema={schema} /> <KeywordDependentSchemas schema={schema} />
<KeywordPrefixItems schema={schema} /> <KeywordPrefixItems schema={schema} />
<KeywordItems schema={schema} /> <KeywordItems schema={schema} />
<KeywordUnevaluatedItems schema={schema} />
<KeywordContains schema={schema} /> <KeywordContains schema={schema} />
</> </>
)} )}

View File

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

View File

@@ -157,6 +157,7 @@ export const isExpandable = (schema) => {
schema?.patternProperties || schema?.patternProperties ||
fn.hasKeyword(schema, "additionalProperties") || fn.hasKeyword(schema, "additionalProperties") ||
fn.hasKeyword(schema, "propertyNames") || fn.hasKeyword(schema, "propertyNames") ||
fn.hasKeyword(schema, "unevaluatedItems") ||
schema?.description schema?.description
) )
} }

View File

@@ -28,6 +28,7 @@ import KeywordProperties from "./components/keywords/Properties/Properties"
import KeywordPatternProperties from "./components/keywords/PatternProperties/PatternProperties" import KeywordPatternProperties from "./components/keywords/PatternProperties/PatternProperties"
import KeywordAdditionalProperties from "./components/keywords/AdditionalProperties" import KeywordAdditionalProperties from "./components/keywords/AdditionalProperties"
import KeywordPropertyNames from "./components/keywords/PropertyNames" import KeywordPropertyNames from "./components/keywords/PropertyNames"
import KeywordUnevaluatedItems from "./components/keywords/UnevaluatedItems"
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"
@@ -73,6 +74,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
KeywordPatternProperties, KeywordPatternProperties,
KeywordAdditionalProperties, KeywordAdditionalProperties,
KeywordPropertyNames, KeywordPropertyNames,
KeywordUnevaluatedItems,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,
KeywordTitle, KeywordTitle,

View File

@@ -26,6 +26,7 @@ import KeywordProperties from "./components/keywords/Properties/Properties"
import KeywordPatternProperties from "./components/keywords/PatternProperties/PatternProperties" import KeywordPatternProperties from "./components/keywords/PatternProperties/PatternProperties"
import KeywordAdditionalProperties from "./components/keywords/AdditionalProperties" import KeywordAdditionalProperties from "./components/keywords/AdditionalProperties"
import KeywordPropertyNames from "./components/keywords/PropertyNames" import KeywordPropertyNames from "./components/keywords/PropertyNames"
import KeywordUnevaluatedItems from "./components/keywords/UnevaluatedItems"
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"
@@ -63,6 +64,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012KeywordPatternProperties: KeywordPatternProperties, JSONSchema202012KeywordPatternProperties: KeywordPatternProperties,
JSONSchema202012KeywordAdditionalProperties: KeywordAdditionalProperties, JSONSchema202012KeywordAdditionalProperties: KeywordAdditionalProperties,
JSONSchema202012KeywordPropertyNames: KeywordPropertyNames, JSONSchema202012KeywordPropertyNames: KeywordPropertyNames,
JSONSchema202012KeywordUnevaluatedItems: KeywordUnevaluatedItems,
JSONSchema202012KeywordType: KeywordType, JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat, JSONSchema202012KeywordFormat: KeywordFormat,
JSONSchema202012KeywordTitle: KeywordTitle, JSONSchema202012KeywordTitle: KeywordTitle,

View File

@@ -43,6 +43,9 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
const KeywordPropertyNames = getComponent( const KeywordPropertyNames = getComponent(
"JSONSchema202012KeywordPropertyNames" "JSONSchema202012KeywordPropertyNames"
) )
const KeywordUnevaluatedItems = getComponent(
"JSONSchema202012KeywordUnevaluatedItems"
)
const KeywordType = getComponent("JSONSchema202012KeywordType") const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat") const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
const KeywordTitle = getComponent("JSONSchema202012KeywordTitle") const KeywordTitle = getComponent("JSONSchema202012KeywordTitle")
@@ -85,6 +88,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
KeywordPatternProperties, KeywordPatternProperties,
KeywordAdditionalProperties, KeywordAdditionalProperties,
KeywordPropertyNames, KeywordPropertyNames,
KeywordUnevaluatedItems,
KeywordType, KeywordType,
KeywordFormat, KeywordFormat,
KeywordTitle, KeywordTitle,