{ "info": { "author": "Jacopo De Luca", "author_email": "jacopo.delu@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3" ], "description": "# JSchema2py #\nJSchema2py is able to generate python classes starting from JSONSchema and provides the automatic support for types\nand constraints checking.\n\n## Installation\nThe package can be installed through pip:\n\n $ pip install jschema2py\n\nor downloaded from [GitHub](https://github.com/jacopodl/jschema2py).\n\n## Examples\nFor example, given the following schema:\n```json\n{\n \"title\": \"UserInfo\",\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"pattern\": \"^[^a-z0-9]\"\n },\n \"userName\": {\n \"type\": \"string\"\n },\n \"age\": {\n \"type\": \"integer\",\n \"minimum\": 0,\n \"maximum\": 100\n }\n }\n}\n```\njschema2py can easily convert it into python class in this way (Assume here that the schema is stored into variable \ncalled schema):\n```python\nfrom jschema2py import build_class\nUserInfo = build_class(schema)\nuser = UserInfo()\nuser.name = \"Jacopo\"\nuser.userName = \"JDL\"\nuser.age = 24\nprint(user)\n```\nvalidation will be performed on the object manipulation:\n```python\nuser.name = \"jacopo\" # raise ConstraintError (pattern: ^[^a-z0-9])\nuser.age = \"24\" # raise TypeError\n```\nThe object can be serialized into a JSON document:\n```python\njsdoc = str(user)\n```\n### Accessing generated classes\nIf one of the property of the schema refers to another object, you can access the class that represents the referred \nobject by using method get_class:\n```json\n{\n \"title\": \"Nested\",\n \"type\": \"object\",\n \"properties\": {\n \"inner\": {\n \"title\": \"Inner\",\n \"type\": \"object\",\n \"properties\": {\n \"string\": {\n \"type\": \"string\",\n \"default\": \"I'm inner!\"\n }\n }\n }\n }\n}\n```\n```python\nfrom jschema2py import build_class\nNested = build_class(schema)\nnested = Nested()\nnested.inner = nested.get_class(\"inner\")() # Gets the class associated with the property \"inner\" \nprint(nested.inner.string)\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jacopodl/jschema2py", "keywords": "jschema2py,json,schema,jsonschema,library,python3", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "jschema2py", "package_url": "https://pypi.org/project/jschema2py/", "platform": "", "project_url": "https://pypi.org/project/jschema2py/", "project_urls": { "Homepage": "https://github.com/jacopodl/jschema2py" }, "release_url": "https://pypi.org/project/jschema2py/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "jsonschema to python class converter", "version": "0.1.0" }, "last_serial": 4061160, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "388fe423bf7f55bf88b29b8bc9b2ff59", "sha256": "859f9720bf11024d3fe30e736bf38487616627a7a98d4ca4f6591d0221728302" }, "downloads": -1, "filename": "jschema2py-0.1.0.tar.gz", "has_sig": false, "md5_digest": "388fe423bf7f55bf88b29b8bc9b2ff59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6249, "upload_time": "2018-07-14T12:57:32", "url": "https://files.pythonhosted.org/packages/86/63/0b291fc527149cf4c67d16074aa5d4e422b010f62542e095be2376473f20/jschema2py-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "388fe423bf7f55bf88b29b8bc9b2ff59", "sha256": "859f9720bf11024d3fe30e736bf38487616627a7a98d4ca4f6591d0221728302" }, "downloads": -1, "filename": "jschema2py-0.1.0.tar.gz", "has_sig": false, "md5_digest": "388fe423bf7f55bf88b29b8bc9b2ff59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6249, "upload_time": "2018-07-14T12:57:32", "url": "https://files.pythonhosted.org/packages/86/63/0b291fc527149cf4c67d16074aa5d4e422b010f62542e095be2376473f20/jschema2py-0.1.0.tar.gz" } ] }