From 66d55034b825a28323cc6ca9c9ac1ce925cca10c Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Mon, 24 Apr 2023 15:33:18 +0200 Subject: [PATCH] fix(json-schema-2020-12): handle boolean schemas properly Refs #8513 --- .../components/keywords/Contains.jsx | 2 +- .../json-schema-2020-12/components/keywords/Else.jsx | 2 +- .../json-schema-2020-12/components/keywords/If.jsx | 2 +- .../json-schema-2020-12/components/keywords/Not.jsx | 2 +- .../json-schema-2020-12/components/keywords/Then.jsx | 2 +- src/core/plugins/json-schema-2020-12/fn.js | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Contains.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Contains.jsx index 16629e15..8b1a2b93 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Contains.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Contains.jsx @@ -7,7 +7,7 @@ import { schema } from "../../prop-types" import { useComponent } from "../../hooks" const Contains = ({ schema }) => { - if (!schema?.contains) return null + if (!Object.hasOwn(schema, "contains")) return null const JSONSchema = useComponent("JSONSchema") const name = ( diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx index 7341c995..004c503a 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx @@ -7,7 +7,7 @@ import { schema } from "../../prop-types" import { useComponent } from "../../hooks" const Else = ({ schema }) => { - if (!schema?.else) return null + if (!Object.hasOwn(schema, "contains")) return null const JSONSchema = useComponent("JSONSchema") const name = ( diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/If.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/If.jsx index 881ddc18..b43c276f 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/If.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/If.jsx @@ -7,7 +7,7 @@ import { schema } from "../../prop-types" import { useComponent } from "../../hooks" const If = ({ schema }) => { - if (!schema?.if) return null + if (!Object.hasOwn(schema, "if")) return null const JSONSchema = useComponent("JSONSchema") const name = ( diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx index b6b6626a..3544ed05 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx @@ -7,7 +7,7 @@ import { schema } from "../../prop-types" import { useComponent } from "../../hooks" const Not = ({ schema }) => { - if (!schema?.not) return null + if (!Object.hasOwn(schema, "contains")) return null const JSONSchema = useComponent("JSONSchema") const name = ( diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx index d06d2b8b..3f4dd161 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx @@ -7,7 +7,7 @@ import { schema } from "../../prop-types" import { useComponent } from "../../hooks" const Then = ({ schema }) => { - if (!schema?.then) return null + if (!Object.hasOwn(schema, "then")) return null const JSONSchema = useComponent("JSONSchema") const name = ( diff --git a/src/core/plugins/json-schema-2020-12/fn.js b/src/core/plugins/json-schema-2020-12/fn.js index cc20ddf2..82419d2a 100644 --- a/src/core/plugins/json-schema-2020-12/fn.js +++ b/src/core/plugins/json-schema-2020-12/fn.js @@ -136,14 +136,14 @@ export const isExpandable = (schema) => { schema?.allOf || schema?.anyOf || schema?.oneOf || - schema?.not || - schema?.if || - schema?.then || - schema?.else || + Object.hasOwn(schema, "not") || + Object.hasOwn(schema, "if") || + Object.hasOwn(schema, "then") || + Object.hasOwn(schema, "else") || schema?.dependentSchemas || schema?.prefixItems || schema?.items || - schema?.contains || + Object.hasOwn(schema, "contains") || schema?.properties || schema?.patternProperties || schema?.description