{ "info": { "author": "Olist Developers", "author_email": "pactum@olist.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 1 - Planning", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Testing" ], "description": "# Pactum\n## The HTTP-API specification sketchbook for pythonistas\n\n[![Circle CI](https://circleci.com/gh/olist/pactum.svg?style=svg)](https://circleci.com/gh/olist/pactum)\n\n```shell\npip install pactum\n```\n\nWith `Pactum` you can **specify** HTTP-APIs using pure python.\n\nPactum is easy to use, easy to extend and easy to contribute:\n\n### Easy to use\n\nThe only requirements to start writing an API specification with `pactum`\nis `pactum` package itself and some knowledge of python.\n\n```python\nimport pactum\n\nclass MyAPI(pactum.API):\n name = 'My API'\n versions = [...]\n```\n\n### Easy to extend\n\nUsing the [visitor pattern](http://wiki.c2.com/?VisitorPattern) you can create\nexporters and extensions for any format or service you want.\n\nTake a look at [pactum/exporters/openapi.py](https://github.com/olist/pactum/blob/master/pactum/exporters/openapi.py).\n\n### Architecture\n\nAlways keep [this diagram](https://github.com/olist/pactum/wiki/Architecture-Diagram) in mind when defining your APIs.\n\n\n### Tutorial\n\nCreate a file called specs.py and start defining your API.\n\nYou can define a `Resource` object for your API.\n\n```python\nfrom pactum import Action, API, Resource, Response, Version\nfrom pactum import fields, verbs\n\nclass Order(Resource):\n fields = [\n fields.IntegerField(name='code', required=True),\n fields.TimestampField(name='created_at'),\n fields.StringField(name='item')\n ]\nresource = Order()\n\nerror_resource = Resource(\n name = 'ErrorResource'\n fields = [fields.StringField(name='error', required=False)]\n)\n```\nYou can define any element of your specification by calling it directly as in\n`error_resource` or by class definition as in `MyResource` and then calling it.\n\n\nList resources are definitions of lists of the same resource.\n```python\nlist_order_resource = ListResource(resource=resource)\n```\n\nYou can define `Response` objects with `status`, `description`(optional) a\n`header`(optional) and a `Resource`/`ListResource` object as `body` (optionally)...\n\n```python\nlist_response = Response(\n status=200, description='Here is your orders list.', body=list_resource\n)\n\ndetail_response = Response(\n status=200, description='Here is your order.', body=resource\n)\n\nerror_response = Response(status=404, resource=error_resource, headers=[('Content-type': 'application-json')])\n```\n\n... and `Request` objects with `verb`, `description`, `header`(optional) and a `Resource`/`ListResource`\nobject as `payload`.\n\n```python\nget_request = Request(verb=verbs.GET)\n```\n\nAn `Action` groups your request and a list of responses for a specified action passed in the description parameter.\n```python\nlist_action = Action(\n description='Returns a list of resources.',\n request=get_request,\n responses=[error_response, list_response]\n)\n\ndetail_action = Action(\n description='Returns a resource based on its code.',\n request=get_request,\n responses=[error_response, detail_response]\n)\n\n\n```\nThe Action object, as all other elements in Pactum, receive a description string\nthat sets the `.__doc__` attribute and can be the docstring of the class\nif the object is defined by class definition.\n\nA route can have a list of actions in an HTTP path.\n```python\nclass OrderListRoute(Route):\n path = '/orders'\n actions = [list_action]\n\nlist_route = OrderListRoute()\n\ndetail_route = OrderRoute(path='/orders/{code}', actions=detail_action)\n```\n\nYour routes can be grouped in API versions.\n```python\nclass V1(Version):\n name = 'V1'\n routes = [list_route, detail_route]\n\nv1 = V1()\n```\nThen you can define your API. ;)\n```python\nclass OrdersAPI(API):\n name = 'Orders API'\n versions = [v1]\n\napi = OrdersAPI()\n```\nBe happy and ready to export your specification to any format you want.\n\n# Exporting to openapi specs.\nPactum has a command that exports your specification to OpenAPI. You can call it by using:\n```\npactum-openapi [--format=]\n```\n\n\n# Road to version 1.\n- [ ] Test elements .accept(visitor) methods.\n- [ ] Support for version selectors (Versions should be specified on HTTP header, path, or custom fields)\n- [x] Stabilize the way we work with path parameters.\n- [ ] Support for Authorization and Authentication Specifications.\n- [ ] Support for extensions.\n- [ ] Behaviors", "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/olist/pactum", "keywords": "", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "pactum", "package_url": "https://pypi.org/project/pactum/", "platform": "", "project_url": "https://pypi.org/project/pactum/", "project_urls": { "Homepage": "https://github.com/olist/pactum" }, "release_url": "https://pypi.org/project/pactum/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "Create API specifications and documentation using Python", "version": "0.2.0" }, "last_serial": 4653362, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "4d309305f48a3b66bdc8b3f1412c0fa5", "sha256": "b1bb8c8699f85f70dbb97a15b90c550bf64aa5492b1a99e7e3654451dc76b596" }, "downloads": -1, "filename": "pactum-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4d309305f48a3b66bdc8b3f1412c0fa5", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4268, "upload_time": "2017-08-29T04:55:08", "url": "https://files.pythonhosted.org/packages/76/ae/722ed147652494dec29e4f2c2b730dcb97555d410a091d9a2410b0efe9d9/pactum-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8a29219d00c95f2654bc6218518b9688", "sha256": "1e5e46fdf2fffd7a9aa1547abb8420ef62dc6201c883fc5a197c46fb4dddd658" }, "downloads": -1, "filename": "pactum-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8a29219d00c95f2654bc6218518b9688", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2731, "upload_time": "2017-08-29T04:55:10", "url": "https://files.pythonhosted.org/packages/a8/1d/94238cdbe0325966c0d8db0629d2ec4710d95c9aab45bf1862021ed89042/pactum-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "9036298180b539688b4fb0d35ddebb29", "sha256": "e039bcadf44e0f1fe8d3d6ba8f6d74ec9331b9ab575308dae8a0491ca72dad17" }, "downloads": -1, "filename": "pactum-0.1.0.tar.gz", "has_sig": false, "md5_digest": "9036298180b539688b4fb0d35ddebb29", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14236, "upload_time": "2018-11-27T11:13:55", "url": "https://files.pythonhosted.org/packages/5f/cd/61a389467ef8327b66283136ba46b505f49d0a329515aa5651c547890194/pactum-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "2273ce7872cb909a39f86d105c460710", "sha256": "efefe324b63e4323811c475d07583f9e8e853d9fa5e7c60e2fc9d40719ac6e90" }, "downloads": -1, "filename": "pactum-0.1.1.tar.gz", "has_sig": false, "md5_digest": "2273ce7872cb909a39f86d105c460710", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14273, "upload_time": "2018-11-28T11:25:12", "url": "https://files.pythonhosted.org/packages/09/82/3b8af5cd0a34b45d60b212c7976294112b52f8dfc7a7b2a3269ac253952d/pactum-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "8dd09ed0845b0686ae8da6393cb91f3b", "sha256": "ff930010fe6abca237ec924297f28a719564e6356c2d6f0b882bb44b5917e89e" }, "downloads": -1, "filename": "pactum-0.2.0.tar.gz", "has_sig": false, "md5_digest": "8dd09ed0845b0686ae8da6393cb91f3b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16045, "upload_time": "2019-01-02T16:43:51", "url": "https://files.pythonhosted.org/packages/ef/86/1f21a7429b40ac83e6c32980cdb406ea2a27f185a7d314084cf93d70bb24/pactum-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8dd09ed0845b0686ae8da6393cb91f3b", "sha256": "ff930010fe6abca237ec924297f28a719564e6356c2d6f0b882bb44b5917e89e" }, "downloads": -1, "filename": "pactum-0.2.0.tar.gz", "has_sig": false, "md5_digest": "8dd09ed0845b0686ae8da6393cb91f3b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16045, "upload_time": "2019-01-02T16:43:51", "url": "https://files.pythonhosted.org/packages/ef/86/1f21a7429b40ac83e6c32980cdb406ea2a27f185a7d314084cf93d70bb24/pactum-0.2.0.tar.gz" } ] }