Skip to main content

Tools for writing and generating API documentation for edX REST APIs

Project description

PyPI Travis Codecov Documentation Supported License

A toolkit for documenting REST APIs that are created with DRF.

The tools use drf-yasg (DRF, yet another Swagger generator) to generate an OpenAPI Specification, which is a .json/.yaml file that describes your API. Additionally, this package makes it easy to configure your service to expose generated OpenAPI specification under /api-docs.yaml and to serve interactive documentation under /api-docs.

This library is intended for use with Open edX services, but could be used to document any Django REST Framework API.

Quick Start

First, add edx-api-doc-tools to your requirements and install it into your environment.

Next, add the following to your list of installed apps in Django settings:

    ... # your other installed apps

Then, in

from edx_api_doc_tools import make_api_info, make_docs_urls
api_info = make_api_info(title="Registrar API", version="v2")
urlpatterns += make_docs_urls(api_info)

Your should now be able to load the Swagger UI in a browser at https://${your_service}/api-docs. Note that by default, documentation is only generated for views under the root path /api. Generation for other views is possible but requires some extra configuration.

Finally, you can enrich the generated documentation:

from edx_api_doc_tools import parameter, schema
class MyView(APIView):

            parameter('min_date', str, 'Filter response by minimum date.'),
            403: 'User lacks required permission.'
            404: 'Resource does not exist.'
            # Note that 2xx response is automatically figured out by drf-yasg,
            # with reponse schema coming from the serializer, if declared.
    def get(self, request):
        Get the resource.

        This docstring will be used in the OpenAPI spec, and *supports Markdown!*


Comphrehensive documentation is coming soon. For now, check out the example/ directory, which shows a fake API using these tools to generate documentation.


The code in this repository is licensed under the Apache Software License 2.0 unless otherwise noted.

Please see LICENSE.txt for details.

How To Contribute

Contributions are very welcome.

Please read How To Contribute for details.

Even though they were written with edx-platform in mind, the guidelines should be followed for Open edX code in general.

The pull request description template should be automatically applied if you are creating a pull request from GitHub. Otherwise you can find it at

The issue report template should be automatically applied if you are creating an issue on GitHub as well. Otherwise you can find it at

Reporting Security Issues

Please do not report security issues in public. Please email

Getting Help

Have a question about this repository, or about Open edX in general? Please refer to this list of resources if you need any assistance.

Change Log


1.0.2 — 2020-01-17


  • First release on PyPI.

Project details

Release history Release notifications

Download files

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

Files for edx-api-doc-tools, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size edx_api_doc_tools-1.0.2-py2.py3-none-any.whl (14.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size edx-api-doc-tools-1.0.2.tar.gz (13.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page