Small CLI utility for opening an OpenAPI specification in a bundled Swagger UI.
The tool starts a local HTTP server on 127.0.0.1 using a free random port,
serves the selected spec file, and opens the Swagger UI page in the default
browser.
swagger-viewer accepts OpenAPI/Swagger specs with these extensions:
.json.yaml.yml
When no explicit path is provided, it searches the current directory recursively for one of these common filenames:
openapi.json,openapi.yaml,openapi.ymlswagger.json,swagger.yaml,swagger.ymlspec.json,spec.yaml,spec.yml
go install github.com/d1vbyz3r0/swagger-viewer@latestOr build a local binary:
go build -o swagger-viewer .Run in a directory that contains an OpenAPI spec:
swagger-viewerSearch for a spec in a specific directory:
swagger-viewer -dir ./apiOpen a specific spec file:
swagger-viewer -file ./api/openapi.yaml