khata compliant with new react-openapi
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
function getNested(obj: any, path: string): any {
|
||||
return path.split(".").reduce((o, k) => o?.[k], obj);
|
||||
}
|
||||
|
||||
export function applyDisplayFormat(item: any, format: string): string {
|
||||
if (!item || typeof item !== "object") return String(item ?? "");
|
||||
return format.replace(/\{(\w+)\}/g, (_, key) => String(item[key] ?? ""));
|
||||
return format.replace(/\{([\w.]+)\}/g, (_, key) => {
|
||||
const val = getNested(item, key);
|
||||
return val != null ? String(val) : "";
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user