From d1fb5135d463a5c320028d613fea416d496f5e65 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 6 Apr 2021 02:09:36 +0200 Subject: [PATCH] config-schema: add support for additional and pattern props and items Signed-off-by: Patrik Oldsberg --- .../components/SchemaViewer/SchemaViewer.tsx | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx b/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx index b49651ae7b..5e6c1ec94c 100644 --- a/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx +++ b/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx @@ -68,6 +68,12 @@ export function MetadataView({ schema }: { schema: Schema }) { + {schema.additionalProperties === true && ( + + )} + {schema.additionalItems === true && ( + + )} + {schema.additionalItems && schema.additionalItems !== true && ( + <> + Additional Items + + + )} ); } export function ObjectView({ path, depth, schema }: SchemaViewProps) { const properties = Object.entries(schema.properties ?? {}); + const patternProperties = Object.entries(schema.patternProperties ?? {}); + return ( <> {depth > 0 && ( @@ -294,6 +313,33 @@ export function ObjectView({ path, depth, schema }: SchemaViewProps) { ))} )} + {patternProperties.length > 0 && ( + <> + {depth > 0 && ( + Pattern Properties + )} + {patternProperties.map(([name, propSchema], index) => ( + ` : name} + depth={depth + 1} + schema={propSchema} + lastChild={index === patternProperties.length - 1} + required={isRequired(name, schema.required)} + /> + ))} + + )} + {schema.additionalProperties && schema.additionalProperties !== true && ( + <> + Additional Properties + + + )} ); }