go-redoc
is an embedded OpenAPI documentation ui for Go using ReDoc and 1.16's embed, with middleware implementations for: net/http
, gin
and echo
. The template is based on the ReDoc's bundle template with the script already placed in the html instead of depending on a cdn.
import "github.com/Kotodian/go-redoc"
...
doc := redoc.Redoc{
Title: "Example API",
Description: "Example API Description",
SpecFile: "./openapi.json",
SpecPath: "/openapi.json",
DocsPath: "/docs",
}
net/http
import (
"net/http"
"github.com/Kotodian/go-redoc"
)
...
http.ListenAndServe(address, doc.Handler())
gin
import (
"github.com/gin-gonic/gin"
"github.com/Kotodian/go-redoc"
ginredoc "github.com/Kotodian/go-redoc/gin"
)
...
r := gin.New()
r.Use(ginredoc.New(doc))
echo
import (
"github.com/labstack/echo/v4"
"github.com/Kotodian/go-redoc"
echoredoc "github.com/Kotodian/go-redoc/echo"
)
...
r := echo.New()
r.Use(echoredoc.New(doc))
See examples