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

Refs #8513
This commit is contained in:
Vladimir Gorej
2023-04-21 13:17:08 +02:00
committed by Vladimír Gorej
parent dea5dbb10e
commit b7a402398f
8 changed files with 50 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ const JSONSchema = ({ schema, name }) => {
const KeywordOneOf = useComponent("KeywordOneOf")
const KeywordNot = useComponent("KeywordNot")
const KeywordIf = useComponent("KeywordIf")
const KeywordThen = useComponent("KeywordThen")
const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat")
@@ -115,6 +116,7 @@ const JSONSchema = ({ schema, name }) => {
<KeywordOneOf schema={schema} />
<KeywordNot schema={schema} />
<KeywordIf schema={schema} />
<KeywordThen schema={schema} />
<Keyword$schema schema={schema} />
<Keyword$vocabulary schema={schema} />
<Keyword$id schema={schema} />

View File

@@ -13,6 +13,7 @@
@import './keywords/OneOf/one-of';
@import './keywords/Not/not';
@import './keywords/If/if';
@import './keywords/Then/then';
@import './keywords/Type/type';
@import './keywords/Format/format';
@import './keywords/Description/description';

View File

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

View File

@@ -0,0 +1,10 @@
.json-schema-2020-12 {
&__then {
.json-schema-2020-12-core-keyword--then {
@extend .json-schema-2020-12-core-keyword--allOf;
}
}
}

View File

@@ -131,6 +131,7 @@ export const isExpandable = (schema) => {
schema?.oneOf ||
schema?.not ||
schema?.if ||
schema?.then ||
schema?.description ||
schema?.properties
)

View File

@@ -18,6 +18,7 @@ import KeywordAnyOf from "./components/keywords/AnyOf/AnyOf"
import KeywordOneOf from "./components/keywords/OneOf/OneOf"
import KeywordNot from "./components/keywords/Not/Not"
import KeywordIf from "./components/keywords/If/If"
import KeywordThen from "./components/keywords/Then/Then"
import KeywordProperties from "./components/keywords/Properties/Properties"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
@@ -53,6 +54,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
KeywordOneOf,
KeywordNot,
KeywordIf,
KeywordThen,
KeywordProperties,
KeywordType,
KeywordFormat,

View File

@@ -17,6 +17,7 @@ import KeywordAnyOf from "./components/keywords/AnyOf/AnyOf"
import KeywordOneOf from "./components/keywords/OneOf/OneOf"
import KeywordNot from "./components/keywords/Not/Not"
import KeywordIf from "./components/keywords/If/If"
import KeywordThen from "./components/keywords/Then/Then"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
import KeywordTitle from "./components/keywords/Title/Title"
@@ -44,6 +45,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012KeywordOneOf: KeywordOneOf,
JSONSchema202012KeywordNot: KeywordNot,
JSONSchema202012KeywordIf: KeywordIf,
JSONSchema202012KeywordThen: KeywordThen,
JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat,

View File

@@ -25,6 +25,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
const KeywordOneOf = getComponent("JSONSchema202012KeywordOneOf")
const KeywordNot = getComponent("JSONSchema202012KeywordNot")
const KeywordIf = getComponent("JSONSchema202012KeywordIf")
const KeywordThen = getComponent("JSONSchema202012KeywordThen")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
@@ -58,6 +59,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
KeywordOneOf,
KeywordNot,
KeywordIf,
KeywordThen,
KeywordProperties,
KeywordType,
KeywordFormat,