{ "info": { "author": "Daniele Esposti", "author_email": "daniele.esposti@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "[![Build Status](https://travis-ci.org/expobrain/json-schema-codegen.svg?branch=master)](https://travis-ci.org/expobrain/json-schema-codegen)\n\n# json-schema-codegen\n\nGenerate code from JSON schema files.\n\n# Table of contents\n\n- [Introduction](#introduction)\n- [Currently supported languages](#currently-supported-languages)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Code generation](#code-generation)\n - [Python2](#python-2)\n - [Python3](#python-3)\n - [Python3+Marshmallow](#python-3marshmallow)\n - [JavaScript+Flow and Flow](#javascriptflow-and-flow)\n- [Contribute](#contribute)\n\n# Introduction\n\nThis is a command line tool to take a [json-schema](http://json-schema.org/) file and generate code automatically.\n\nFor instance this `json-schema` definition:\n\n```json\n{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"title\": \"Test\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"integer\" }\n }\n}\n```\n\nwill generate this Python code:\n\n```python\nclass Test(object):\n def __init__(self, data=None):\n data = data or {}\n\n self.id = data.get(\"id\")\n```\n\nor this JavaScript+Flow code:\n\n```javascript\nexport class Test {\n id: ?number;\n\n constructor(data: Object = {}) {\n this.id = data.id;\n }\n}\n```\n\nCurrently this tool generates code for Python and JavaScript with [Flow](https://flow.org/) annotations but it can be extended to generate code for any language.\n\nThe code generation is divided in two stages:\n\n1. generate the [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) for the target language from the `json-schema` file\n1. convert the AST into the target language\n\nThis allows the tool to be language agnostic, that is it just needs to generate the AST in JSON format for the target language and then a language specific tool will convert this AST into proper code.\n\n# Currently supported languages\n\nList of currently supported languages:\n\n- Python 2.7+\n- JavaScript ES7+ with Flow annotations\n- pure Flow annotations\n\n# Requirements\n\n- Python 3.x\n- Node v8.4+\n\n# Installation\n\nUntil this [pull request](https://github.com/pypa/setuptools/pull/1389) in [`setuptools`](https://pypi.org/project/setuptools/) is fixed, the only way to install `json-schema-codegen` is to clone the repo:\n\n```shell\ngit clone https://github.com/expobrain/json-schema-codegen.git\n```\n\n# Usage\n\n```shell\nusage: json_codegen.py [-h] [--prefix PREFIX] [--language LANGUAGE]\n [--output OUTPUT]\n schema\n\npositional arguments:\n schema Definition of the PRD as JSON schema\n\noptional arguments:\n -h, --help show this help message and exit\n --prefix PREFIX, -p PREFIX\n Optional prefix for generated classes\n --language LANGUAGE, -l LANGUAGE\n Output language. Default is python\n --output OUTPUT, -o OUTPUT\n Output filename for the generated code\n```\n\n# Code generation\n\n## Python 2\n\nThe generation of Python's code is integrated into the tool so it needs just a single invocation:\n\n```shell\njson_codegen --language python --output \n```\n\n## Python 3\n\nThe egenerator of pure Python 3 compatible code:\n\n```shell\njson_codegen --language python3 --output \n```\n\n## Python 3+Marshmallow\n\nThe generation of Python 3's code with [Marshmallow](https://marshmallow.readthedocs.io/en/2.x-line/) support is integrated into the tool so it needs just a single invocation:\n\n```shell\njson_codegen --language python3+marshmallow --output \n```\n\n## JavaScript+Flow and Flow\n\nGenerating JavaScript+Flow and Flow code involves two steps, generating the AST:\n\n```shell\njson_codegen --language [javascript+flow|flow] --output \n```\n\nand generating the code from the AST:\n\n```shell\nbin/ast_to_js \n```\n\n# Contribute\n\nClone the repository, install packages and setup git hooks:\n\n```shell\ngit clone https://github.com/expobrain/json-schema-codegen\npip install -r requirements_dev.txt\nyarn install\ngit config core.hooksPath .githooks\n```\n\n\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/expobrain/json-schema-codegen", "keywords": "python javascript json-schema codegen", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "json-codegen", "package_url": "https://pypi.org/project/json-codegen/", "platform": "", "project_url": "https://pypi.org/project/json-codegen/", "project_urls": { "Homepage": "https://github.com/expobrain/json-schema-codegen" }, "release_url": "https://pypi.org/project/json-codegen/0.4.5/", "requires_dist": [ "astor (>=0.7.1)", "setuptools (>=40.1.0)" ], "requires_python": ">=3", "summary": "", "version": "0.4.5" }, "last_serial": 4930028, "releases": { "0.3.1": [ { "comment_text": "", "digests": { "md5": "687cfd033e68baea5be7dbd296f5a9ea", "sha256": "6482a2f45ea617025262237faff2a4ec00a7ce4977f4a41dee5c2a3bc6343607" }, "downloads": -1, "filename": "json_codegen-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "687cfd033e68baea5be7dbd296f5a9ea", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 149012, "upload_time": "2019-03-01T12:13:20", "url": "https://files.pythonhosted.org/packages/e6/55/ae382c8aab4021a89aaaa5406ab3a1aaf31278a4b538ad2e452a398ea024/json_codegen-0.3.1-py3-none-any.whl" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "cc55b8feb6f8e1c851bb076eb827a878", "sha256": "6d58b53e68178f3fcf1124fc819a71743d69d5407ab9bfd8572ec7fd18c759ea" }, "downloads": -1, "filename": "json_codegen-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "cc55b8feb6f8e1c851bb076eb827a878", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 149719, "upload_time": "2019-03-04T21:55:34", "url": "https://files.pythonhosted.org/packages/79/e1/401c4d56b86d87b0799f0b49c8a0101acf2f3f6fa50fcdec8d54b98b9e3f/json_codegen-0.4.0-py3-none-any.whl" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "b34e82f9b179fac7a002bc51ec57850f", "sha256": "d297398ae091d1860b3e291ed82a80f6db248937e1645d3822012d3267b53560" }, "downloads": -1, "filename": "json_codegen-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b34e82f9b179fac7a002bc51ec57850f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 139374, "upload_time": "2019-03-05T00:57:59", "url": "https://files.pythonhosted.org/packages/1a/89/d5a7acc7dc545f60bd62a0fb0fb41bb6ad6fc3666205a1c919d9721d1541/json_codegen-0.4.1-py3-none-any.whl" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "b76e8a4fd94de14720c7165fbbe934aa", "sha256": "690cb23510546ce8ca21251dae050dba1bd7962201fde9ee31b28d0cecb5d2a3" }, "downloads": -1, "filename": "json_codegen-0.4.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b76e8a4fd94de14720c7165fbbe934aa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 139566, "upload_time": "2019-03-05T10:01:17", "url": "https://files.pythonhosted.org/packages/f6/b9/17bd912abfed0e5951d0096ccb6ee8f2e335e2706e2ab70cf74f1185a647/json_codegen-0.4.2-py3-none-any.whl" } ], "0.4.3.1": [ { "comment_text": "", "digests": { "md5": "040988613a54cc73be8abab2062041c3", "sha256": "afa92e0c9c983c103640428aad9df79fb4daa9c74f6b4031ec201f6d908c14fe" }, "downloads": -1, "filename": "json_codegen-0.4.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "040988613a54cc73be8abab2062041c3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 139923, "upload_time": "2019-03-05T22:39:16", "url": "https://files.pythonhosted.org/packages/98/df/61e54324913d50e89f5d6894b4c12f94e0743a22905de094f433b89ee9e1/json_codegen-0.4.3.1-py3-none-any.whl" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "40619c0555c84b4895e89c99d38e7af5", "sha256": "bb80bde48bd9e05942b1f957e355421b14a0ab812d7ce814f17b05bf87058aa4" }, "downloads": -1, "filename": "json_codegen-0.4.4-py3-none-any.whl", "has_sig": false, "md5_digest": "40619c0555c84b4895e89c99d38e7af5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 139886, "upload_time": "2019-03-06T14:01:12", "url": "https://files.pythonhosted.org/packages/ec/dc/ffb5f1ba58c7104626645a1a3e6f255bd3183c9b53c99802745aa2232200/json_codegen-0.4.4-py3-none-any.whl" } ], "0.4.5": [ { "comment_text": "", "digests": { "md5": "d80a63fcfe75c863e31e25a226720ecb", "sha256": "4d15ed20774eef04b70533870e8902a87224ea454718e72f29513ced546f8df5" }, "downloads": -1, "filename": "json_codegen-0.4.5-py3-none-any.whl", "has_sig": false, "md5_digest": "d80a63fcfe75c863e31e25a226720ecb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 140214, "upload_time": "2019-03-12T12:56:27", "url": "https://files.pythonhosted.org/packages/af/50/c588cd64a29b8d2e8070965e52e7439c90fde665be72711e1f8551801ee6/json_codegen-0.4.5-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d80a63fcfe75c863e31e25a226720ecb", "sha256": "4d15ed20774eef04b70533870e8902a87224ea454718e72f29513ced546f8df5" }, "downloads": -1, "filename": "json_codegen-0.4.5-py3-none-any.whl", "has_sig": false, "md5_digest": "d80a63fcfe75c863e31e25a226720ecb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 140214, "upload_time": "2019-03-12T12:56:27", "url": "https://files.pythonhosted.org/packages/af/50/c588cd64a29b8d2e8070965e52e7439c90fde665be72711e1f8551801ee6/json_codegen-0.4.5-py3-none-any.whl" } ] }