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 4f2a8fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 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;
}
5 changes: 3 additions & 2 deletions 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],
properties: { ...defaultSchema.properties, ...schema.properties},
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 4f2a8fa

Please sign in to comment.