package httpapi import ( "net/http" "github.com/gin-gonic/gin" "github.com/swaggest/swgui/v5emb" "codeberg.org/squidd/sonda/internal/api/openapi" ) const ( specPath = "/api/v1/openapi.yaml" docsPath = "/api/docs/" ) // registerDocs serves the OpenAPI spec and a Swagger UI for it. Both are public: // they describe the API and contain no data. The UI's assets are embedded in the // binary, so opening it never contacts another server. func registerDocs(r *gin.Engine, v1 *gin.RouterGroup) { v1.GET("/openapi.yaml", func(c *gin.Context) { c.Header("Cache-Control", "no-cache") c.Data(http.StatusOK, "application/yaml; charset=utf-8", openapi.Spec) }) ui := v5emb.New("Sonda API", specPath, docsPath) r.GET("/api/docs", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, docsPath) }) r.GET("/api/docs/*any", gin.WrapH(ui)) }