I have rest api developed using Bottle. Is there any library like swagger-ui which helps to view the documentation and test the apis?
In order to setup swagger documentation for Bottle based rest services: Copy swagger UI files to web container
Clone https://github.com/swagger-api/swagger-ui.git and copy "dist" folder contents to your web container docs resources directory.
For example, if you copy the dist folder contents to docs directory under your bottle project root folder, add the below method to your Bottle Instance to route the requests appropriately.
@app.get('/docs/<filename:re:.*>')
def html(filename):
return static_file(filename, root='docs/')
**Below step is applicable to rest services on any platform. However few frameworks (Java Jersey or Flask) have the below functionalities built-in. Edit the json file
i.e change the below line in index.html to refer to json file which contains the rest service documentation in swagger structure.
url = "http://petstore.swagger.io/v2/swagger.json";
As a starting point for this json refer to http://petstore.swagger.io/v2/swagger.json
That's all we need. Launch
/to view swagger docs.http://<hostname:port>/<path for swagger resources>/index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With