{ "info": { "author": "Ivan Korobkov", "author_email": "ivan.korobkov@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Compilers" ], "description": "Pdef - Interface definition language for the web\n================================================\nPdef (pi:def, stands for \"protocol definition [language]\") is a statically typed interface\ndefinition language which supports JSON and a simple HTTP RPC. It allows to write\ninterfaces and data structures once and then to generate code and RPC clients/servers for\ndifferent languages. It is suitable for public APIs, internal service-oriented APIs,\nconfiguration files, as a format for persistence, cache, message queues, logs, etc.\nFeatures:\n\n- Packages, modules, imports and namespaces.\n- Circular module imports and type references (with some limitations).\n- Simple type system built on a clear separation between data structures and interfaces.\n- Message and interface inheritance.\n- Chained method invocations.\n- Default JSON format and HTTP RPC.\n- Pluggable loosely-coupled formats and RPCs.\n- Pluggable code generators.\n\n\nLanguages\n---------\n- [Java](https://github.com/pdef/pdef-java)\n- [Python](https://github.com/pdef/pdef-python)\n- [Objective-C](https://github.com/pdef/pdef-objc)\n\n\nLinks\n-----\n- **[Language guide](docs/language-guide.md)**\n- [Style guide](docs/style-guide.md)\n- [JSON format](docs/json-format.md)\n- [HTTP RPC](docs/http-rpc.md)\n- [Grammar in BNF](docs/grammar.bnf)\n- [Generated and language specific code](docs/generated-lang-specific-code.md)\n- [How to write a code generator](https://github.com/pdef/pdef-generator-template)\n- [Google group](https://groups.google.com/d/forum/pdef) (pdef@googlegroups.com)\n\n\nRequirements\n------------\n- The compiler requires Python 2.7 or Python 3.3.\n- Bindings requirements are language specific.\n\n\nInstallation\n------------\nPdef consists of a compiler, pluggable code generators, and language-specific bindings.\n\nInstall the compiler as a python package:\n```bash\n$ pip install pdef-compiler\n```\n\nOr [download](https://github.com/pdef/pdef/releases) the archive, unzip it and run:\n```bash\n$ python setup.py install\n```\n\nInstall the code generators:\n```bash\n$ pip install pdef-java\n$ pip install pdef-python\n$ pip install pdef-objc\n```\n\nRun the check command with test package to check that the compiler works:\n```bash\n$ pdefc check https://raw.github.com/pdef/pdef/master/example/world.yaml\n```\n\n\nGetting Started\n---------------\nCreate a package file `myproject.yaml`\n```yaml\npackage:\n name: myproject\n modules:\n - posts\n - photos\n```\n\nCreate the module files:\n\n`posts.pdef`\n```pdef\nnamespace myproject;\nimport myproject.photos;\n\ninterface Posts {\n get(id int64) Post;\n\n @post\n create(title string, text string) Post;\n}\n\nmessage Post {\n id int64;\n title string;\n text string;\n photos list;\n}\n```\n\n`photos.pdef`\n```pdef\nnamespace myproject;\n\nmessage Photo {\n id int64;\n url string;\n}\n```\n\nGenerate the source code:\n```bash\n$ pdefc generate-java myproject.yaml --out generated/\n$ pdefc generate-objc myproject.yaml --out generated/\n$ pdefc generate-python myproject.yaml --out generated/\n```\n\nExample\n-------\nExample package [sources](https://github.com/pdef/pdef/tree/master/example/).\n\nInterfaces:\n```pdef\nnamespace world;\nfrom world import continents, space; // Import two modules from a package.\n\n/**\n * The world interface.\n * A god-like person can use it to rule the world.\n */\ninterface World {\n /** Returns the humans interface. */\n humans() Humans; // Returns another interface.\n\n /** Returns the continents interface. */\n continents() Continents; // Returns an interface from another module.\n\n /** Switches the light. */\n switchDayNight() void;\n\n /** Returns the last world events, the events are polymorphic. */\n events(limit int32, offset int64) list;\n}\n\ninterface Humans {\n /** Finds a human by id. */\n find(id int64) Human;\n\n /** Lists all people. */\n all(limit int32, offset int32) list;\n\n /** Creates a human. */\n @post // A post method (a mutator).\n create(human Human) Human;\n}\n```\n\nEnums:\n```pdef\nenum Sex {\n MALE, FEMALE, UNCLEAR;\n}\n\n// An discriminator.\nenum EventType {\n HUMAN_EVENT,\n HUMAN_CREATED,\n HUMAN_DIED;\n}\n```\n\nMessages:\n```pdef\nmessage Thing { // A simple message definition.\n id int64; // an id field of the int64 type.\n location Location;\n}\n\n/** Human is a primate of the family Hominidae, and the only extant species of the genus Homo. */\nmessage Human : Thing { // A message with a base message and a docstring.\n name string;\n birthday datetime;\n sex Sex;\n continent Continent;\n}\n```\n\nPolymorphic inheritance:\n```pdef\n// A polymorphic message with EventType as its discriminator.\nmessage Event {\n type EventType @discriminator;\n id int32;\n time datetime;\n}\n\n// A polymorphic subtype.\nmessage HumanEvent : Event(EventType.HUMAN_EVENT) {\n human Human;\n}\n\n// Multi-level polymorphic messages.\nmessage HumanCreated : HumanEvent(EventType.HUMAN_CREATED) {}\nmessage HumanDied : HumanEvent(EventType.HUMAN_DIED) {}\n```\n\n### Curl\nPdef uses an [HTTP RPC](docs/http-rpc.md) with a [JSON format](docs/json-format.md)\nwhich are easy to use without specially generated clients. These are examples,\nthere is no real server.\n\nCreate a new human:\n```bash\n$ curl -d human=\"{\\\"id\\\": 1, \\\"name\\\":\\\"John\\\"}\" http://example.com/world/humans/create\n{\n \"data\": {\n \"id\": 1,\n \"name\": \"John\"\n }\n}\n```\n\nSwitch the light:\n```bash\n$ curl -X POST http://example.com/world/switchTheLight\n{\n \"data\": null\n}\n```\n\nList people:\n```bash\n$ curl \"http://example.com/world/humans/all?limit=2&offset=10\"\n{\n \"data\": [\n {\"id\": 11, \"name\": \"John\"},\n {\"id\": 12, \"name\": \"Jane\"}\n ]\n}\n```\n\n\nLicense and Copyright\n---------------------\nCopyright: 2013 Ivan Korobkov \n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/pdef/pdef", "keywords": null, "license": "Apache License 2.0", "maintainer": null, "maintainer_email": null, "name": "pdef-compiler", "package_url": "https://pypi.org/project/pdef-compiler/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pdef-compiler/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/pdef/pdef" }, "release_url": "https://pypi.org/project/pdef-compiler/1.2.2/", "requires_dist": null, "requires_python": null, "summary": "Pdef compiler", "version": "1.2.2" }, "last_serial": 1001968, "releases": { "1.0-beta5": [], "1.0-beta6": [ { "comment_text": "", "digests": { "md5": "433e3686a62f3ed36e7c56522b73f4d3", "sha256": "d61ec98a982aa5ba2b13ebc16c0522d9bcc2847efeb13dadd4ecd294fdfd6b9a" }, "downloads": -1, "filename": "pdef-compiler-1.0-beta6.tar.gz", "has_sig": false, "md5_digest": "433e3686a62f3ed36e7c56522b73f4d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29452, "upload_time": "2013-12-01T18:32:49", "url": "https://files.pythonhosted.org/packages/c7/0c/72475e360e4921884a6e306a33e0e27c0c8da6fbcc4efcbd1b770875bca3/pdef-compiler-1.0-beta6.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "49d0a48825136eddf1702efb7e43544e", "sha256": "a1fb85adb4d59958ce2171d8bf0226b6be1dc4e6915958061647cd57bf1a7326" }, "downloads": -1, "filename": "pdef-compiler-1.0.0.tar.gz", "has_sig": false, "md5_digest": "49d0a48825136eddf1702efb7e43544e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29726, "upload_time": "2013-12-03T17:16:33", "url": "https://files.pythonhosted.org/packages/a6/e2/be51fc6d1e83a9339bb2e9d9324028fd030b195364aa8cc51999e16b8d84/pdef-compiler-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "8ba308b8aeaa509a4bec48fe75f088e6", "sha256": "c3d41ab7382b3c05b9301dfc7325202ebea084fb155f4af398698779af898489" }, "downloads": -1, "filename": "pdef-compiler-1.0.1.tar.gz", "has_sig": false, "md5_digest": "8ba308b8aeaa509a4bec48fe75f088e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29754, "upload_time": "2013-12-18T13:16:00", "url": "https://files.pythonhosted.org/packages/12/20/e2677edcd6f9f678c92ab308a925cb74313f4f7d5efcb81b9552298c3740/pdef-compiler-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "ece4038ac05e4fb9a3a9b78cb98a4ebc", "sha256": "4d22f53cc1a535b71a94f75b0c0b303a886bc839880f4e09aff5ad550b9ab368" }, "downloads": -1, "filename": "pdef-compiler-1.1.0.tar.gz", "has_sig": false, "md5_digest": "ece4038ac05e4fb9a3a9b78cb98a4ebc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28218, "upload_time": "2013-12-22T16:06:56", "url": "https://files.pythonhosted.org/packages/e1/c2/fb0f975e91a8b1aa2b1ad685cd4ffc218fed00625fe695c9d12b15bd8ece/pdef-compiler-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "79390235d0934fccac9898bf0c3b4b6f", "sha256": "08a8d2c22a0d51b25388291df41b0162722ecd3abd8ddca691d2e6c5967b59d5" }, "downloads": -1, "filename": "pdef-compiler-1.1.1.tar.gz", "has_sig": false, "md5_digest": "79390235d0934fccac9898bf0c3b4b6f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28486, "upload_time": "2014-01-14T11:26:53", "url": "https://files.pythonhosted.org/packages/51/1b/a41e0a47e97bba973072cafdce5e50650e8983b9d4e32833e40860ecfe37/pdef-compiler-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "be1c81f07db99f19eef35951f8b45d4c", "sha256": "7c02995dc9396c8e25620b4c7d40e3c6763cd7133543dca3e5110d26880a616e" }, "downloads": -1, "filename": "pdef-compiler-1.1.2.tar.gz", "has_sig": false, "md5_digest": "be1c81f07db99f19eef35951f8b45d4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28661, "upload_time": "2014-01-15T09:21:44", "url": "https://files.pythonhosted.org/packages/97/b9/4a95a645902d514d513cd3f5c798b583c25f8d47f45c70babcff0af9fdc3/pdef-compiler-1.1.2.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "d4eff4793cfd237056a91c7dc5fcbb9e", "sha256": "47fd951e4229cb4529fee2e427e4b50b5f79aa058ed4fefd516c07fbae8f71a5" }, "downloads": -1, "filename": "pdef-compiler-1.2.0.tar.gz", "has_sig": false, "md5_digest": "d4eff4793cfd237056a91c7dc5fcbb9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28681, "upload_time": "2014-02-11T10:26:29", "url": "https://files.pythonhosted.org/packages/3a/2e/700de84fa8fc99dabe317c60a56d7275d6b3a74bb529d1ec165a818d3656/pdef-compiler-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "a021686b1aa587bca5ce211380d61a55", "sha256": "9cc44781fbe62512573e3f58322b5367d118996632c83183018bccac00be167b" }, "downloads": -1, "filename": "pdef-compiler-1.2.1.tar.gz", "has_sig": false, "md5_digest": "a021686b1aa587bca5ce211380d61a55", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28800, "upload_time": "2014-02-17T09:33:35", "url": "https://files.pythonhosted.org/packages/ba/70/839729f95123388e62675cf665780243dc4da0c1cf7ff08110a5dea5eb33/pdef-compiler-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "d14b79135e3a0c293e0e318abe66fe8c", "sha256": "e7427063ad4f747fc97c6279c7d1dc31fb24f89780762727f277d050657f94e1" }, "downloads": -1, "filename": "pdef-compiler-1.2.2.tar.gz", "has_sig": false, "md5_digest": "d14b79135e3a0c293e0e318abe66fe8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28855, "upload_time": "2014-02-17T09:39:23", "url": "https://files.pythonhosted.org/packages/66/26/f46094702b12fde8fdc914e69f1011e071f3dd7dc3797ee3a2baa9d30df2/pdef-compiler-1.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d14b79135e3a0c293e0e318abe66fe8c", "sha256": "e7427063ad4f747fc97c6279c7d1dc31fb24f89780762727f277d050657f94e1" }, "downloads": -1, "filename": "pdef-compiler-1.2.2.tar.gz", "has_sig": false, "md5_digest": "d14b79135e3a0c293e0e318abe66fe8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28855, "upload_time": "2014-02-17T09:39:23", "url": "https://files.pythonhosted.org/packages/66/26/f46094702b12fde8fdc914e69f1011e071f3dd7dc3797ee3a2baa9d30df2/pdef-compiler-1.2.2.tar.gz" } ] }