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.26.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for modeller-0.0.26-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13e0a649fff57e5e9cd0effabbbe95bcfdf98d2f0b12407f08fe540b9b85374c |
|
MD5 | 6813e082f1006ed9afbc5e99807a52af |
|
BLAKE2b-256 | 3f215a43d5e9d11bf1ffbdf6bc016380175c5af5b19f3c0106fe68497bfb0997 |