{ "info": { "author": "Mashianov Oleksander", "author_email": "mashianov@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "# Django REST framework auto docs\n\n# mindbogglr-drf_autodocs\n\n[![Latest PyPI version](https://badge.fury.io/py/mindbogglr-drf_autodocs.svg)](https://pypi.python.org/pypi/mindbogglr-drf_autodocs)\n\nForked from: [drf_autodocs](https://github.com/iMakedonsky/drf-autodocs/tree/06c2d1d5a9cd23e698310dbce6100463bd8c3f46)\n\nAdded support for ManifestFilesMixin when url for fonts is pointing to a non-existant file in css.\n\n\n# Original ReadMe\n\nAutomated api documentation renderer\n\n### Features:\n\n * optional response_serializer_class, if output serializer is different from input serializer\n * fully-documented functional views\n * tree-like structure\n * Docstrings:\n * markdown\n * preserve space & newlines\n * formatting with nice syntax\n * Fields:\n * different fields for request/response, based on read-/write-only attributes and whether response_serializer_class presented or not\n * choices rendering\n * help_text rendering (to specify SerializerMethodField output, etc)\n * Endpoint properties:\n * filter_backends\n * authentication_classes\n * permission_classes\n * extra url params(GET params)\n\n### What isn't supported yet:\n\n * viewsets\n * possibility to try in browser\n\n\n# Samples\n\n#### Whole structure:\n\n![whole structure](http://joxi.ru/52aBGNI4k3oyA0.jpg)\n\n#### Single node:\n\n![single node](http://joxi.ru/E2ppYWh94VdV2Y.jpg)\n\n#### Choices:\n\n![choices](http://joxi.ru/D2PdaVspB1M423.jpg)\n\n#### Nested items:\n\n![nested items](http://joxi.ru/vAWOkRt1BKY4AW.jpg)\n\n#### Docstring formatting:\n```python\n@format_docstring(request_example, response_example=response_example)\nclass BookReadUpdateHandler(RetrieveUpdateAPIView):\n \"\"\"\n Wow, this magic decorator allows us to:\n 1) Keep clean & short docstring\n 2) Insert additional data in it, like request/response examples\n\n Request: {}\n Response: {response_example}\n \"\"\"\n```\n\n![help text](http://joxi.ru/VrwzKWSO4YekAX.jpg)\n\n\n# Installation\n\nIn virtualenv:\n\n pip install drf_autodocs\n\nIn settings:\n\n INSTALLED_APPS = [\n ...\n 'drf_autodocs',\n ...\n ]\n\nIn your urls:\n\n urlpatterns = [\n ...\n url(r'^', include('drf_autodocs.urls')),\n ]\n\n\nThat's already enough for swagger-like docs,\nresult available on\n\n`localhost:8000/docs/`\n\nIf you want functional views support and some more features, read below.\n\n# Usage\n\n### Tree-like structure\n\nTree-like structure is built from url prefixes. To make your endpoints grouped by some\ncategory, you must include your urls within other url. There are, generally, 2 ways to achieve it:\n\nExample 1:\n\n```python\nuniversity_urlpatterns = [\n url(r'^lecturers/', university_views.LecturersHandler.as_view(), name='lecturers'),\n url(r'^lecturers/(?P\\d+)/$', university_views.LecturerUpdateHandler.as_view(), name='lecturer_read_update'),\n url(r'^universities/', university_views.UniversitiesHandler.as_view(), name='universities'),\n]\n\nurlpatterns = [\n url(r'^library/', include(library_urlpatterns, namespace='library')),\n url(r'^university/', include(university_urlpatterns, namespace='university')),\n]\n```\n\nExample 2:\n```python\nurlpatterns = [\n url(r'^library/', include(library_urlpatterns, namespace='library')),\n url(r'^university/', include([\n url(r'^lecturers/', university_views.LecturersHandler.as_view(), name='lecturers'),\n url(r'^lecturers/(?P\\d+)/$', university_views.LecturerUpdateHandler.as_view(), name='lecturer_read_update'),\n url(r'^universities/', university_views.UniversitiesHandler.as_view(), name='universities')\n ], namespace='university')),\n]\n```\n\n\n### Response serializer class\nSay you have a view like this:\n```python\nclass BookReadUpdateHandler(RetrieveUpdateAPIView):\n serializer_class = BookUpdateSerializer\n queryset = Book.objects.all()\n```\n\nAnd say this serializers' input is different from output:\n```python\nclass BookUpdateSerializer(serializers.ModelSerializer):\n class Meta:\n fields = ('name', 'author')\n model = Book\n\n def to_representation(self, instance):\n return LibrarySerializer(instance.library)\n```\n\nNow to know what return format is, one must make a request.\nThis package simplifies it via:\n\n`response_serializer_class = YourSerializer`\n\nNow your view looks like:\n```python\nclass BookReadUpdateHandler(RetrieveUpdateAPIView):\n \"\"\"\n Shiny and nice docstring, which:\n 1) allows formatting\n 2) `allows markdown`\n \"\"\"\n serializer_class = BookUpdateSerializer\n response_serializer_class = LibrarySerializer\n queryset = Book.objects.all()\n```\n\n\n### Docstring formatting in class-based views\n\n```python\nfrom .request_response_examples import request_example, response_example\nfrom drf_autodocs.decorators import format_docstring\n\n\n@format_docstring(request_example, response_example=response_example)\nclass BookReadUpdateHandler(RetrieveUpdateAPIView):\n \"\"\"\n Wow, this magic decorator allows us to:\n 1) Keep clean & short docstring\n 2) Insert additional data in it, like request/response examples\n\n Request: {}\n Response: {response_example}\n \"\"\"\n serializer_class = BookUpdateSerializer\n response_serializer_class = LibrarySerializer\n queryset = Book.objects.all()\n```\n\n\n### Extra URL(GET) parameters\nPlease think twice before using such parameters, as they might be unneeded.\n\nBut if you really need them, here you go:\n\n```python\nclass LibrariesHandler(ListCreateAPIView):\n \"\"\"\n Shiny and nice docstring, which:\n 1) allows formatting\n 2) `allows markdown`\n \"\"\"\n extra_url_params = (('show_all', 'Bool', 'if True returns all instances and only 5 otherwise'),\n ('some_extra_param', 'Integer', 'Something more to be included there'))\n```\n\nResults in:\n\n![extra_url_params](http://joxi.ru/E2ppYWh9GMzJ2Y.jpg)\n\n\n### Function-based views\n\nFor functional views, decorate them with.\n\n`drf_autodocs.decorators.document_func_view`\n\nNow you can insert into view via kwargs:\n\n * serializer_class\n * response_serializer_class\n * filter_backends\n * authentication_classes\n * permission_classes\n * doc_format_args\n * doc_format_kwargs\n\nNow it should look like:\n```python\nfrom drf_autodocs.decorators import document_func_view\n\nformat_args = ['\"This string\\nwas inserted\"',]\n\n@document_func_view(serializer_class=BookSerializer,\n response_serializer_class=LibrarySerializer,\n doc_format_args=format_args)\n@api_view(['GET', 'POST', 'DELETE'])\ndef hello_world(request):\n \"\"\"\n Works for `functional` views too!\n Yeah, that thing rocks!\n And allows formatting {}\n \"\"\"\n return Response('hello_world response')\n```\n\n### Help text\n\nThis package uses default DRF field attribute `help_text`\nIf you're using `ModelSerializer`, and model field got `help_text` attr, it will be\ntransferred to your serializers' field automatically.\n\nExample:\n\n```python\nfrom rest_framework import serializers\n\nhas_books = serializers.SerializerMethodField(help_text='returns Bool')\n```\n\nNote that specifying help_text on serializers' field overrides the one from model\n\n\n# Customization\nTo change application look & feel, override templates and/or static files.\n\nRoot template is :\n`templates/drf_autodocs/index.html`\n\n\nFor additional parsers(if you want other structure than tree), inherit from\n\n `drf_autodocs.parser.BaseAPIParser`\n\n# Configuration/settings\n\nEndpoint names could use view names or url names, replacing '_' and '-' with ' ' and capitalizing output.\n\nDefault behavior is to use url names:\n\n`url(r'^books/(?P\\d+)/$', library_views.BookReadUpdateHandler.as_view(), name='book_read_update'),`\n\nwill result in:\n\n![url_name](http://joxi.ru/Q2K1WDh4yXnGrj.jpg)\n\nIf you want to use endpoint(view) names instead, do this in settings:\n\n`AUTODOCS_ENDPOINT_NAMES = \"view\"`\n\n\n\n# Supports\n - Python 3\n - Django 1.8+\n - Django Rest Framework 3+\n\n\n# Credits\nThanks to [django](http://djangoproject.com), [django-REST](http://www.django-rest-framework.org/) for their awesome work,\nand [drf-docs](https://github.com/manosim/django-rest-framework-docs) for source of inspiration as well as some parts of code.\n\n\nDeveloped with care by Mashianov Oleksander at\n\n[![buddhasoft](http://i63.tinypic.com/2h87nzm.png)](http://buddhasoft.net/)\n\n\nIf you :thumbsup: this, don't forget to :star: it and share with friends.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/iMakedonsky/drf-autodocs", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "mindbogglr-drf-autodocs", "package_url": "https://pypi.org/project/mindbogglr-drf-autodocs/", "platform": "", "project_url": "https://pypi.org/project/mindbogglr-drf-autodocs/", "project_urls": { "Homepage": "https://github.com/iMakedonsky/drf-autodocs" }, "release_url": "https://pypi.org/project/mindbogglr-drf-autodocs/0.4.3.1/", "requires_dist": null, "requires_python": "", "summary": "Extensible auto django rest framework api generator", "version": "0.4.3.1" }, "last_serial": 4430310, "releases": { "0.4.3.1": [ { "comment_text": "", "digests": { "md5": "b461647e5f7353ed08d45dd074876a00", "sha256": "d35e29a91dba9aafc75cb8d5753b875249ad2da8b72f14aa2f5c51c3130e9ae3" }, "downloads": -1, "filename": "mindbogglr-drf_autodocs-0.4.3.1.tar.gz", "has_sig": false, "md5_digest": "b461647e5f7353ed08d45dd074876a00", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 111231, "upload_time": "2018-10-30T06:52:28", "url": "https://files.pythonhosted.org/packages/9e/ba/82017c4dcf416acf140f41f3dacf1c6967db8f3c710f16992e97ffefa72e/mindbogglr-drf_autodocs-0.4.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b461647e5f7353ed08d45dd074876a00", "sha256": "d35e29a91dba9aafc75cb8d5753b875249ad2da8b72f14aa2f5c51c3130e9ae3" }, "downloads": -1, "filename": "mindbogglr-drf_autodocs-0.4.3.1.tar.gz", "has_sig": false, "md5_digest": "b461647e5f7353ed08d45dd074876a00", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 111231, "upload_time": "2018-10-30T06:52:28", "url": "https://files.pythonhosted.org/packages/9e/ba/82017c4dcf416acf140f41f3dacf1c6967db8f3c710f16992e97ffefa72e/mindbogglr-drf_autodocs-0.4.3.1.tar.gz" } ] }