From c8bbcf505e504085055879ce6bea8965e95ae9b8 Mon Sep 17 00:00:00 2001 From: Zachary Belford Date: Tue, 23 May 2023 14:23:57 -0700 Subject: [PATCH 1/2] fix: combiners with differing types render nothing for some children --- .../combiners/oneof-with-multi-types.json | 54 +++++++++++++++++++ src/__stories__/Combiners.tsx | 4 ++ .../SchemaRow/TopLevelSchemaRow.tsx | 6 ++- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/__fixtures__/combiners/oneof-with-multi-types.json diff --git a/src/__fixtures__/combiners/oneof-with-multi-types.json b/src/__fixtures__/combiners/oneof-with-multi-types.json new file mode 100644 index 00000000..e8492870 --- /dev/null +++ b/src/__fixtures__/combiners/oneof-with-multi-types.json @@ -0,0 +1,54 @@ +{ + "title": "a", + "oneOf": [ + { + "title": "b", + "type": "object", + "properties": { + "c": { + "title": "d", + "type": "string" + }, + "e": { + "title": "e", + "type": "string" + } + } + }, + { + "title": "f", + "type": "boolean" + }, + { + "title": "g", + "oneOf": [ + { + "title": "h", + "type": "string" + }, + { + "title": "l", + "type": "object", + "properties": { + "foo": { + "title": "k", + "oneOf": [ + { + "title": "m", + "type": "string" + }, + { + "title": "o", + "type": "object", + "properties": { + "foo": { "type": "string" } + } + } + ] + } + } + } + ] + } + ] +} diff --git a/src/__stories__/Combiners.tsx b/src/__stories__/Combiners.tsx index ad865471..2cc188f1 100644 --- a/src/__stories__/Combiners.tsx +++ b/src/__stories__/Combiners.tsx @@ -9,6 +9,7 @@ const allOfSchema = require('../__fixtures__/combiners/allOfs/base.json'); const allOfComplexSchema = require('../__fixtures__/combiners/allOfs/complex.json'); const oneOfWithArraySchema = require('../__fixtures__/combiners/oneof-with-array-type.json'); const oneOfWithArraySchema2 = require('../__fixtures__/combiners/oneof-within-array-item.json'); +const oneOfWithMultiTypesSchema = require('../__fixtures__/combiners/oneof-with-multi-types.json'); const anyOfObject = require('../__fixtures__/combiners/anyOf.json'); export default { @@ -32,5 +33,8 @@ ArrayOneOf.args = { schema: oneOfWithArraySchema as JSONSchema4, renderRootTreeL export const ArrayOneOf2 = Template.bind({}); ArrayOneOf2.args = { schema: oneOfWithArraySchema2 as JSONSchema4, renderRootTreeLines: true }; +export const OneOfMulti = Template.bind({}); +OneOfMulti.args = { schema: oneOfWithMultiTypesSchema, renderRootTreeLines: true }; + export const ObjectAnyOf = Template.bind({}); ObjectAnyOf.args = { schema: anyOfObject as JSONSchema4 }; diff --git a/src/components/SchemaRow/TopLevelSchemaRow.tsx b/src/components/SchemaRow/TopLevelSchemaRow.tsx index 9e101043..2f18da65 100644 --- a/src/components/SchemaRow/TopLevelSchemaRow.tsx +++ b/src/components/SchemaRow/TopLevelSchemaRow.tsx @@ -88,7 +88,11 @@ export const TopLevelSchemaRow = ({ currentNestingLevel={nestingLevel} parentNodeId={nodeId} /> - ) : null} + ) : combiner ? : null + + } ); } From 9a7710de241c60be98dd784a506ae1a4d16b0883 Mon Sep 17 00:00:00 2001 From: Zachary Belford Date: Mon, 29 May 2023 10:33:25 -0700 Subject: [PATCH 2/2] fix: prettier updates --- src/components/SchemaRow/TopLevelSchemaRow.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/SchemaRow/TopLevelSchemaRow.tsx b/src/components/SchemaRow/TopLevelSchemaRow.tsx index 2f18da65..7a58eba9 100644 --- a/src/components/SchemaRow/TopLevelSchemaRow.tsx +++ b/src/components/SchemaRow/TopLevelSchemaRow.tsx @@ -88,11 +88,9 @@ export const TopLevelSchemaRow = ({ currentNestingLevel={nestingLevel} parentNodeId={nodeId} /> - ) : combiner ? : null - - } + ) : combiner ? ( + + ) : null} ); }