overrides for customisation

This commit is contained in:
2026-04-01 19:24:09 +05:30
parent 44567496a1
commit 6dc33be455
4 changed files with 38 additions and 29 deletions

View File

@@ -51,20 +51,22 @@ function parseSchemaFields(
const type = mapOpenApiType(prop);
const override = overrides[key];
fields[key] = {
type,
label:
prop.title ||
key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, " "),
required: required.includes(key),
options: prop.enum,
readOnly:
prop.readOnly ||
key === "id" ||
key === "created_at" ||
key === "updated_at",
...override,
};
console.log("key", key, "type", type, "prop", prop, "override", override);
if (key !== "id" && override?.display !== false) {
fields[key] = {
type,
label:
prop.title ||
key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, " "),
required: required.includes(key),
options: prop.enum,
readOnly:
prop.readOnly ||
key === "created_at" ||
key === "updated_at",
...override,
};
} else continue;
// Schema-based Relation Detection
// If it's an object/string and matches a resource name, it might be a relation
@@ -148,7 +150,7 @@ export async function loadConfigFromOpenApi(baseUrl: string): Promise<AppConfig>
label: schema.title || label,
pluralLabel: pluralLabel,
endpoint: listPath,
primaryKey: "_id", // assume 'id' as default or look for 'required' + 'unique'
primaryKey: "id", // assume 'id' as default or look for 'required' + 'unique'
fields: parseSchemaFields(schema, name, allResourceNames),
});
}