Skip to content
This repository was archived by the owner on Sep 25, 2018. It is now read-only.
This repository was archived by the owner on Sep 25, 2018. It is now read-only.

Explore code generation options #1

Open

Description

@cmungall

Bindings can be made automatically based on schema def, depends on this ticket:

phenopackets/phenopacket-format#31

Activity

  1. cmungall commented on Mar 7, 2016

    @cmungall
    MemberAuthor
  2. kshefchek commented on Mar 17, 2016

    @kshefchek
    Contributor

    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:

    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.

  3. kshefchek commented on Mar 19, 2016

    @kshefchek
    Contributor

    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

  4. added a commit that references this issue on Jun 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions