{ "info": { "author": "Nicola Iarocci", "author_email": "nicola@nicolaiarocci.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "Eve-Swagger |latest-version|\n============================\n\n|build-status| |python-support|\n\nSwagger_ extension for Eve_ powered RESTful APIs.\n\nUsage\n-----\n.. code-block:: python\n\n from eve import Eve\n from eve_swagger import swagger, add_documentation\n\n app = Eve()\n app.register_blueprint(swagger)\n\n # required. See http://swagger.io/specification/#infoObject for details.\n app.config['SWAGGER_INFO'] = {\n 'title': 'My Supercool API',\n 'version': '1.0',\n 'description': 'an API description',\n 'termsOfService': 'my terms of service',\n 'contact': {\n 'name': 'nicola',\n 'url': 'http://nicolaiarocci.com'\n },\n 'license': {\n 'name': 'BSD',\n 'url': 'https://github.com/pyeve/eve-swagger/blob/master/LICENSE',\n },\n 'schemes': ['http', 'https'],\n }\n\n # optional. Will use flask.request.host if missing.\n app.config['SWAGGER_HOST'] = 'myhost.com'\n\n # optional. Add/Update elements in the documentation at run-time without deleting subtrees.\n add_documentation({'paths': {'/status': {'get': {'parameters': [\n {\n 'in': 'query',\n 'name': 'foobar',\n 'required': False,\n 'description': 'special query parameter',\n 'type': 'string'\n }]\n }}}})\n\n if __name__ == '__main__':\n app.run()\n\nWhen the API is up and running, visit the ``/api-docs`` endpoint. The resulting\nJSON can then be used with swagger tooling, like the Swagger UI or Swagger Editor:\n\n.. image:: resources/swagger_editor.png\n\nIf you get the error \"*Can't read from server. It may not have the appropriate\naccess-control-origin settings*\" from Swagger UI, you might want to enable CORS\nsupport with the ``X_DOMAINS`` and ``X_HEADERS`` configuration in your Eve\n``settings.py``:\n\n.. code-block:: python\n\n X_DOMAINS = ['http://localhost:8000', # The domain where Swagger UI is running\n 'http://editor.swagger.io',\n 'http://petstore.swagger.io']\n X_HEADERS = ['Content-Type', 'If-Match'] # Needed for the \"Try it out\" buttons\n\nFor more information check the CORS documentation of `Swagger UI`_ and `Swagger\nEditor`_.\n\nInstallation\n------------\n.. code-block::\n\n $ pip install eve-swagger\n\n\nDescription fields on the swagger docs\n--------------------------------------\n\nIf you would like to include description fields to your swagger docs you can\ninclude a description field in your schema validations in your ``settings.py``.\nThis can be done per field as well as on the resource-level.\n\nAs an example:\n\n.. code-block:: python\n\n ...\n 'description': 'Description of the user resource',\n 'schema': {\n 'userName': {\n 'description': 'The username of the logged in user.',\n 'type': 'string',\n 'minlength': 1,\n 'maxlength': 256,\n 'required': True\n },\n }\n ...\n\n**NOTE**: If you do use that feature make sure that the ``TRANSPARENT_SCHEMA_RULES``\nin your ``settings.py`` is also turned ON, otherwise you will get complains from the\nCerberus library about \"unknown field 'description' for field [yourFieldName]\", or use \na custom schema validator, as below:\n\n.. code-block:: python\n\n from eve.io.mongo import Validator\n\n class MyValidator(Validator):\n def _validate_description(self, description, field, value):\n \"\"\" {'type': 'string'} \"\"\"\n # Accept description attribute, used for swagger doc generation\n pass\n\n app = Eve(validator=MyValidator)\n\n\nDisabling the documentation of a resource\n-----------------------------------------\n\nYou can disable the documentation of a specific resource by adding a ``disable_documentation`` field\nto the resource definition in ``settings.py``. This means that the resource will not show up in\nthe ``paths`` or ``definitions`` sections of the swagger docs.\n\n.. code-block:: python\n\n ...\n 'person': {\n 'item_title': 'person',\n 'disable_documentation': True,\n 'schema': {...}\n }\n ...\n\nEnabling the documentation of Eve event hooks\n---------------------------------------------\n\nBy setting ``app.config['ENABLE_HOOK_DESCRIPTION']`` to ``True`` you can enable the description of all Eve event hooks.\nThis is done by showing the docstrings of the callback functions in the swagger docs under the appropriate ``paths``.\n\n.. code-block:: python\n\n def foo(request, lookup):\n \"\"\" Do something before GETting all the people \"\"\"\n pass\n def bar(response):\n \"\"\" Do something when you've fetched the database entries \"\"\"\n pass\n ...\n app.config['ENABLE_HOOK_DESCRIPTION'] = True\n ...\n app.on_pre_GET_people += foo\n app.on_fetched_resource_people += bar\n\nThe swagger docs will now look like this:\n\n.. code-block:: python\n\n \"paths\": {\n \"/people\": {\n \"get\": {\n ...,\n \"description\": \"**Hooks**:\\n* `on_pre_GET_people`:\\n\\n * `foo`:\\n\\n Do something before GETting all the people\\n\\n\\n* `on_fetched_resource_people`:\\n\\n * `bar`:\\n\\n Do something when you've fetched the database entries\\n\\n\"\n }\n }\n }\n\nWhich will be rendered by Swagger like this:\n\n.. image:: resources/hook_description.png\n\nExample fields on the docs\n--------------------------\n\nLike a description, an example can be added to a field.\n\n.. code-block:: python\n\n ...\n 'schema': {\n 'lastName': {\n 'example': 'Doe',\n 'type': 'string',\n 'minlength': 1,\n },\n }\n ...\n\nThe example is shown in the swagger ui in the model and the responses.\n\n.. image:: resources/example_field.png\n\n**NOTE**: As with the description, the field ``TRANSPARENT_SCHEMA_RULES``\nmust be enabled in your ``settings.py``, otherwise the Cerberus library \nwill display an error about \"unknown field 'example' for field[yourFieldName]\".\n\nIf you do not want to use this rule for the entire schema, you can also use \nyour own validator.\n\n.. code-block:: python\n\n from eve.io.mongo import Validator\n\n class MyValidator(Validator):\n def _validate_example(self, example, field, value):\n if example and not isinstance(value, str):\n self._error(field, \"Value must be a string\")\n\n ...\n\n app = Eve(validator=MyValidator)\n\nCopyright\n---------\nEve-Swagger is an open source project by `Nicola Iarocci`_.\nSee the original LICENSE_ for more information.\n\n.. |latest-version| image:: https://img.shields.io/pypi/v/eve-swagger.svg\n :alt: Latest version on PyPI\n :target: https://pypi.python.org/pypi/eve-swagger\n.. |build-status| image:: https://travis-ci.org/pyeve/eve-swagger.svg?branch=master\n :alt: Build status\n :target: https://travis-ci.org/pyeve/eve-swagger\n.. |python-support| image:: https://img.shields.io/pypi/pyversions/eve-swagger.svg\n :target: https://pypi.python.org/pypi/eve-swagger\n :alt: Python versions\n.. |license| image:: https://img.shields.io/pypi/l/eve-swagger.svg\n :alt: Software license\n :target: https://github.com/pyeve/eve-swagger/blob/master/LICENSE\n\n.. _Swagger: http://swagger.io/\n.. _Eve: http://python-eve.org/\n.. _`popular request`: https://github.com/pyeve/eve/issues/574\n.. _LICENSE: https://github.com/pyeve/eve-swagger/blob/master/LICENSE\n.. _`Nicola Iarocci`: http://nicolaiarocci.com\n.. _`Swagger UI`: https://github.com/swagger-api/swagger-ui#enabling-cors\n.. _`Swagger Editor`: https://github.com/swagger-api/swagger-editor/blob/master/docs/cors.md\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/pyeve/eve-swagger", "keywords": "swagger", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "Eve-Swagger", "package_url": "https://pypi.org/project/Eve-Swagger/", "platform": "any", "project_url": "https://pypi.org/project/Eve-Swagger/", "project_urls": { "Homepage": "http://github.com/pyeve/eve-swagger" }, "release_url": "https://pypi.org/project/Eve-Swagger/0.0.11/", "requires_dist": null, "requires_python": "", "summary": "Swagger extension for Eve powered RESTful APIs", "version": "0.0.11" }, "last_serial": 3976620, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "332b55f612ec3d96e685585709eff28e", "sha256": "5882a0d9e88c52c2f3c2214df67e508593ba49abeabc9e7c8f6916586502a197" }, "downloads": -1, "filename": "Eve-Swagger-0.0.1.tar.gz", "has_sig": false, "md5_digest": "332b55f612ec3d96e685585709eff28e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5131, "upload_time": "2016-06-04T07:55:18", "url": "https://files.pythonhosted.org/packages/9f/ab/7a513779c359a0ec96bff8a28956c1ec6dfe4c733a15a55692995dae13d0/Eve-Swagger-0.0.1.tar.gz" } ], "0.0.10": [ { "comment_text": "", "digests": { "md5": "d8060cca0ebecc0d07ea6867f44cb047", "sha256": "586c64ad86cdae28b1a21c6a1b6afa822e3b23722d04099f487d6f919a5d3183" }, "downloads": -1, "filename": "Eve-Swagger-0.0.10.tar.gz", "has_sig": false, "md5_digest": "d8060cca0ebecc0d07ea6867f44cb047", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16727, "upload_time": "2018-04-10T08:11:24", "url": "https://files.pythonhosted.org/packages/2c/66/cc32a1485002b16ae58db90647d93271a9daca2b50489af90c25906caed0/Eve-Swagger-0.0.10.tar.gz" } ], "0.0.11": [ { "comment_text": "", "digests": { "md5": "95ff6007be3833151b78da696bed7b64", "sha256": "dc6a94cc82aa6a3277cda9efc95820e2335eae7dadb506e52180caf40c03ea9f" }, "downloads": -1, "filename": "Eve-Swagger-0.0.11.tar.gz", "has_sig": false, "md5_digest": "95ff6007be3833151b78da696bed7b64", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17145, "upload_time": "2018-06-19T09:15:21", "url": "https://files.pythonhosted.org/packages/69/07/cf0b4abce5fd59c4f603a40bd30ebd182159bcd3d7e9b9ee567904618560/Eve-Swagger-0.0.11.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "ca43d2fdd92498bf44aa85028a568de3", "sha256": "e6d1f109b089c8a2749767aeb003f777190ecc92a87b9dededfda480865c8a1c" }, "downloads": -1, "filename": "Eve-Swagger-0.0.2.tar.gz", "has_sig": false, "md5_digest": "ca43d2fdd92498bf44aa85028a568de3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5187, "upload_time": "2016-06-06T12:47:43", "url": "https://files.pythonhosted.org/packages/eb/8d/0b7723f16fab6d55ed231778fb9a1f0a70403253c5bf4c5e24e968b45761/Eve-Swagger-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "03931310370b3867e3a4c04526465054", "sha256": "b1403d34a4a669612e8392b0390294ae7b8784638be0ce62af18a2ea8c779ce6" }, "downloads": -1, "filename": "Eve-Swagger-0.0.3.tar.gz", "has_sig": false, "md5_digest": "03931310370b3867e3a4c04526465054", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5165, "upload_time": "2016-06-07T06:59:58", "url": "https://files.pythonhosted.org/packages/03/b0/6456528287bc1a92a4a66b87eee4cf0165c7cdc3868ecdd8b0e84a2b9313/Eve-Swagger-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "a4acb928d52e2b0a5743d0006093b873", "sha256": "266510bfe27afcafd943e72a983802c3a6258c668cd43bc82df683eca880b911" }, "downloads": -1, "filename": "Eve-Swagger-0.0.4.tar.gz", "has_sig": false, "md5_digest": "a4acb928d52e2b0a5743d0006093b873", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5706, "upload_time": "2016-06-12T15:22:51", "url": "https://files.pythonhosted.org/packages/0e/34/443f7b20a1078b9678624f2070ffecc4a2d5c506d64e14742352a20049be/Eve-Swagger-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "cdc3f0c1bf56ec60a258ab5725ef3d4f", "sha256": "00107cfca1c188689da93a39da32fa4d50b7f014fbe4e6b2b05a5a63d8a49dbd" }, "downloads": -1, "filename": "Eve-Swagger-0.0.5.tar.gz", "has_sig": false, "md5_digest": "cdc3f0c1bf56ec60a258ab5725ef3d4f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13296, "upload_time": "2016-10-25T13:48:17", "url": "https://files.pythonhosted.org/packages/42/a3/8bba111212ad3c8b389ecfab30fa31509be6f25e996e16de7db5ca251aa6/Eve-Swagger-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "a9ba069f3b2d682b5d36955ca7f6ab08", "sha256": "9828d097cd4e8ac25406d34128692463a0517a4132d538006762da6ca89acd34" }, "downloads": -1, "filename": "Eve-Swagger-0.0.6.tar.gz", "has_sig": false, "md5_digest": "a9ba069f3b2d682b5d36955ca7f6ab08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13661, "upload_time": "2017-01-03T08:22:26", "url": "https://files.pythonhosted.org/packages/cc/8b/229d54f35f3c83c66816082ff2f73e6f0097d10749d8de57a127d92d637f/Eve-Swagger-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "d6ad05ef0146c2ea2efa8a789535e46a", "sha256": "c84f7297601c75be2eabecf451f1f66459d55b255dadb9fe6bb7005bd8f10616" }, "downloads": -1, "filename": "Eve-Swagger-0.0.7.tar.gz", "has_sig": false, "md5_digest": "d6ad05ef0146c2ea2efa8a789535e46a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13755, "upload_time": "2017-03-13T09:01:50", "url": "https://files.pythonhosted.org/packages/4a/fa/13d3430810000504848dc2f5069a30d414dada7841be470c4db873410dfb/Eve-Swagger-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "9c30949e1f92f9b9850fe959d84fa9d5", "sha256": "90740855ed617c23f64c0d02b674c0b1f31914f97b4ebb180129778ef8262cd1" }, "downloads": -1, "filename": "Eve-Swagger-0.0.8.tar.gz", "has_sig": false, "md5_digest": "9c30949e1f92f9b9850fe959d84fa9d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14374, "upload_time": "2017-10-02T07:22:35", "url": "https://files.pythonhosted.org/packages/37/dd/2b1e7ba02161173c9b075bad00eabb9b164157bfd23b0f6795929dc91f6a/Eve-Swagger-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "19c60cfaeff2972d4c328a156093e021", "sha256": "34d5e362f5d1721cafc828b1fc780b96d0a8fe40c54f617efb930132571e2da8" }, "downloads": -1, "filename": "Eve-Swagger-0.0.9.tar.gz", "has_sig": false, "md5_digest": "19c60cfaeff2972d4c328a156093e021", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16081, "upload_time": "2018-03-06T16:10:18", "url": "https://files.pythonhosted.org/packages/02/b7/3a58e0b8a3314191d7f338f5c31066e38f601c1e4515ad1261e56009fc4f/Eve-Swagger-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "95ff6007be3833151b78da696bed7b64", "sha256": "dc6a94cc82aa6a3277cda9efc95820e2335eae7dadb506e52180caf40c03ea9f" }, "downloads": -1, "filename": "Eve-Swagger-0.0.11.tar.gz", "has_sig": false, "md5_digest": "95ff6007be3833151b78da696bed7b64", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17145, "upload_time": "2018-06-19T09:15:21", "url": "https://files.pythonhosted.org/packages/69/07/cf0b4abce5fd59c4f603a40bd30ebd182159bcd3d7e9b9ee567904618560/Eve-Swagger-0.0.11.tar.gz" } ] }