feat: add OpenAPI definition

This commit is contained in:
Sam 2023-05-19 04:50:11 +02:00
parent c3291edd4f
commit e0d08270bf
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
3 changed files with 1471 additions and 0 deletions

View file

@ -1,6 +1,8 @@
package backend
import (
"net/http"
"codeberg.org/u1f320/pronouns.cc/backend/routes/auth"
"codeberg.org/u1f320/pronouns.cc/backend/routes/bot"
"codeberg.org/u1f320/pronouns.cc/backend/routes/member"
@ -9,8 +11,14 @@ import (
"codeberg.org/u1f320/pronouns.cc/backend/routes/user"
"codeberg.org/u1f320/pronouns.cc/backend/server"
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
_ "embed"
)
//go:embed openapi.html
var openapi string
// mountRoutes mounts all API routes on the server's router.
// they are all mounted under /v1/
func mountRoutes(s *server.Server) {
@ -23,4 +31,9 @@ func mountRoutes(s *server.Server) {
meta.Mount(s, r)
mod.Mount(s, r)
})
// API docs
s.Router.Get("/", func(w http.ResponseWriter, r *http.Request) {
render.HTML(w, r, openapi)
})
}