makinacorpus/django-rest-swagger

Name: django-rest-swagger

Owner: Makina Corpus

Description: Swagger Documentation Generator for Django REST Framework

Created: 2014-10-22 10:43:03.0

Updated: 2014-10-22 03:51:40.0

Pushed: 2014-10-22 10:43:32.0

Homepage: null

Size: 3171

Language: null

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Django REST Swagger

An API documentation generator for Swagger UI and Django REST Framework version > 2.3.5

For older versions of Django REST Framework, see Django REST Framework Docs

Installation

From PyPI: pip install django-rest-swagger

From source:

Requirements

This application was developed and tested on:

Backwards compatibility for earlier Django & Django REST Framework versions will be added in a future release. Meanwhile, please use Django REST Framework Docs to document your projects.

Quick start

Note: This application will not work with Django REST Framework < 2.3

  1. Add rest_framework_swagger to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'rest_framework_swagger',
    )
    
  2. Include the rest_framework_swagger URLs to a path of your choice

    erns = ('',
    ...
    url(r'^docs/', include('rest_framework_swagger.urls')),
    
    
Configuration

Further configuration can optionally be made from your project's settings.py.

GER_SETTINGS = {
"exclude_namespaces": [], # List URL namespaces to ignore
"api_version": '0.1',  # Specify your API's version
"api_path": "/",  # Specify the path to your API not a root level
"enabled_methods": [  # Specify which methods to enable in Swagger UI
    'get',
    'post',
    'put',
    'patch',
    'delete'
],
"api_key": '', # An API key
"is_authenticated": False,  # Set to True to enforce user authentication,
"is_superuser": False,  # Set to True to enforce admin only access

How It Works

This project is built on the Django REST Framework Docs and uses the lovely Swagger from Wordnik as an interface. This application introspectively generates documentation based on your Django REST Framework API code. Comments are generated in combination from code analysis and comment extraction. Here are some of the features that are documented:

class Countries(APIView):
    """
    This text is the description for this API
    param1 -- A first parameter
    param2 -- A second parameter
    """
Example

Included in this repository is a functioning example. Please clone the repo, copy or reference the rest_framework_swagger directory into the cigar_example folder. Install the required packages using pip install -r requirements.txt

Screenshots

Bugs & Contributions

Please report bugs by opening an issue

Contributions are welcome and are encouraged !

Special Thanks

Thanks to BNOTIONS for sponsoring initial development time.

Many thanks to Tom Christie & all the contributors who have developed Django REST Framework

Contributors
Django REST Framework Docs contributors:
Release Notes:
v0.1.14 (March 7, 2014)
v0.1.13 (Feb 25, 2014)
v0.1.12 (Feb 24, 2014)
v0.1.11 (Dec 1, 2013)
v0.1.10 (Nov 23, 2013)
v0.1.9 (Oct 1, 2013)
v0.1.8 (Sept 16, 2013)
v0.1.7 (Sept 4, 2013)
v0.1.6 (August 3, 2013)
v0.1.5 (July 30, 2013)
License

Copyright (c) 2013, Marc Gibbons All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.