overrides for customisation
This commit is contained in:
@@ -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),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user