You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2018. It is now read-only.
I have two experimental branches towards this effort:
Manually created API
Manually generated Python class structure based on schema and Java reference, using annotations/type hints for eventual type checking, but this doesn't seem very pythonic which embraces duck typing. If we were to pursue we would have to write a custom object_hook for json encode/decoding.
Testing JSON Packages
Unit tests to test functionality of jsonschema and python-jsonschema-objects with our schema and example files.
Jsonschema validates the omim and variant example, accurately fails on the journal example since we're using "human" instead of "patient." However, the patient example fails due to:
I assume this has to do with the lines
$ref: urn:jsonschema...
jsonschema attempts to resolve the url and fails.
Similarly, python-jsonschema-objects fails when loading the schema:
builder = jsonobjects.ObjectBuilder(self.schema)
Exception: urllib.error.URLError:
With the same issue (note we haven't even attempted to load an example file here).
I'm not familiar with JSONschema enough to know if the use of $ref and referring to an object within the schema is legal and this is a bug in these packages, or if we're using this incorrectly.
Update: this is fixed by changing $ref to id, or we could alternatively follow this pattern of internal referencing.
I've changed $ref to id in the schema for the sake of testing (on my branch). python-jsonschema-objects works reasonably well for both validation and mapping json to python objects and serializing back to json.
Activity
cmungall commentedon Mar 7, 2016
http://jsonmodels.readthedocs.org/en/latest/readme.html
allows you to go from an OM to JSONSchema - but not vice versa.
from 2012:
http://stackoverflow.com/questions/12465588/convert-a-json-schema-to-a-python-class
warlock or this: https://github.com/cwacek/python-jsonschema-objects
kshefchek commentedon Mar 17, 2016
I have two experimental branches towards this effort:
Manually generated Python class structure based on schema and Java reference, using annotations/type hints for eventual type checking, but this doesn't seem very pythonic which embraces duck typing. If we were to pursue we would have to write a custom object_hook for json encode/decoding.
Unit tests to test functionality of jsonschema and python-jsonschema-objects with our schema and example files.
Jsonschema validates the omim and variant example, accurately fails on the journal example since we're using "human" instead of "patient." However, the patient example fails due to:
KeyError: 'urn:jsonschema:org:monarchinitiative:ppk:model:condition:TemporalRegion'
urllib.error.URLError:
jsonschema.exceptions.RefResolutionError:
I assume this has to do with the lines
$ref: urn:jsonschema...
jsonschema attempts to resolve the url and fails.
Similarly, python-jsonschema-objects fails when loading the schema:
builder = jsonobjects.ObjectBuilder(self.schema)
Exception: urllib.error.URLError:
With the same issue (note we haven't even attempted to load an example file here).
I'm not familiar with JSONschema enough to know if the use of $ref and referring to an object within the schema is legal and this is a bug in these packages, or if we're using this incorrectly.
Update: this is fixed by changing $ref to id, or we could alternatively follow this pattern of internal referencing.
kshefchek commentedon Mar 19, 2016
I've changed $ref to id in the schema for the sake of testing (on my branch). python-jsonschema-objects works reasonably well for both validation and mapping json to python objects and serializing back to json.
See latest commit
Merge pull request #1 from harryhoch/test-schema-validators