feat(json-schema-2020-12): add support for unevaluatedItems keyword
Refs #8513
This commit is contained in:
committed by
Vladimír Gorej
parent
7f9ac83f16
commit
aba7f986ad
@@ -58,6 +58,7 @@ const JSONSchema = ({ schema, name }) => {
|
||||
"KeywordAdditionalProperties"
|
||||
)
|
||||
const KeywordPropertyNames = useComponent("KeywordPropertyNames")
|
||||
const KeywordUnevaluatedItems = useComponent("KeywordUnevaluatedItems")
|
||||
const KeywordType = useComponent("KeywordType")
|
||||
const KeywordFormat = useComponent("KeywordFormat")
|
||||
const KeywordTitle = useComponent("KeywordTitle")
|
||||
@@ -134,6 +135,7 @@ const JSONSchema = ({ schema, name }) => {
|
||||
<KeywordDependentSchemas schema={schema} />
|
||||
<KeywordPrefixItems schema={schema} />
|
||||
<KeywordItems schema={schema} />
|
||||
<KeywordUnevaluatedItems schema={schema} />
|
||||
<KeywordContains schema={schema} />
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -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
|
||||
@@ -157,6 +157,7 @@ export const isExpandable = (schema) => {
|
||||
schema?.patternProperties ||
|
||||
fn.hasKeyword(schema, "additionalProperties") ||
|
||||
fn.hasKeyword(schema, "propertyNames") ||
|
||||
fn.hasKeyword(schema, "unevaluatedItems") ||
|
||||
schema?.description
|
||||
)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import KeywordProperties from "./components/keywords/Properties/Properties"
|
||||
import KeywordPatternProperties from "./components/keywords/PatternProperties/PatternProperties"
|
||||
import KeywordAdditionalProperties from "./components/keywords/AdditionalProperties"
|
||||
import KeywordPropertyNames from "./components/keywords/PropertyNames"
|
||||
import KeywordUnevaluatedItems from "./components/keywords/UnevaluatedItems"
|
||||
import KeywordType from "./components/keywords/Type/Type"
|
||||
import KeywordFormat from "./components/keywords/Format/Format"
|
||||
import KeywordTitle from "./components/keywords/Title/Title"
|
||||
@@ -73,6 +74,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
||||
KeywordPatternProperties,
|
||||
KeywordAdditionalProperties,
|
||||
KeywordPropertyNames,
|
||||
KeywordUnevaluatedItems,
|
||||
KeywordType,
|
||||
KeywordFormat,
|
||||
KeywordTitle,
|
||||
|
||||
@@ -26,6 +26,7 @@ import KeywordProperties from "./components/keywords/Properties/Properties"
|
||||
import KeywordPatternProperties from "./components/keywords/PatternProperties/PatternProperties"
|
||||
import KeywordAdditionalProperties from "./components/keywords/AdditionalProperties"
|
||||
import KeywordPropertyNames from "./components/keywords/PropertyNames"
|
||||
import KeywordUnevaluatedItems from "./components/keywords/UnevaluatedItems"
|
||||
import KeywordType from "./components/keywords/Type/Type"
|
||||
import KeywordFormat from "./components/keywords/Format/Format"
|
||||
import KeywordTitle from "./components/keywords/Title/Title"
|
||||
@@ -63,6 +64,7 @@ const JSONSchema202012Plugin = () => ({
|
||||
JSONSchema202012KeywordPatternProperties: KeywordPatternProperties,
|
||||
JSONSchema202012KeywordAdditionalProperties: KeywordAdditionalProperties,
|
||||
JSONSchema202012KeywordPropertyNames: KeywordPropertyNames,
|
||||
JSONSchema202012KeywordUnevaluatedItems: KeywordUnevaluatedItems,
|
||||
JSONSchema202012KeywordType: KeywordType,
|
||||
JSONSchema202012KeywordFormat: KeywordFormat,
|
||||
JSONSchema202012KeywordTitle: KeywordTitle,
|
||||
|
||||
@@ -43,6 +43,9 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
||||
const KeywordPropertyNames = getComponent(
|
||||
"JSONSchema202012KeywordPropertyNames"
|
||||
)
|
||||
const KeywordUnevaluatedItems = getComponent(
|
||||
"JSONSchema202012KeywordUnevaluatedItems"
|
||||
)
|
||||
const KeywordType = getComponent("JSONSchema202012KeywordType")
|
||||
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
|
||||
const KeywordTitle = getComponent("JSONSchema202012KeywordTitle")
|
||||
@@ -85,6 +88,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
||||
KeywordPatternProperties,
|
||||
KeywordAdditionalProperties,
|
||||
KeywordPropertyNames,
|
||||
KeywordUnevaluatedItems,
|
||||
KeywordType,
|
||||
KeywordFormat,
|
||||
KeywordTitle,
|
||||
|
||||
Reference in New Issue
Block a user