I am using Django & DRF to write REST APIs. Recently I integrated django-rest-framework-swagger to automatically populate the API docs.
Today, I came across swagger-ui template [https://github.com/jensoleg/swagger-ui] and now want to replace default swagger theme with this one.
What I tried already?
I copied all the contents of the dist directory into /venv/lib/python2.7/site-packages/rest_framework_swagger/static/rest_framework_swagger directory. But it didn't work (UI doesn't look good at all).
To customize django-rest-swagger ui template, all you need to do is include
rest_framework_swagger/index.html
in your root template directory. In my case, I had all of this under my owntemplates
directory which was just the under the actual project folder.This
index.html
file should look similar to this:To see their already existing template:
This library code is found in
rest_framework_swagger/base.html
and theirrest_framework_swagger/index.html
simply looks like this:NOTE: This solution works well with rest_framework_swagger 0.3.x. Their latest rest_framework_swagger (2.x), has a breaking change and I strongly recommend not to use it as you cannot do much customizations (eg. can't use YAML strings). I am using 0.3.x for my project and it's working absolutely fine.