Skip to main content

This is a django app which you can modify and improve your autogenerated swagger documentation from your drf API.

Project description

=============================
drf-swagger-customization
=============================

.. image:: https://badge.fury.io/py/drf-swagger-customization.svg
:target: https://badge.fury.io/py/drf-swagger-customization

.. image:: https://travis-ci.org/androiz/drf-swagger-customization.svg?branch=master
:target: https://travis-ci.org/androiz/drf-swagger-customization

.. image:: https://codecov.io/gh/androiz/drf-swagger-customization/branch/master/graph/badge.svg
:target: https://codecov.io/gh/androiz/drf-swagger-customization

This is a django app which you can modify and improve your autogenerated swagger documentation from your drf API.

Documentation
-------------

The full documentation is at https://drf-swagger-customization.readthedocs.io.

Quickstart
----------

Install drf-swagger-customization::

pip install drf-swagger-customization


Add these global variables to your settings.py:

.. code-block:: python

EXTENSION_PATH = os.path.join(PROJECT_DIR, 'docs/doc_extension.json') # Path to your extension file
EXTERNAL_DOC_FOLDER = os.path.join(PROJECT_DIR, 'docs/external/') # Path to your external documentation folder


Add drf-swagger-customization's URL patterns:

.. code-block:: python

from drf_swagger_customization.views import get_swagger_view

schema_view = get_swagger_view(title='Pastebin API')

urlpatterns = [
...
url(r'^docs/$', schema_view),
...
]

Usage
--------
With this package we can increase the auto-generated documentation from django-swagger. That way, we can add documentation
from external APIs or add more information to our drf API methods such as fields, remove endpoints, update attributes, and so on.

In order to add/update/remove information to our EXTENSION_PATH json file, we have available these operations:

Create:
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: javascript

{
"operation": "create",
"swagger-data": {
"paths|/v1/travels/|get|parameters": [
{
"name": "Field1",
"in": "query",
"required": true,
"type": "string"
},
{
"name": "Field2",
"in": "path",
"required": true,
"type": "integer"
}
]
}
}

Update:
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: javascript

{
"operation": "update",
"swagger-data": {
"paths|/v1/travels/|get|parameters|field1": {
"name": "Field1",
"in": "query",
"required": true,
"type": "string"
}
}
}


Remove:
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: javascript

{
"operation": "delete",
"swagger-data": "paths|/v1/travels/|get|parameters|field1"
}


Completed Sample
--------

.. code-block:: javascript

[
{
"operation": "create",
"swagger-data": {
"paths|/v1/travels/|get|parameters": [
{
"name": "Field1",
"in": "query",
"required": true,
"type": "string"
},
{
"name": "Field2",
"in": "path",
"required": true,
"type": "integer"
}
]
}
},
{
"operation": "update",
"swagger-data": {
"paths|/v1/travels/|get|parameters|field1": {
"name": "Field1",
"in": "query",
"required": true,
"type": "string"
}
}
},
{
"operation": "delete",
"swagger-data": "paths|/v1/travels/|get|parameters|field1"
}
]


Future Work
--------

* Add an example
* Command for doc_file customization, in order to remove redundant executions.
* Improve the settings options.




History
-------

0.1.3 (2017-05-30)
++++++++++++++++++

* Bugfix with documentation

0.1.2 (2017-05-30)
++++++++++++++++++

* Improved documentation in order to explain how to build the json file

0.1.1 (2017-05-25)
++++++++++++++++++

* Fix in methods add, update and remove documentation.

0.1.0 (2017-05-24)
++++++++++++++++++

* First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf-swagger-customization-0.1.3.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drf_swagger_customization-0.1.3-py2.py3-none-any.whl (8.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file drf-swagger-customization-0.1.3.tar.gz.

File metadata

File hashes

Hashes for drf-swagger-customization-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4874014dff8b87933b82251ed2584686e2ea5b79e5e1e01d50240e75f63aabdd
MD5 3da8dacb82395625bad08d6ccab960f9
BLAKE2b-256 913edc100f79036263c7ac848319660ffce806a82cd574bc8ec4e4a0e01793c0

See more details on using hashes here.

File details

Details for the file drf_swagger_customization-0.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for drf_swagger_customization-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 79f94c49c217eb2e7557cb90c80c605598c78d7b3c523805c86b66aebc7e0ed3
MD5 62c96bb38292b5972a63c38a61095764
BLAKE2b-256 a7076495d269ad4d577b72a8c66a5549771adac614174bf53828c9b656d6245c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page