Skip to content

Commit

Permalink
fix: schema.required is not a mandatory property
Browse files Browse the repository at this point in the history
  • Loading branch information
wbabyte committed Sep 26, 2024
1 parent 5c91462 commit d2f6456
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/schema-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ function _canInline(schema, key) {
}

export function canGrid(schema) {
const keys = Object.keys(schema.properties);
const keys = Object.keys(schema.properties || {});
return keys.length > 2 && keys.filter((key) => _canInline(schema, key)).length === keys.length;
}
3 changes: 2 additions & 1 deletion src/organisms/gv-resources/gv-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ export class GvResources extends KeyboardElement(LitElement) {
};

const schema = typeof resourceType.schema === 'string' ? JSON.parse(resourceType.schema) : resourceType.schema;
const schemaRequired = schema.required ? schema.required : [];

return {
properties: { ...defaultSchema.properties, ...schema.properties },
required: [...defaultSchema.required, ...schema.required],
required: [...defaultSchema.required, ...schemaRequired],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class GvSchemaFormControlObject extends UpdateAfterBrowser(LitElement) {
}

render() {
const keys = Object.keys(this.schema.properties);
const keys = Object.keys(this.schema.properties || {});
const isGrid = canGrid(this.schema);
const classes = {
'form_control-inline': canInline(this.schema),
Expand Down

0 comments on commit d2f6456

Please sign in to comment.