Schemas¶
The library intends to deal with complex schemas, possibly using inheritance which is not yet supported in JSON Schema, as well as data types which can be useful in generated class.
For this purpose, a meta-schema is built on top of the standard ones, adding specific features, but which won’t be recognized by standard validators. Though, the schema valid against this meta-schema should usually be processed without problem by standard validation libraries (with warnings for the unknown field) with the exception.
- The additional grammar adds:
- extra object attributes:
isAbtractboolean to indicate an abstract class.extendsallowing to specify theidof parent classes.readOnlyandnotSerializedto specify properties which cannot beset or are not serialized.
extra literal types (
date,time,datetime,path,importable).- extra property attributes for specific types:
isPathDirboolean to indicate the path of a directoryisPathFileboolean to indicate the path of a fileisPathExistingboolean to indicate an existing pathforeignKeydictionary of options to define a foreign key to another object
It also comes with a few definitions that can be useful in a Domain-Driven Design implementation.
This meta-schema is available as https://numengo.org/ngoschema <https://numengo.org/ngoschema#
and can be optionally referred as $schema.
in the definitions (instead of the standard draft)
- Additional types are available for literals, and can then be used already properly casted in further code. Those types are mapped as follows:
date:datetime.datedatetime:datetime.datetimetime:datetime.timetime:datetime.timepath:pathlib.Path