Skip to content

Latest commit

 

History

History
45 lines (27 loc) · 1.2 KB

README.md

File metadata and controls

45 lines (27 loc) · 1.2 KB

Swagger UI

GoDevDoc

Package swgui (Swagger UI) provides HTTP handler to serve Swagger UI. All assets are embedded in Go source code, so just build and run.

Static assets for v3 are built from Swagger UI v3.25.4.

CDN-based v3cdn uses Swagger UI v3.24.2.

How to use

package main

import (
    "net/http"

    "github.com/swaggest/swgui/v3"
)

func main() {
    http.Handle("/", v3.NewHandler("My API", "/swagger.json", "/"))
    http.ListenAndServe(":8080", nil)
}

Use CDN for assets

In order to reduce binary size you can import github.com/swaggest/swgui/v3cdn to use CDN hosted assets.

Also you can use swguicdn build tag to enable CDN mode for github.com/swaggest/swgui/v3 import.

Be aware that CDN mode may be considered inappropriate for security or networking reasons.

Run as standalone server

Install swgui-server

go get github.com/swaggest/swgui/...

Start server

swgui-server -port 8080