flask-restful-swagger icon indicating copy to clipboard operation
flask-restful-swagger copied to clipboard

How to customize swagger html

Open PabloCastellano opened this issue 10 years ago • 3 comments

Hi.

In a project I want to customize the default swagger web interface. What's the easiest way to do it? I haven't found any documentation.

I could just edit the files in the static/ folder but I wanted to know if there's some mechanism like copying the static folder from this plugin to my root folder and just edit them there.

PabloCastellano avatar Jan 21 '15 10:01 PabloCastellano

+1

hwdavidward avatar Feb 25 '15 16:02 hwdavidward

I have a workaround: I was able to make a directory called swagger inside my flask app's static folder and put the static files from this project in there. Then to use them, you can change render_page function (like 175) to not include the base url. The specific line that needs to be changed is:

with open(os.path.join(rootPath, 'static', page), "r") as fs:

Change it to:

with open(os.path.join('static/swagger', page), "r") as fs:

However, you probably just want to include the rendering as part of your own project so it can have the same look and feel as the rest of your site.

nickvasilyev avatar Nov 19 '15 14:11 nickvasilyev

If the workaround is effective, it may make sense to close this issue off. @nickvasilyev @hwdavidward @PabloCastellano Would you guys like to weigh in?

niall-byrne avatar Jan 05 '16 06:01 niall-byrne