{ "info": { "author": "ifanr", "author_email": "adamwen@ifanr.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Programming Language :: Python" ], "description": "Synopsis\n========\n\n**django-tastypie-swagger** is a small adapter library to construct Swagger_ documentation from Tastypie_ resources.\n\nThis package provides two things:\n\n1. An embedded instance of `Swagger UI`_ to point a URL to.\n2. Automatic `Resource Listing`_ and `API Declaration`_ generation that is consumed by #1\n\n\nUsage\n=====\n\nAdd to INSTALLED_APPS::\n\n INSTALLED_APPS = [\n ...\n\n 'tastypie_swagger',\n\n ...\n ]\n\nDefine **TASTYPIE_SWAGGER_API_MODULE_LIST** in your settings::\n\n \n TASTYPIE_SWAGGER_API_MODULE_LIST = (\n {'path': 'app_name.path',\n 'obj': 'xxx',\n 'func_name': 'xxx'},\n\n {'path': 'app_name.path',\n 'obj': 'xxx',\n 'func_name': 'xxx'}\n )\n\n**TASTYPIE_SWAGGER_API_MODULE_LIST** is an iterable object.\nEach item is a dict.\npath: It should be a payhon path can find your api instance, like polls.api(polls is your APP's name, there is a api.py in directory polls)\nobj: It should be an Api instance or an instance who have a function to get an Api instance\nfunc_name: if isinstance(obj, Api) is True, func_name should be ''\n\nInclude in your urlconf with namespace **tastypie_swagger**::\n\n urlpatterns = patterns('',\n ...\n\n url(r'api/doc/', include('tastypie_swagger.urls', namespace='tastypie_swagger')),\n\n ...\n )\n\n\nSwagger documentation will be served up at the URL you configured.\n\nUsing ``extra_actions``\n--------------------\n\nWhile most **ModelResource** based endpoints are good *as-is* there are times\nwhen adding additional functionality (`like search `_)\nis required. In Tastypie the recommended way do to this is by overriding the\n``prepend_urls`` function and returning a list of urls that describe additional\nendpoints. How do you make the schema map represent these endpoints so they are\nproperly documented?::\n\nAdd an attribute to the ``Meta`` class inside your **ModelResource** class\ncalled ``extra_actions``. Following the Tastypie search example, here is how\n``extra_actions`` should be defined::\n\n class Meta:\n ...\n extra_actions = [\n {\n \"name\": \"search\",\n \"http_method\": \"GET\",\n \"resource_type\": \"list\",\n \"description\": \"Seach endpoint\",\n \"fields\": {\n \"q\": {\n \"type\": \"string\",\n \"required\": True,\n \"description\": \"Search query terms\"\n }\n }\n }\n ]\n\n``extra_actions`` is a list of dictionary objects that define extra endpoints\nthat are unavailable to introspection.\n\n.. important::\n ``extra_actions`` feeds directly into the schema **for swagger**. It does\n not alter the tastypie schema listing tastypie provides.\n\nTop level keys and meaning in the ``extra_actions`` dictionary:\n\n- ``name``: **Required**. Nickname of the resource.\n- ``http_method``: Defaults to ``\"GET\"``. HTTP method allowed here as a string.\n Will be uppercased on output.\n- ``resource_type``: If this is declared as ``\"list\"`` then the endpoint\n **will not** include a ``{id}`` parameter in the uri or in the parameters\n list. This is applicable to endpoints such as the above example that filter\n or perform actions across many items. If ``resource_type`` is ommitted and\n the ``http_method`` is ``\"GET\"`` then the endpoint will default to ``\"view\"``\n and include a ``{id}`` parameter in the uri and parameter list.\n- ``description``: Description of this endpoint.\n- ``fields``: Dictionary of parameters this endpoint accepts.\n\nField dictionaries are declared in a ``{ \"name\": { [options dict] }`` style.\nThis is done for compatability reasons with older versions of\ndjango-tastypie-swagger.\n\n.. warning::\n The structure of ``fields`` will likely change in future versions if\n `Joshua Kehn`_ continues committing.\n\nAvailable keys and meaning for the ``fields`` dictionary.::\n\n - ``type``: Defaults to ``\"string\"``. Parameter type.\n - ``required``: Defaults to ``False``.\n - ``description``: Defaults to ``\"\"`` (empty string). Description of this\n parameter.\n\n\nDetecting required fields\n-------------------------\n\nTastypie 0.9.11 **ModelResource** fields do not respect the *blank* attribute on django model fields, which this library depends on to determine if a field is required or not.\n\nYou can use `this ModelResource subclass `_ as a workaround to this issue.\n\n\n\n\n\n.. _Swagger: http://swagger.wordnik.com/\n.. _Tastypie: https://django-tastypie.readthedocs.org\n.. _Resource Listing: https://github.com/wordnik/swagger-core/wiki/Resource-Listing\n.. _API Declaration: https://github.com/wordnik/swagger-core/wiki/API-Declaration\n.. _Swagger UI: https://github.com/wordnik/swagger-ui\n.. _tastypie.api.Api: https://django-tastypie.readthedocs.org/en/latest/api.html\n.. _Joshua Kehn: mailto:josh@kehn.us", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/ifanrx/django-tastypie-swagger/downloads", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ifanrx/django-tastypie-swagger", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-tastypie-swagger-ng", "package_url": "https://pypi.org/project/django-tastypie-swagger-ng/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-tastypie-swagger-ng/", "project_urls": { "Download": "https://github.com/ifanrx/django-tastypie-swagger/downloads", "Homepage": "https://github.com/ifanrx/django-tastypie-swagger" }, "release_url": "https://pypi.org/project/django-tastypie-swagger-ng/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "An adapter to use swagger-ui with django-tastypie", "version": "0.1.3" }, "last_serial": 2007319, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "94edab24bd0eb16499f71578c739581b", "sha256": "ce361fe8879680a11cd95f9806e498387c3ef4b096a1f6fd1a93299495030b21" }, "downloads": -1, "filename": "django-tastypie-swagger-ng-0.1.2.tar.gz", "has_sig": false, "md5_digest": "94edab24bd0eb16499f71578c739581b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 116179, "upload_time": "2014-07-02T18:04:10", "url": "https://files.pythonhosted.org/packages/f6/3a/440e2ab85a9f06eacf516ea9523f622a6ea2f0fe1ee0566d6fea2f6b0692/django-tastypie-swagger-ng-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "1c1c8440a68f2d41aeac2a071821058a", "sha256": "4fd1f7dea6e8425c57700bc7038a508c7526d98bb267b9090c8fa5e292a561fe" }, "downloads": -1, "filename": "django-tastypie-swagger-ng-0.1.3.tar.gz", "has_sig": false, "md5_digest": "1c1c8440a68f2d41aeac2a071821058a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 116125, "upload_time": "2016-03-15T06:56:03", "url": "https://files.pythonhosted.org/packages/b7/ed/7c75437fd8301fdd43cc15c1aec87b9a8768f2b9215a3d7cf74ee6c95f8d/django-tastypie-swagger-ng-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1c1c8440a68f2d41aeac2a071821058a", "sha256": "4fd1f7dea6e8425c57700bc7038a508c7526d98bb267b9090c8fa5e292a561fe" }, "downloads": -1, "filename": "django-tastypie-swagger-ng-0.1.3.tar.gz", "has_sig": false, "md5_digest": "1c1c8440a68f2d41aeac2a071821058a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 116125, "upload_time": "2016-03-15T06:56:03", "url": "https://files.pythonhosted.org/packages/b7/ed/7c75437fd8301fdd43cc15c1aec87b9a8768f2b9215a3d7cf74ee6c95f8d/django-tastypie-swagger-ng-0.1.3.tar.gz" } ] }