create efficent models starting from json schema
Project description
Usage
With the schema in types/schema.yaml
$schema: http://json-schema.org/schema#
properties:
name:
type: string
surname:
type: string
age:
type: integer
required:
- name
- surname
- age
you can load a model with automatic validation and efficent use of __slots__
import yaml
import modeler
schema = yaml.load(open('types/schema.yaml').read())
Model = modeler.make_model(schema=schema,)
Model(name='Tommaso', surname='De Rossi', age=19)
Details
Model validate itself as soon as instantiated, if you want to change this behavior overwrite _on_init
method.
Model will return None if you try to access a property present in the json schema .properties
but not in the object.
Model will throw if you try to access a property not present in the object and not in the json schema .properties
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
modeller-0.0.19.tar.gz
(4.9 kB
view hashes)
Built Distribution
Close
Hashes for modeller-0.0.19-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aaae894ec9f351ac8f8c5877ba74b6cf9dadde4697dbfcd771e6756359d3afd |
|
MD5 | adb1e8e4cc58550e19088a99272178ab |
|
BLAKE2b-256 | 535fa47042d543e3f7b0a883b2239d9c40813e115b71fd426b442b9eddb40850 |