Hi all, I’ve wrote this code gen tool that can take json and return DS model. It can be run locally by ember server. Also supports making model fragments from nested json to 1 level.
Give it this:
{
"shouldBeNumber1": "1",
"shouldBeString1": ".1",
"shouldBeBoolean1": "false",
"shouldBeFragment1": {
"FshouldBeNumber1": "1",
"FshouldBeString1": "bar",
"FshouldBeBoolean1": "false"
}
}
get back this (you then copy into your files)
import DS from 'ember-data';
export default DS.Model.extend({
shouldBeNumber1: DS.attr("number"),
shouldBeString1: DS.attr("string"),
shouldBeBoolean1: DS.attr("boolean"),
shouldBeFragment1: DS.hasOneFragment("shouldBeFragment1")
});
export default DS.ModelFragment.extend({
FshouldBeNumber1: DS.attr("number"),
FshouldBeString1: DS.attr("string"),
FshouldBeBoolean1: DS.attr("boolean")
});
Will be adding to this add I find use cases.