feat(docs): Swagger generation

This commit is contained in:
2024-12-02 17:13:05 +01:00
parent 3f35d35016
commit 491d31e2e9
7 changed files with 189 additions and 7 deletions

View File

@@ -4,8 +4,10 @@ import (
"flag"
"log"
"git.odit.services/lfk/document-server/docs" // Correct import path for docs
"git.odit.services/lfk/document-server/handlers"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/swagger"
)
var (
@@ -13,6 +15,8 @@ var (
prod = flag.Bool("prod", false, "Enable prefork in Production")
)
// @title LfK Document Server API
// @description This is the API documentation for the LfK Document Server - a tool for pdf generation.
func main() {
// Parse command-line flags
flag.Parse()
@@ -22,6 +26,9 @@ func main() {
Prefork: *prod,
})
// Swagger documentation route
app.Get("/swagger/*", swagger.HandlerDefault)
v1 := app.Group("/v1")
v1.Get("/", func(c *fiber.Ctx) error {
@@ -30,6 +37,7 @@ func main() {
v1.Post("/contracts", handlers.GenerateContract)
app.Use(handlers.NotFoundHandler)
docs.SwaggerInfo.BasePath = "/"
log.Fatal(app.Listen(*port))
}