noirbizarre / flask-restplus

Fully featured framework for fast, easy and documented API development with Flask
http://flask-restplus.readthedocs.org
Other
2.73k stars 507 forks source link

Alternative swagger theme #407

Open autoferrit opened 6 years ago

autoferrit commented 6 years ago

I am wondering if there would be a way to support alternative swagger themes? Or, how could I override the theme for my app if desired? One I saw that looked nice was this one:

https://github.com/afgarcia86/bootstrap-swagger-ui

but i would have to run that separately from running my restplus app.

hanleilei commented 6 years ago

view the change log, seem the latest version are using version 2.2.6, I tried the latest version of swagger, it can not work, the folder structure are different.

vcolano commented 6 years ago

A bit hacky, but I figured out a way to do this. I'm using one of the themes from http://meostrander.com/swagger-ui-themes/

import flask_restplus
import os
from shutil import copyfile

# Replace default SWAGGER theme with feeling-blue theme
css_dir = os.path.abspath(os.path.join(flask_restplus.__file__, '../static/bower/swagger-ui/dist/css'))
copyfile('themes/2.x/theme-feeling-blue.css_dir', css_dir + '/screen.css')