Hack Swagger Editor to Provide View-only Mode.
I don't have enough time and nodejs working experience to contribute to Swagger Editor itself, so I just hack it by override the response in nginx.
The community looks not that easy:
- How can I export the HTML of the preview? #623 [ NOT WELCOME HERE ]
- Add a view only mode? #719 [ HACK it yourself ]
- Feature: Preview Only #795 [ IMPLEMENTED BUT REJECTED, WTF! ]
- Install Swagger Editor by docker:
This will run swagger-editor on port 9010
docker pull swaggerapi/swagger-editor docker run -d -p 9010:8080 swaggerapi/swagger-editor
- Copy
nginx
files to your nginx config directory:cp -r nginx/* /etc/nginx
- Change
server_name
androot
ATTENTION: usevim /etc/nginx/sites-enabled/swagger.conf
public
dir as root - Reload nginx
nginx -t && nginx -s reload
If you want to access swagger via https, please:
- Prepare SSL certificate;
- Use
swagger.https.conf
:ln -snf ../sites-available/swagger.https.conf /etc/nginx/sites-enabled/swagger.conf
- Change
ssl_certificate
andssl_certificate_key
to use real certificate; - Generate a dhparam file:
sudo openssl dhparam -out /etc/nginx/ssl/dhparam.pem 4096
- Then reload nginx:
nginx -t && nginx -s reload