Skip to main content
=============================
drf-swagger-customization
=============================

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

.. image:: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat
:target: http://drf-swagger-customization.readthedocs.io/en/latest/

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 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"
}

Rename
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: javascript

{
"action": "rename",
"operation": {
"paths|/v1/travels/": "/travels/",
"paths|/v1/travels/{id}/": "/travels/{id}/"
}
}


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"
},
{
"action": "rename",
"operation": {
"paths|/v1/travels/": "/travels/",
"paths|/v1/travels/{id}/": "/travels/{id}/"
}
}
]


Future Work
--------

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




History
-------

0.1.5 (2017-05-31)
++++++++++++++++++

* Added new action "Rename"

0.1.4 (2017-05-30)
++++++++++++++++++

* Bugfix with documentation

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.


Metadata

Release files for drf-swagger-customization 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drf-swagger-customization 0.1.5
File Size Uploaded
drf-swagger-customization-0.1.5.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for drf-swagger-customization 0.1.5
File Interpreter ABI Platform
drf_swagger_customization-0.1.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 17.4 kB

Release files / drf-swagger-customization-0.1.5.tar.gz

Download URL drf-swagger-customization-0.1.5.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f7c39083274df6625057b44511a956d8c1a23c23362fe48c17a1b1b977b6bd13
BLAKE2b-256 checksum
How to use checksums
092a36f3107bf0edc4c761f713b2e6090cce8ab457d156afcd3aa281ffa34fbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / drf_swagger_customization-0.1.5-py2.py3-none-any.whl

Download URL drf_swagger_customization-0.1.5-py2.py3-none-any.whl
Size 8.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cc38dc7306c9e43ad0f36491fea7c0e291bf4ee6a315d9249188fa4166975942
BLAKE2b-256 checksum
How to use checksums
c9ae675f12581abf7f6a6d14191c45c421d21fa843d990ba245d5f54b5538e62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page