Cross-platform Swagger UI built with golang with only a fat binary, which can help you serve your swagger documentation with only one command.
Download the latest release for your system on release page.
Start a swagger documentation server on port 8000
for /path/to/your/swagger.json
:
$ swaggerui -l "0.0.0.0:8000" -f "/path/to/your/swagger.json"
Everyone can read your documentation on http://your.ip.address:8000
, you can also view other online swagger file, such as swagger's petstore,
by opening
http://your.ip.address:8000/?url=http://petstore.swagger.io/v2/swagger.json
or serve a local swagger files folder defined with -d
flag, such as /swagger
as pre-defined, then you can view the path/to/my-awesome-api.yaml
file in this folder by opening
http://your.ip.address:8000/?file=path/to/my-awesome-api.yaml
you can also replace the default API host endpoint with host
query for local host swagger file
http://your.ip.address:8000/?file=path/to/my-awesome-api.yaml&host=www.new.host
To make it as a daemon:
$ swaggerui -s install -l "0.0.0.0:8000" -f "/path/to/your/swagger.json"
$ swaggerui -s start
which could run in background and auto-start with your system.
More detailed usage:
Usage of swaggerui:
-b enable the topbar
-d string
swagger files vhost dir (default "/swagger")
-f string
swagger url or local file path (default "http://petstore.swagger.io/v2/swagger.json")
-l string
server's listening Address (default ":8080")
-s string
Send signal to a master process: install, remove, start, stop, status (default "status")
Source code is written in go, make and xxd is also needed to build the binary.
The Swagger UI's HTML pages in dist folder is copied from the original Swagger UI Source, then converted into bytes array in file static/static.go using xxd
command, to re-build it
$ make static
By typing the following command, you can get the cross platform distributions of this program
$ make release