Skip to content

fix: schema.required is not a mandatory property #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading