fix: differentiate between entirely and partially composite schemas

Signed-off-by: Matt Benson <gudnabrsam@gmail.com>
This commit is contained in:
Matt Benson
2025-06-20 10:27:34 -05:00
parent 3c7e2c900b
commit b0dc9b8781
2 changed files with 17 additions and 7 deletions
@@ -102,6 +102,9 @@ const getSubschemas = (schema: JSONSchema7Definition): subSchemasType => {
base[key as Exclude<keyof JSONSchema7, keyof subSchemasType>] = value;
}
}
if (!(base?.type === 'object' || 'properties' in base)) {
return subschemas;
}
return Object.fromEntries(
Object.entries(subschemas).map(([key, sub]) => {
const mergedSubschema = sub.map(alt => {
@@ -358,13 +361,15 @@ export const RenderSchema = ({
let columns: Column[] | undefined;
let elements: SchemaRenderElement[] | undefined;
if (strategy === 'root') {
elements = [{ schema }];
columns = [typeColumn];
if (schema.description) {
columns.unshift(descriptionColumn);
}
if (schema.title) {
columns.unshift(titleColumn);
if ('type' in schema || !Object.keys(subschemas).length) {
elements = [{ schema }];
columns = [typeColumn];
if (schema.description) {
columns.unshift(descriptionColumn);
}
if (schema.title) {
columns.unshift(titleColumn);
}
}
} else if (schema.properties) {
columns = [nameColumn, titleColumn, descriptionColumn, typeColumn];