enumOptions and enum reader
This commit is contained in:
@@ -80,6 +80,21 @@ function parseSchemaFields(
|
||||
const relation = schemaToResourceMap.get(targetSchema);
|
||||
if (relation) {
|
||||
fields[key].relation = relation;
|
||||
|
||||
// Propagate enumOption from target resource config, or derive from target schema
|
||||
const explicitEnumOption = configuration[relation]?.enumOption;
|
||||
if (explicitEnumOption) {
|
||||
fields[key].enumOption = explicitEnumOption;
|
||||
} else {
|
||||
const targetProps = targetSchema.properties || {};
|
||||
const valueField = Object.entries(targetProps).find(
|
||||
([name, p]: [string, any]) => name !== 'id' && p.type === 'string'
|
||||
)?.[0];
|
||||
fields[key].enumOption = {
|
||||
key: 'id',
|
||||
value: valueField ?? 'id',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively parse nested objects (only if not a relation)
|
||||
|
||||
Reference in New Issue
Block a user