Middleware for Labstack Echo that integrates Stoplight Elements to provide an interactive OpenAPI documentation interface.
This project is in early development, has no stable release, and is not ready for production use.
- Serve OpenAPI documentation using Stoplight Elements
- Easy integration with Echo applications
- Supports both JSON and YAML OpenAPI specifications
go get github.com/k3env/elements-echoWith embedded spec
package main
import (
"embed""github.com/labstack/echo/v4"
elements "github.com/k3env/elements-echo"
)
//go:embed all:docsvarembedFs embed.FSfuncmain() {
e:=echo.New()
middleware:=elements.New("/openapi")
middleware, err:=middleware.UseEmbed(embedFs, "docs/swagger.yaml")
iferr!=nil {
e.Logger.Fatal(err)
}
// Register the middleware to serve OpenAPI documentatione.Use(middleware.Handle())
e.Logger.Fatal(e.Start(":8080"))
}With spec from fs
package main
import (
"github.com/labstack/echo/v4"
elements "github.com/k3env/elements-echo"
)
funcmain() {
e:=echo.New()
middleware:=elements.New("/openapi")
middleware, err:=middleware.UseSpecFile("docs/swagger.yaml")
iferr!=nil {
e.Logger.Fatal(err)
}
// Register the middleware to serve OpenAPI documentatione.Use(middleware.Handle())
e.Logger.Fatal(e.Start(":8080"))
}Initializes the middleware with supplied route.