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

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

View File

@@ -50,6 +50,7 @@ const JSONSchema = ({ schema, name }) => {
const KeywordElse = useComponent("KeywordElse")
const KeywordDependentSchemas = useComponent("KeywordDependentSchemas")
const KeywordPrefixItems = useComponent("KeywordPrefixItems")
const KeywordItems = useComponent("KeywordItems")
const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat")
@@ -123,6 +124,7 @@ const JSONSchema = ({ schema, name }) => {
<KeywordElse schema={schema} />
<KeywordDependentSchemas schema={schema} />
<KeywordPrefixItems schema={schema} />
<KeywordItems schema={schema} />
<Keyword$schema schema={schema} />
<Keyword$vocabulary 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 Items = ({ schema }) => {
if (!schema?.items) return null
const JSONSchema = useComponent("JSONSchema")
const name = (
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--primary">
Items
</span>
)
return (
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--items">
<JSONSchema name={name} schema={schema.items} />
</div>
)
}
Items.propTypes = {
schema: schema.isRequired,
}
export default Items

View File

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

View File

@@ -22,6 +22,7 @@ import KeywordThen from "./components/keywords/Then"
import KeywordElse from "./components/keywords/Else"
import KeywordDependentSchemas from "./components/keywords/DependentSchemas"
import KeywordPrefixItems from "./components/keywords/PrefixItems"
import KeywordItems from "./components/keywords/Items"
import KeywordProperties from "./components/keywords/Properties/Properties"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
@@ -61,6 +62,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
KeywordElse,
KeywordDependentSchemas,
KeywordPrefixItems,
KeywordItems,
KeywordProperties,
KeywordType,
KeywordFormat,

View File

@@ -21,6 +21,7 @@ import KeywordThen from "./components/keywords/Then"
import KeywordElse from "./components/keywords/Else"
import KeywordDependentSchemas from "./components/keywords/DependentSchemas"
import KeywordPrefixItems from "./components/keywords/PrefixItems"
import KeywordItems from "./components/keywords/Items"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
import KeywordTitle from "./components/keywords/Title/Title"
@@ -52,6 +53,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012KeywordElse: KeywordElse,
JSONSchema202012KeywordDependentSchemas: KeywordDependentSchemas,
JSONSchema202012KeywordPrefixItems: KeywordPrefixItems,
JSONSchema202012KeywordItems: KeywordItems,
JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat,

View File

@@ -31,6 +31,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
"JSONSchema202012KeywordDependentSchemas"
)
const KeywordPrefixItems = getComponent("JSONSchema202012KeywordPrefixItems")
const KeywordItems = getComponent("JSONSchema202012KeywordItems")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
@@ -68,6 +69,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
KeywordElse,
KeywordDependentSchemas,
KeywordPrefixItems,
KeywordItems,
KeywordProperties,
KeywordType,
KeywordFormat,