Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ go.work.sum
# Editor/IDE
# .idea/
# .vscode/

_examples/auth/auth
_examples/auto_params/demo
_examples/custom_validation_error/custom_validation_error_example
_examples/simple/simple
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,30 @@ A Go library that extends Fiber to add automatic OpenAPI documentation generatio
## Installation

```bash
go get github.com/labbs/fiber-oapi
go get github.com/labbs/fiber-oapi/v3
```

> **Upgrading from v1.x?** v3 tracks Fiber v3 and requires Go 1.26+. Two breaking changes to be aware of:
> - Handlers now take `fiber.Ctx` (struct value) instead of `*fiber.Ctx`.
> - The path-parameter struct tag is now `uri:` instead of `path:` (Fiber v3 binder convention). Query and header tags are unchanged.

## Quick Start

```go
package main

import (
"github.com/gofiber/fiber/v2"
fiberoapi "github.com/labbs/fiber-oapi"
"github.com/gofiber/fiber/v3"
fiberoapi "github.com/labbs/fiber-oapi/v3"
)

func main() {
app := fiber.New()
oapi := fiberoapi.New(app)

fiberoapi.Get(oapi, "/hello/:name",
func(c *fiber.Ctx, input struct {
Name string `path:"name" validate:"required,min=2"`
func(c fiber.Ctx, input struct {
Name string `uri:"name" validate:"required,min=2"`
}) (fiber.Map, *fiberoapi.ErrorResponse) {
return fiber.Map{"message": "Hello " + input.Name}, nil
},
Expand Down Expand Up @@ -98,7 +102,7 @@ fiberoapi.Method(method, router, path, handler, options) // Custom HTTP method

```go
type MyInput struct {
ID string `path:"id" validate:"required"` // Path parameter
ID string `uri:"id" validate:"required"` // Path parameter
Filter string `query:"filter" validate:"omitempty"` // Query parameter
Auth string `header:"Authorization"` // Header parameter
Title string `json:"title" validate:"required,min=1"` // JSON body field
Expand Down Expand Up @@ -286,7 +290,7 @@ fiberoapi.Put(oapi, "/documents/:id", handler,

// Resource-based access via struct tags
type UpdateDocInput struct {
DocumentID string `path:"documentId" validate:"required" resource:"document" action:"write"`
DocumentID string `uri:"documentId" validate:"required" resource:"document" action:"write"`
Title string `json:"title" validate:"required"`
}

Expand All @@ -299,7 +303,7 @@ fiberoapi.RequireResourceAccess(c, authService, "document", docID, "delete")
Access the authenticated user in handlers:

```go
fiberoapi.Get(oapi, "/me", func(c *fiber.Ctx, input struct{}) (fiber.Map, *fiberoapi.ErrorResponse) {
fiberoapi.Get(oapi, "/me", func(c fiber.Ctx, input struct{}) (fiber.Map, *fiberoapi.ErrorResponse) {
authCtx, err := fiberoapi.GetAuthContext(c)
if err != nil {
return nil, &fiberoapi.ErrorResponse{Code: 401, Details: "Not authenticated"}
Expand All @@ -319,7 +323,7 @@ fiberoapi.Get(oapi, "/me", func(c *fiber.Ctx, input struct{}) (fiber.Map, *fiber

```go
oapi := fiberoapi.New(app, fiberoapi.Config{
ValidationErrorHandler: func(c *fiber.Ctx, err error) error {
ValidationErrorHandler: func(c fiber.Ctx, err error) error {
return c.Status(400).JSON(fiber.Map{
"success": false,
"error": err.Error(),
Expand All @@ -334,7 +338,7 @@ oapi := fiberoapi.New(app, fiberoapi.Config{
oapi := fiberoapi.New(app, fiberoapi.Config{
EnableAuthorization: true,
AuthService: authService,
AuthErrorHandler: func(c *fiber.Ctx, err *fiberoapi.AuthError) error {
AuthErrorHandler: func(c fiber.Ctx, err *fiberoapi.AuthError) error {
// err.StatusCode: 401, 403, or 5xx
// err.Message: human-readable error message
return c.Status(err.StatusCode).JSON(fiber.Map{
Expand Down
29 changes: 16 additions & 13 deletions _examples/auth/go.mod
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
module auth

go 1.25.0
go 1.26.0

replace github.com/Labbs/fiber-oapi => ../../
replace github.com/labbs/fiber-oapi/v3 => ../../

require (
github.com/Labbs/fiber-oapi v0.0.0-00010101000000-000000000000
github.com/gofiber/fiber/v2 v2.52.13
github.com/gofiber/fiber/v3 v3.3.0
github.com/labbs/fiber-oapi/v3 v3.0.0-00010101000000-000000000000
)

require (
github.com/andybalholm/brotli v1.2.0 // indirect
github.com/andybalholm/brotli v1.2.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.30.2 // indirect
github.com/gofiber/schema v1.7.1 // indirect
github.com/gofiber/utils/v2 v2.0.6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/compress v1.18.6 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.17 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/tinylib/msgp v1.6.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.66.0 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.35.0 // indirect
github.com/valyala/fasthttp v1.71.0 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
54 changes: 32 additions & 22 deletions _examples/auth/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/andybalholm/brotli v1.2.1 h1:R+f5xP285VArJDRgowrfb9DqL18yVK0gKAW/F+eTWro=
github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fxamacker/cbor/v2 v2.9.2 h1:X4Ksno9+x3cz0TZv69ec1hxP/+tymuR8PXQJyDwfh78=
github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
Expand All @@ -12,40 +14,48 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.30.2 h1:JiFIMtSSHb2/XBUbWM4i/MpeQm9ZK2xqPNk8vgvu5JQ=
github.com/go-playground/validator/v10 v10.30.2/go.mod h1:mAf2pIOVXjTEBrwUMGKkCWKKPs9NheYGabeB04txQSc=
github.com/gofiber/fiber/v2 v2.52.13 h1:TOKP64iqC9b5P49VrBW5tHhUOvDyrtJ0xePEfzJbCbk=
github.com/gofiber/fiber/v2 v2.52.13/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
github.com/gofiber/fiber/v3 v3.3.0 h1:QBd3sYCqdy6Qs5gJYzSw4I4SbqL204jPqpdub/ueiw8=
github.com/gofiber/fiber/v3 v3.3.0/go.mod h1:YH7/TAoRaU4kF8slDCtQuFJ1NzC+3MtxUI4KfvQtaIA=
github.com/gofiber/schema v1.7.1 h1:oSJBKdgP8JeIME4TQSAqlNKTU2iBB+2RNmKi8Nsc+TI=
github.com/gofiber/schema v1.7.1/go.mod h1:A/X5Ffyru4p9eBdp99qu+nzviHzQiZ7odLT+TwxWhbk=
github.com/gofiber/utils/v2 v2.0.6 h1:7fXYy7nSsyqbH0GQUMtK4Kwjy4J7R5742VM7JsZxzOs=
github.com/gofiber/utils/v2 v2.0.6/go.mod h1:p7mAHAk3+oUK10ZX2xTw9fZQixb4hCg8SKd4IH2xroU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.17 h1:78v8ZlW0bP43XfmAfPsdXcoNCelfMHsDmd/pkENfrjQ=
github.com/mattn/go-runewidth v0.0.17/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/shamaton/msgpack/v3 v3.1.2 h1:d5gWAIyMU4M0WgDjz6IFSCuXJUA2dFwRHBpDclE8CLw=
github.com/shamaton/msgpack/v3 v3.1.2/go.mod h1:DcQG8jrdrQCIxr3HlMYkiXdMhK+KfN2CitkyzsQV4uc=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tinylib/msgp v1.6.4 h1:mOwYbyYDLPj35mkA2BjjYejgJk9BuHxDdvRnb6v2ZcQ=
github.com/tinylib/msgp v1.6.4/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.66.0 h1:M87A0Z7EayeyNaV6pfO3tUTUiYO0dZfEJnRGXTVNuyU=
github.com/valyala/fasthttp v1.66.0/go.mod h1:Y4eC+zwoocmXSVCB1JmhNbYtS7tZPRI2ztPB72EVObs=
github.com/valyala/fasthttp v1.71.0 h1:tepR7H+Guh9VUqxxcPggYi8R3lGUu2Rsdh+z7/FCY3k=
github.com/valyala/fasthttp v1.71.0/go.mod h1:z1sDUvOShhXq/C9mwH/fSm1Vb71tUJwmQdgkBrBNwnA=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
26 changes: 13 additions & 13 deletions _examples/auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"time"

fiberoapi "github.com/Labbs/fiber-oapi"
"github.com/gofiber/fiber/v2"
fiberoapi "github.com/labbs/fiber-oapi/v3"
"github.com/gofiber/fiber/v3"
)

// Authentication service with role management.
Expand Down Expand Up @@ -197,11 +197,11 @@ type CreateUserResponse struct {
}

type DocumentRequest struct {
DocumentID string `path:"documentId" validate:"required"`
DocumentID string `uri:"documentId" validate:"required"`
}

type UpdateDocumentRequest struct {
DocumentID string `path:"documentId" validate:"required"`
DocumentID string `uri:"documentId" validate:"required"`
Title string `json:"title" validate:"required,min=1,max=100"`
Content string `json:"content" validate:"required,min=1"`
}
Expand Down Expand Up @@ -241,7 +241,7 @@ func main() {
EnableAuthorization: true,
AuthService: authService,
// Custom error handler for authentication/authorization errors
AuthErrorHandler: func(c *fiber.Ctx, err *fiberoapi.AuthError) error {
AuthErrorHandler: func(c fiber.Ctx, err *fiberoapi.AuthError) error {
errType := "authentication_error"
if err.StatusCode == 403 {
errType = "authorization_error"
Expand Down Expand Up @@ -290,7 +290,7 @@ func main() {

// ====== ROUTES PUBLIQUES ======
fiberoapi.Get(oapi, "/health",
func(c *fiber.Ctx, input struct{}) (map[string]string, *fiberoapi.ErrorResponse) {
func(c fiber.Ctx, input struct{}) (map[string]string, *fiberoapi.ErrorResponse) {
return map[string]string{
"status": "ok",
"service": "fiber-oapi auth example",
Expand All @@ -306,7 +306,7 @@ func main() {

// ====== ROUTES AVEC AUTHENTIFICATION SIMPLE ======
fiberoapi.Get(oapi, "/me",
func(c *fiber.Ctx, input struct{}) (CreateUserResponse, *fiberoapi.ErrorResponse) {
func(c fiber.Ctx, input struct{}) (CreateUserResponse, *fiberoapi.ErrorResponse) {
authCtx, _ := fiberoapi.GetAuthContext(c)
return CreateUserResponse{
ID: 1,
Expand All @@ -322,7 +322,7 @@ func main() {

// Test endpoint with map[string]interface{} response
fiberoapi.Get(oapi, "/status",
func(c *fiber.Ctx, input struct{}) (map[string]interface{}, *fiberoapi.ErrorResponse) {
func(c fiber.Ctx, input struct{}) (map[string]interface{}, *fiberoapi.ErrorResponse) {
authCtx, _ := fiberoapi.GetAuthContext(c)
return map[string]interface{}{
"user_id": authCtx.UserID,
Expand All @@ -348,7 +348,7 @@ func main() {
// RequiredRoles: vérifié automatiquement avant le handler
// RequiredPermissions: documenté dans la spec OpenAPI
fiberoapi.Get(oapi, "/documents/:documentId",
func(c *fiber.Ctx, input DocumentRequest) (DocumentResponse, *fiberoapi.ErrorResponse) {
func(c fiber.Ctx, input DocumentRequest) (DocumentResponse, *fiberoapi.ErrorResponse) {
authCtx, _ := fiberoapi.GetAuthContext(c)
fmt.Printf("📖 User %s (roles: %v) accessing document %s\n", authCtx.UserID, authCtx.Roles, input.DocumentID)

Expand All @@ -369,7 +369,7 @@ func main() {

// Route pour les éditeurs (peuvent modifier)
fiberoapi.Put(oapi, "/documents/:documentId",
func(c *fiber.Ctx, input UpdateDocumentRequest) (DocumentResponse, *fiberoapi.ErrorResponse) {
func(c fiber.Ctx, input UpdateDocumentRequest) (DocumentResponse, *fiberoapi.ErrorResponse) {
authCtx, _ := fiberoapi.GetAuthContext(c)
fmt.Printf("✏️ User %s (scopes: %v) updating document %s\n", authCtx.UserID, authCtx.Scopes, input.DocumentID)

Expand All @@ -390,7 +390,7 @@ func main() {

// Route pour partager (éditeurs seulement)
fiberoapi.Post(oapi, "/documents/:documentId/share",
func(c *fiber.Ctx, input DocumentRequest) (DocumentShareResponse, *fiberoapi.ErrorResponse) {
func(c fiber.Ctx, input DocumentRequest) (DocumentShareResponse, *fiberoapi.ErrorResponse) {
authCtx, _ := fiberoapi.GetAuthContext(c)
fmt.Printf("🔗 User %s sharing document %s\n", authCtx.UserID, input.DocumentID)

Expand All @@ -408,7 +408,7 @@ func main() {

// Route réservée aux administrateurs
fiberoapi.Delete(oapi, "/documents/:documentId",
func(c *fiber.Ctx, input DocumentRequest) (DocumentDeleteResponse, *fiberoapi.ErrorResponse) {
func(c fiber.Ctx, input DocumentRequest) (DocumentDeleteResponse, *fiberoapi.ErrorResponse) {
authCtx, _ := fiberoapi.GetAuthContext(c)
fmt.Printf("🗑️ Admin %s deleting document %s\n", authCtx.UserID, input.DocumentID)

Expand All @@ -426,7 +426,7 @@ func main() {

// Route de création d'utilisateur (admin seulement)
fiberoapi.Post(oapi, "/users",
func(c *fiber.Ctx, input CreateUserRequest) (CreateUserResponse, *fiberoapi.ErrorResponse) {
func(c fiber.Ctx, input CreateUserRequest) (CreateUserResponse, *fiberoapi.ErrorResponse) {
authCtx, _ := fiberoapi.GetAuthContext(c)
fmt.Printf("👤 Admin %s creating user: %s\n", authCtx.UserID, input.Name)

Expand Down
29 changes: 16 additions & 13 deletions _examples/auto_params/go.mod
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
module demo

go 1.25.0
go 1.26.0

replace github.com/labbs/fiber-oapi => ../..
replace github.com/labbs/fiber-oapi/v3 => ../..

require (
github.com/gofiber/fiber/v2 v2.52.13
github.com/labbs/fiber-oapi v0.0.0-00010101000000-000000000000
github.com/gofiber/fiber/v3 v3.3.0
github.com/labbs/fiber-oapi/v3 v3.0.0-00010101000000-000000000000
)

require (
github.com/andybalholm/brotli v1.2.0 // indirect
github.com/andybalholm/brotli v1.2.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.30.2 // indirect
github.com/gofiber/schema v1.7.1 // indirect
github.com/gofiber/utils/v2 v2.0.6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/compress v1.18.6 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.17 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/tinylib/msgp v1.6.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.66.0 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.35.0 // indirect
github.com/valyala/fasthttp v1.71.0 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading