Skip to content

Latest commit

 

History

History
116 lines (68 loc) · 3.33 KB

README.md

File metadata and controls

116 lines (68 loc) · 3.33 KB

Concentric Sky

Django Tastypie Swagger

django-tastypie-swagger is a small adapter library to construct Swagger documentation from Tastypie resources.

This package provides two things:

  1. An embedded instance of Swagger UI to point a URL to.
  2. Automatic Resource Listing and API Declaration generation that is consumed by #1

Table of Contents

Version History

  • v0.1.3 Various bug fixes and documentation updates
  • v0.1.2 Fixes for Django 1.5 compatibility
  • v0.1.1 Public codebase was released

Documentation

Detailed documentation is available on Read The Docs.

Installation

Install package::

pip install django-tastypie-swagger

Add to INSTALLED_APPS::

INSTALLED_APPS = [
    ...

    'tastypie_swagger',

    ...
]

Getting Started

Enable documentation for an api endpoint by adding a URL to your urlpatterns.

eg::

urlpatterns = patterns('',
    ...

    url(r'api/myapi/doc/',
      include('tastypie_swagger.urls', namespace='myapi_tastypie_swagger'),
      kwargs={"tastypie_api_module":"myapp.registration.my_api", "namespace":"myapi_tastypie_swagger"}
    ),

    ...
)

To declare more than one endpoint, repeat the above URL definition and change the namespace.

Swagger documentation will be served up at the URL(s) you configured.

Swagger V1 v.s. V2

The following URI are according to Swagger Spec 1.2:

* `/resources/`
* `/schema/`
* `/schema/<resource_name>`

The Swagger Spec V2.0 compliant swagger.json is served at the following URLs. Both URLs return the same content.

* `/specs/` 
* `/specs/swagger.json`  

Note that the V2 specs are generated by mapping the V1 output to V2. This ensures that existing Tastypie Apis continue to work unmodified.

Testing

The example folder contains a Django app to test tastypie-swagger. Run tests as follows:

$ cd /path/to/tastypie_swagger
$ pip install -r requirements.txt
$ cd example
$ manage.py test

Contributors

Contributors to this project are listed in the CONTRIBUTORS.md file. If you contribute to this project, please add your name to the file.

License

This project is licensed under the Apache License, Version 2.0. Details can be found in the LICENSE.md file. License for third-party code is available in 3RDPARTYLICENSES.md.

About Concentric Sky

For nearly a decade, Concentric Sky has been building technology solutions that impact people everywhere. We work in the mobile, enterprise and web application spaces. Our team, based in Eugene Oregon, loves to solve complex problems. Concentric Sky believes in contributing back to our community and one of the ways we do that is by open sourcing our code on GitHub. Contact Concentric Sky at [email protected].