While there are plans to support JSON Schema and some other formats so we are not reinventing the wheel and provide yet another format to learn for model definitions. For those who prefer, there is this format which some might find more intuitive to write.
This is still a work in progress but it is slowly taking shape.
In this document we use YAML to describe the format but you can use any data container.
Every module consists of fields and models. Fields are parsed before models regardless of the order of fields in the module descriptor file.
Every field can either be an alias to another field (string) or define a Field structure (object).
Models are defined in a somewhat similar format. Each model can define fields
which is an object whose keys become field names and values become field descriptors. Either directly referring to a defined field by its name in the module or making an anonymous field in-place.
As seen in the example above, you can refer to already defined fields like username
key that uses DifferentName
defined earlier in the file. If you end the field name by ?
it makes that field optional.
Alternatively, you can define an anonymous field.
NOTE Every module has string, integer, double, bool, list, object and null as fields by default.
Every model defined in the module automatically creates a field by the same name as the model.
It is possible to use a field even prior to its definition so long as it gets defined somewhere in the module.
For example, we can improve the previous example by the following definition:
This is the same for aliases, you can make a field alias for a field that is not defined yet.
Models can inherit from one another. You can either inherit from one model or a series of models.
You may exclude some fields from getting inherited.
If a model defines a field, that will override the inheritance.