{ "info": { "author": "Cristi V.", "author_email": "cristi@cvjd.me", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Documentation", "Topic :: Software Development :: Code Generators" ], "description": ".. role:: python(code)\n :language: python\n\n########################################\ndrf-yasg - Yet another Swagger generator\n########################################\n\n|travis| |nbsp| |codecov| |nbsp| |rtd-badge| |nbsp| |pypi-version|\n\n|bmac-button|\n\nGenerate **real** Swagger/OpenAPI 2.0 specifications from a Django Rest Framework API.\n\nCompatible with\n\n- **Django Rest Framework**: 3.8, 3.9\n- **Django**: 1.11, 2.1, 2.2\n- **Python**: 2.7, 3.5, 3.6, 3.7\n\nOnly the latest patch version of each ``major.minor`` series of Python, Django and Django REST Framework is supported.\n\n**Only the latest version of drf-yasg is supported.** Support of old versions is dropped immediately with the release\nof a new version. Please do not create issues before upgrading to the latest release available at the time. Regression\nreports are accepted and will be resolved with a new release as quickly as possible. Removed features will usually go\nthrough a deprecation cycle of a few minor releases.\n\nResources:\n\n* **Source**: https://github.com/axnsan12/drf-yasg/\n* **Documentation**: https://drf-yasg.readthedocs.io/\n* **Changelog**: https://drf-yasg.readthedocs.io/en/stable/changelog.html\n* **Live demo**: https://drf-yasg-demo.herokuapp.com/\n\n|heroku-button|\n\n********\nFeatures\n********\n\n- full support for nested Serializers and Schemas\n- response schemas and descriptions\n- model definitions compatible with codegen tools\n- customization hooks at all points in the spec generation process\n- JSON and YAML format for spec\n- bundles latest version of\n `swagger-ui `_ and\n `redoc `_ for viewing the generated documentation\n- schema view is cacheable out of the box\n- generated Swagger schema can be automatically validated by\n `swagger-spec-validator `_\n- supports Django REST Framework API versioning with ``URLPathVersioning`` and ``NamespaceVersioning``; other DRF\n or custom versioning schemes are not currently supported\n\n.. figure:: https://raw.githubusercontent.com/axnsan12/drf-yasg/1.0.2/screenshots/redoc-nested-response.png\n :width: 100%\n :figwidth: image\n :alt: redoc screenshot\n\n **Fully nested request and response schemas.**\n\n.. figure:: https://raw.githubusercontent.com/axnsan12/drf-yasg/1.0.2/screenshots/swagger-ui-list.png\n :width: 100%\n :figwidth: image\n :alt: swagger-ui screenshot\n\n **Choose between redoc and swagger-ui.**\n\n.. figure:: https://raw.githubusercontent.com/axnsan12/drf-yasg/1.0.2/screenshots/swagger-ui-models.png\n :width: 100%\n :figwidth: image\n :alt: model definitions screenshot\n\n **Real Model definitions.**\n\n\n*****************\nTable of contents\n*****************\n\n.. contents::\n :depth: 4\n\n*****\nUsage\n*****\n\n0. Installation\n===============\n\nThe preferred instalation method is directly from pypi:\n\n.. code:: console\n\n pip install -U drf-yasg\n\nAdditionally, if you want to use the built-in validation mechanisms (see `4. Validation`_), you need to install\nsome extra requirements:\n\n.. code:: console\n\n pip install -U drf-yasg[validation]\n\n.. _readme-quickstart:\n\n1. Quickstart\n=============\n\nIn ``settings.py``:\n\n.. code:: python\n\n INSTALLED_APPS = [\n ...\n 'drf_yasg',\n ...\n ]\n\nIn ``urls.py``:\n\n.. code:: python\n\n ...\n from rest_framework import permissions\n from drf_yasg.views import get_schema_view\n from drf_yasg import openapi\n\n ...\n\n schema_view = get_schema_view(\n openapi.Info(\n title=\"Snippets API\",\n default_version='v1',\n description=\"Test description\",\n terms_of_service=\"https://www.google.com/policies/terms/\",\n contact=openapi.Contact(email=\"contact@snippets.local\"),\n license=openapi.License(name=\"BSD License\"),\n ),\n public=True,\n permission_classes=(permissions.AllowAny,),\n )\n\n urlpatterns = [\n url(r'^swagger(?P\\.json|\\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),\n url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),\n url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),\n ...\n ]\n\nThis exposes 4 endpoints:\n\n* A JSON view of your API specification at ``/swagger.json``\n* A YAML view of your API specification at ``/swagger.yaml``\n* A swagger-ui view of your API specification at ``/swagger/``\n* A ReDoc view of your API specification at ``/redoc/``\n\n2. Configuration\n================\n\n---------------------------------\na. ``get_schema_view`` parameters\n---------------------------------\n\n- ``info`` - Swagger API Info object; if omitted, defaults to ``DEFAULT_INFO``\n- ``url`` - API base url; if left blank will be deduced from the location the view is served at\n- ``patterns`` - passed to SchemaGenerator\n- ``urlconf`` - passed to SchemaGenerator\n- ``public`` - if False, includes only endpoints the current user has access to\n- ``validators`` - a list of validator names to apply on the generated schema; only ``ssv`` is currently supported\n- ``generator_class`` - schema generator class to use; should be a subclass of ``OpenAPISchemaGenerator``\n- ``authentication_classes`` - authentication classes for the schema view itself\n- ``permission_classes`` - permission classes for the schema view itself\n\n-------------------------------\nb. ``SchemaView`` options\n-------------------------------\n\n- :python:`SchemaView.with_ui(renderer, cache_timeout, cache_kwargs)` - get a view instance using the\n specified UI renderer; one of ``swagger``, ``redoc``\n- :python:`SchemaView.without_ui(cache_timeout, cache_kwargs)` - get a view instance with no UI renderer;\n same as ``as_cached_view`` with no kwargs\n- :python:`SchemaView.as_cached_view(cache_timeout, cache_kwargs, **initkwargs)` - same as ``as_view``,\n but with optional caching\n- you can, of course, call :python:`as_view` as usual\n\nAll of the first 3 methods take two optional arguments, ``cache_timeout`` and ``cache_kwargs``; if present,\nthese are passed on to Django\u2019s :python:`cached_page` decorator in order to enable caching on the resulting view.\nSee `3. Caching`_.\n\n----------------------------------------------\nc. ``SWAGGER_SETTINGS`` and ``REDOC_SETTINGS``\n----------------------------------------------\n\nAdditionally, you can include some more settings in your ``settings.py`` file.\nSee https://drf-yasg.readthedocs.io/en/stable/settings.html for details.\n\n\n3. Caching\n==========\n\nSince the schema does not usually change during the lifetime of the django process, there is out of the box support for\ncaching the schema view in-memory, with some sane defaults:\n\n* caching is enabled by the `cache_page `__\n decorator, using the default Django cache backend, can be changed using the ``cache_kwargs`` argument\n* HTTP caching of the response is blocked to avoid confusing situations caused by being shown stale schemas\n* the cached schema varies on the ``Cookie`` and ``Authorization`` HTTP headers to enable filtering of visible endpoints\n according to the authentication credentials of each user; note that this means that every user accessing the schema\n will have a separate schema cached in memory.\n\n4. Validation\n=============\n\nGiven the numerous methods to manually customize the generated schema, it makes sense to validate the result to ensure\nit still conforms to OpenAPI 2.0. To this end, validation is provided at the generation point using python swagger\nlibraries, and can be activated by passing :python:`validators=['ssv']` to ``get_schema_view``; if the generated\nschema is not valid, a :python:`SwaggerValidationError` is raised by the handling codec.\n\n**Warning:** This internal validation can slow down your server.\nCaching can mitigate the speed impact of validation.\n\nThe provided validation will catch syntactic errors, but more subtle violations of the spec might slip by them. To\nensure compatibility with code generation tools, it is recommended to also employ one or more of the following methods:\n\n-------------------------------\n``swagger-ui`` validation badge\n-------------------------------\n\nOnline\n^^^^^^\n\nIf your schema is publicly accessible, `swagger-ui` will automatically validate it against the official swagger\nonline validator and display the result in the bottom-right validation badge.\n\nOffline\n^^^^^^^\n\nIf your schema is not accessible from the internet, you can run a local copy of\n`swagger-validator `_ and set the ``VALIDATOR_URL`` accordingly:\n\n.. code:: python\n\n SWAGGER_SETTINGS = {\n ...\n 'VALIDATOR_URL': 'http://localhost:8189',\n ...\n }\n\n.. code:: console\n\n $ docker run --name swagger-validator -d -p 8189:8080 --add-host test.local:10.0.75.1 swaggerapi/swagger-validator\n 84dabd52ba967c32ae6b660934fa6a429ca6bc9e594d56e822a858b57039c8a2\n $ curl http://localhost:8189/debug?url=http://test.local:8002/swagger/?format=openapi\n {}\n\n---------------------\nUsing ``swagger-cli``\n---------------------\n\nhttps://www.npmjs.com/package/swagger-cli\n\n.. code:: console\n\n $ npm install -g swagger-cli\n [...]\n $ swagger-cli validate http://test.local:8002/swagger.yaml\n http://test.local:8002/swagger.yaml is valid\n\n--------------------------------------------------------------\nManually on `editor.swagger.io `__\n--------------------------------------------------------------\n\nImporting the generated spec into https://editor.swagger.io/ will automatically trigger validation on it.\nThis method is currently the only way to get both syntactic and semantic validation on your specification.\nThe other validators only provide JSON schema-level validation, but miss things like duplicate operation names,\nimproper content types, etc\n\n5. Code generation\n==================\n\nYou can use the specification outputted by this library together with\n`swagger-codegen `_ to generate client code in your language of choice:\n\n.. code:: console\n\n $ docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate -i /local/tests/reference.yaml -l javascript -o /local/.codegen/js\n\nSee the github page linked above for more details.\n\n.. _readme-testproj:\n\n6. Example project\n==================\n\nFor additional usage examples, you can take a look at the test project in the ``testproj`` directory:\n\n.. code:: console\n\n $ git clone https://github.com/axnsan12/drf-yasg.git\n $ cd drf-yasg\n $ virtualenv venv\n $ source venv/bin/activate\n (venv) $ cd testproj\n (venv) $ python -m pip install -U pip setuptools\n (venv) $ pip install -U -r requirements.txt\n (venv) $ python manage.py migrate\n (venv) $ python manage.py runserver\n (venv) $ firefox localhost:8000/swagger/\n\n************************\nThird-party integrations\n************************\n\ndjangorestframework-camel-case\n===============================\n\nIntegration with `djangorestframework-camel-case `_ is\nprovided out of the box - if you have ``djangorestframework-camel-case`` installed and your ``APIView`` uses\n``CamelCaseJSONParser`` or ``CamelCaseJSONRenderer``, all property names will be converted to *camelCase* by default.\n\ndjangorestframework-recursive\n===============================\n\nIntegration with `djangorestframework-recursive `_ is\nprovided out of the box - if you have ``djangorestframework-recursive`` installed.\n\n.. |travis| image:: https://img.shields.io/travis/axnsan12/drf-yasg/master.svg\n :target: https://travis-ci.org/axnsan12/drf-yasg\n :alt: Travis CI\n\n.. |codecov| image:: https://img.shields.io/codecov/c/github/axnsan12/drf-yasg/master.svg\n :target: https://codecov.io/gh/axnsan12/drf-yasg\n :alt: Codecov\n\n.. |pypi-version| image:: https://img.shields.io/pypi/v/drf-yasg.svg\n :target: https://pypi.org/project/drf-yasg/\n :alt: PyPI\n\n.. |rtd-badge| image:: https://img.shields.io/readthedocs/drf-yasg.svg\n :target: https://drf-yasg.readthedocs.io/\n :alt: ReadTheDocs\n\n.. |bmac-button| image:: https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png\n :target: https://www.buymeacoffee.com/cvijdea\n :alt: Buy Me A Coffee\n\n.. |heroku-button| image:: https://www.herokucdn.com/deploy/button.svg\n :target: https://heroku.com/deploy?template=https://github.com/axnsan12/drf-yasg\n :alt: Heroku deploy button\n\n.. |nbsp| unicode:: 0xA0\n :trim:", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/say/drf-yasg", "keywords": "drf django django-rest-framework schema swagger openapi codegen swagger-codegen documentation drf-yasg django-rest-swagger drf-openapi", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "drf-yasg-kauffman", "package_url": "https://pypi.org/project/drf-yasg-kauffman/", "platform": "", "project_url": "https://pypi.org/project/drf-yasg-kauffman/", "project_urls": { "Homepage": "https://github.com/say/drf-yasg" }, "release_url": "https://pypi.org/project/drf-yasg-kauffman/1.16.2a1/", "requires_dist": null, "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "summary": "Automated generation of real Swagger/OpenAPI 2.0 schemas from Django Rest Framework code.", "version": "1.16.2a1" }, "last_serial": 5822629, "releases": { "1.16.2a1": [ { "comment_text": "", "digests": { "md5": "d26b1cee0ce7b9ab03ce7d682872fbe7", "sha256": "383912498f902eb2352e4a00e46ee0f3be4383d823abacc4936b4bf5fc86beb5" }, "downloads": -1, "filename": "drf-yasg-kauffman-1.16.2a1.tar.gz", "has_sig": false, "md5_digest": "d26b1cee0ce7b9ab03ce7d682872fbe7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "size": 1287942, "upload_time": "2019-09-12T21:30:11", "url": "https://files.pythonhosted.org/packages/9b/d7/ca25a7ea6019e9f90bc46d050702922cadde169fa610f068eee1e788040f/drf-yasg-kauffman-1.16.2a1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d26b1cee0ce7b9ab03ce7d682872fbe7", "sha256": "383912498f902eb2352e4a00e46ee0f3be4383d823abacc4936b4bf5fc86beb5" }, "downloads": -1, "filename": "drf-yasg-kauffman-1.16.2a1.tar.gz", "has_sig": false, "md5_digest": "d26b1cee0ce7b9ab03ce7d682872fbe7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "size": 1287942, "upload_time": "2019-09-12T21:30:11", "url": "https://files.pythonhosted.org/packages/9b/d7/ca25a7ea6019e9f90bc46d050702922cadde169fa610f068eee1e788040f/drf-yasg-kauffman-1.16.2a1.tar.gz" } ] }