{ "info": { "author": "Damien Lebrun", "author_email": "dinoboff@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 1 - Planning", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7" ], "description": "===================\nJSON-Schema builder\n===================\n\nHelpers to build you define JSON schema for either validation or publication.\n\nRequirements\n============\n\nIt requires Python 2.7 and ``jsonschema``. ``jsonschema`` or ``setuptools``\nshould be installed with Python.\n\n\nInstall\n=======\n\nUsing pip::\n\n pip install schemabuilder\n\nOr easy_install::\n\n easty_install schemabuilder\n\n\nYou may install it manually::\n\n git clone https://github.com/dinoboff/schemabuilder.git\n cd schemabuilder\n python setup.py install\n\n\nUsage\n=====\n\nPrimitives\n----------\n\nJSON schema primitives are represented by object of type:\n\n* ``schemabuilder.Str``\n* ``schemabuilder.Bool``\n* ``schemabuilder.Number``\n* ``schemabuilder.Int``\n* ``schemabuilder.Object``\n* ``schemabuilder.Array``\n\n\n.. code-block:: python\n\n >>> import schemabuilder as jsb\n >>> import pprint\n >>>\n >>> name = jsb.Str(pattern=\"^[a-zA-Z][- 'a-zA-Z0-9]+\")\n >>> email = jsb.Str(format=\"email\")\n >>> user = jsb.Object(properties={\n ... 'name': name(required=True),\n ... 'email': email(),\n ... 'home': jsb.Str(format='uri'),\n ... })\n >>> pprint.pprint(user.to_dict())\n {'properties': {'email': {'type': 'string'},\n 'home': {'format': 'uri', 'type': 'string'},\n 'name': {'type': 'string'}},\n 'required': ['name'],\n 'type': 'object'}\n\n\nSchema\n------\n\nSchema collects those definitions for validation (using ``jsonschema``) or\npublication.\n\n.. code-block:: python\n\n >>> import schemabuilder as jsb\n >>> import pprint\n >>>\n >>> my_schemas = jsb.Schema(id='http://example.com/schemas.json#')\n >>> name = my_schemas.define(\n ... 'name', jsb.Str(pattern=\"^[a-zA-Z][- 'a-zA-Z0-9]+\")\n ... )\n >>> email = my_schemas.define('email', jsb.Str(format=\"email\"))\n >>> user = my_schemas.define('user', jsb.Object(properties={\n ... 'name': name(required=True),\n ... 'email': email(required=True),\n ... }))\n >>>\n >>> user.validate({'name': 'bob'})\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"schemabuilder/schema.py\", line 50, in validate\n validator.validate(data)\n File \"/Users/bob/pyenv/lib/python2.7/site-packages/jsonschema/validators.py\", line 117, in validate\n raise error\n jsonschema.exceptions.ValidationError: 'email' is a required property\n \n Failed validating 'required' in schema:\n {'properties': {'email': {'$ref': '#/definitions/email'},\n 'name': {'$ref': '#/definitions/name'}},\n 'required': ['name', 'email'],\n 'type': 'object'}\n \n On instance:\n {'name': 'bob'}\n >>>\n >>> user.validate({'name': 'bob', 'email': 'bob@example.com'})\n >>>\n >>> import json\n >>> print json.dumps(my_schemas.to_dict(), indent=4)\n {\n \"definitions\": {\n \"email\": {\n \"type\": \"string\", \n \"format\": \"email\"\n }, \n \"user\": {\n \"required\": [\n \"name\", \n \"email\"\n ], \n \"type\": \"object\", \n \"properties\": {\n \"name\": {\n \"$ref\": \"#/definitions/name\"\n }, \n \"email\": {\n \"$ref\": \"#/definitions/email\"\n }\n }\n }, \n \"name\": {\n \"pattern\": \"^[a-zA-Z][- 'a-zA-Z0-9]+\", \n \"type\": \"string\"\n }\n }, \n \"id\": \"http://example.com/schemas.json#\", \n \"$schema\": \"http://json-schema.org/draft-04/schema#\"\n }\n\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dinoboff/schemabuilder", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "schemabuilder", "package_url": "https://pypi.org/project/schemabuilder/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/schemabuilder/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/dinoboff/schemabuilder" }, "release_url": "https://pypi.org/project/schemabuilder/0.3.0/", "requires_dist": null, "requires_python": null, "summary": "JSON schema definition helpers", "version": "0.3.0" }, "last_serial": 1372904, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "60832111249f35526c32ca5a9099aa8a", "sha256": "62d7b422b7f1a3fc30249188423777fcc4b7a864bcce1feeb5c6c1df59970d94" }, "downloads": -1, "filename": "schemabuilder-0.1.0.tar.gz", "has_sig": false, "md5_digest": "60832111249f35526c32ca5a9099aa8a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6798, "upload_time": "2014-09-11T02:06:10", "url": "https://files.pythonhosted.org/packages/10/5f/5059781a5e13c6310054e12db34844837976402fb72d4577217a9eb229aa/schemabuilder-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "d26e17eca39d7569cc97d16583cca348", "sha256": "a7bd5dc589d24f6a4520a3a7e14c4448870ac8b8cde0d7db7fd566c0a6d9cd8f" }, "downloads": -1, "filename": "schemabuilder-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d26e17eca39d7569cc97d16583cca348", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6908, "upload_time": "2015-01-05T13:36:19", "url": "https://files.pythonhosted.org/packages/5d/13/5f71858edba06bcf2d0db558e97fc7779237285ade7a35d4d9c580ccc5f4/schemabuilder-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "6101382b5f4994eb13023984b1574297", "sha256": "fb90b296d576bbe640a0c26165f39de0ecf0e5f20e1341c0b9cdb437bbb54d7e" }, "downloads": -1, "filename": "schemabuilder-0.2.0.tar.gz", "has_sig": false, "md5_digest": "6101382b5f4994eb13023984b1574297", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7060, "upload_time": "2015-01-05T14:30:23", "url": "https://files.pythonhosted.org/packages/05/57/b270a79b72fa421c1fe4ca83febb528b4885a939021289b9a98a54efaf76/schemabuilder-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "59c8205fe56eb97f5a2b936f0c635ed6", "sha256": "28793951df1fa291ace0587bfb462f91c2e50dcb13c2cce39dd34c0752f4e0a4" }, "downloads": -1, "filename": "schemabuilder-0.3.0.tar.gz", "has_sig": false, "md5_digest": "59c8205fe56eb97f5a2b936f0c635ed6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7095, "upload_time": "2015-01-06T16:07:52", "url": "https://files.pythonhosted.org/packages/c4/eb/342bed0f85beb0f9204a4d2a473238c15432ac3203b4bf34bda31dfd308d/schemabuilder-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "59c8205fe56eb97f5a2b936f0c635ed6", "sha256": "28793951df1fa291ace0587bfb462f91c2e50dcb13c2cce39dd34c0752f4e0a4" }, "downloads": -1, "filename": "schemabuilder-0.3.0.tar.gz", "has_sig": false, "md5_digest": "59c8205fe56eb97f5a2b936f0c635ed6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7095, "upload_time": "2015-01-06T16:07:52", "url": "https://files.pythonhosted.org/packages/c4/eb/342bed0f85beb0f9204a4d2a473238c15432ac3203b4bf34bda31dfd308d/schemabuilder-0.3.0.tar.gz" } ] }