import { startCase } from "lodash";

export default schema => {
  let schemaToUse = schema;
  if (!schemaToUse.fields && Array.isArray(schema)) {
    schemaToUse = {
      fields: schema
    };
  }
  schemaToUse.fields = schemaToUse.fields.map(field => {
    if (typeof field === "string") {
      return {
        displayName: startCase(field),
        path: field,
        type: "string"
      };
    } else {
      return field;
    }
  });
  return schemaToUse;
};

@@ -392,16 +392,111 @@
      %7D;%0A
+    %7D else if (!field.type) %7B%0A      return %7B%0A        ...field,%0A        type: %22string%22%0A      %7D;%0A
     %7D el

add default type to field in datatable schema if not provided