Skip to content

Commit

Permalink
Add Swagger Docs for All Endpoints (#230)
Browse files Browse the repository at this point in the history
Co-authored-by: Alder Whiteford <[email protected]>
Co-authored-by: Garrett Ladley <[email protected]>
Co-authored-by: garrettladley <[email protected]>
  • Loading branch information
4 people authored Feb 21, 2024
1 parent 5c5fc20 commit 58ce174
Show file tree
Hide file tree
Showing 25 changed files with 9,761 additions and 1,019 deletions.
13 changes: 5 additions & 8 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ require (

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/spec v0.20.14 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down Expand Up @@ -76,8 +74,7 @@ require (
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/tools v0.18.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
31 changes: 4 additions & 27 deletions backend/go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/awnumar/memcall v0.2.0 h1:sRaogqExTOOkkNwO9pzJsL8jrOV29UuUW7teRMfbqtI=
github.com/awnumar/memcall v0.2.0/go.mod h1:S911igBPR9CThzd/hYQQmTc9SWNu3ZHIlCGaWsWsoJo=
github.com/awnumar/memguard v0.22.4 h1:1PLgKcgGPeExPHL8dCOWGVjIbQUBgJv9OL0F/yE1PqQ=
github.com/awnumar/memguard v0.22.4/go.mod h1:+APmZGThMBWjnMlKiSM1X7MVpbIVewen2MTkqWkA/zE=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down Expand Up @@ -77,11 +72,8 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM=
github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
Expand All @@ -106,7 +98,6 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -134,7 +125,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
Expand All @@ -160,39 +150,26 @@ golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/postgres v1.5.6 h1:ydr9xEd5YAM0vxVDY0X139dyzNz10spDiDlC7+ibLeU=
Expand Down
59 changes: 33 additions & 26 deletions backend/src/controllers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ func NewAuthController(authService services.AuthServiceInterface, authSettings c

// Me godoc
//
// @Summary Gets the current user
// @Description Returns the current user
// @Summary Retrieve the current user given an auth session
// @Description Returns the current user associated with an auth session
// @ID get-current-user
// @Tags user
// @Tags auth
// @Produce json
// @Success 200 {object} models.User
// @Failure 401 {string} string "failed to get current user"
// @Router /api/v1/auth/me [get]
// @Success 200 {object} models.User
// @Failure 400 {object} errors.Error
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /auth/me [get]
func (a *AuthController) Me(c *fiber.Ctx) error {
claims, err := auth.From(c)
if err != nil {
Expand All @@ -50,14 +53,15 @@ func (a *AuthController) Me(c *fiber.Ctx) error {
// @Summary Logs in a user
// @Description Logs in a user
// @ID login-user
// @Tags user
// @Tags auth
// @Accept json
// @Produce json
// @Param userBody body []string true "User Body"
// @Success 200 {object} string "success"
// @Failure 400 {string} string "failed to parse body"
// @Failure 401 {string} string "failed to login user"
// @Router /api/v1/auth/login [post]
// @Param loginBody body models.LoginUserResponseBody true "Login Body"
// @Success 200 {object} utilities.SuccessResponse
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /auth/login [post]
func (a *AuthController) Login(c *fiber.Ctx) error {
var userBody models.LoginUserResponseBody

Expand Down Expand Up @@ -87,12 +91,14 @@ func (a *AuthController) Login(c *fiber.Ctx) error {
// @Summary Refreshes a user's access token
// @Description Refreshes a user's access token
// @ID refresh-user
// @Tags user
// @Tags auth
// @Accept json
// @Produce json
// @Success 200 {object} string "success"
// @Failure 401 {string} string "failed to refresh access token"
// @Router /api/v1/auth/refresh [get]
// @Success 200 {object} utilities.SuccessResponse
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /auth/refresh [get]
func (a *AuthController) Refresh(c *fiber.Ctx) error {
// Extract token values from cookies
refreshTokenValue := c.Cookies("refresh_token")
Expand Down Expand Up @@ -124,12 +130,11 @@ func (a *AuthController) Refresh(c *fiber.Ctx) error {
// @Summary Logs out a user
// @Description Logs out a user
// @ID logout-user
// @Tags user
// @Tags auth
// @Accept json
// @Produce json
// @Success 200 {object} string
// @Failure 401 {string} string "failed to logout user"
// @Router /api/v1/auth/logout [get]
// @Success 200 {object} utilities.SuccessResponse
// @Router /auth/logout [get]
func (a *AuthController) Logout(c *fiber.Ctx) error {
// Extract token values from cookies
accessTokenValue := c.Cookies("access_token")
Expand All @@ -151,14 +156,16 @@ func (a *AuthController) Logout(c *fiber.Ctx) error {
// @Summary Updates a user's password
// @Description Updates a user's password
// @ID update-password
// @Tags user
// @Tags auth
// @Accept json
// @Produce json
// @Param userBody body []string true "User Body"
// @Success 200 {object} string "success"
// @Failure 400 {string} string "failed to parse body"
// @Failure 401 {string} string "failed to update password"
// @Router /api/v1/auth/update-password [post]
// @Param userBody body models.UpdatePasswordRequestBody true "User Body"
// @Success 200 {object} utilities.SuccessResponse
// @Failure 400 {object} errors.Error
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /auth/update-password [post]
func (a *AuthController) UpdatePassword(c *fiber.Ctx) error {
var userBody models.UpdatePasswordRequestBody

Expand Down
74 changes: 42 additions & 32 deletions backend/src/controllers/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ func NewCategoryController(categoryService services.CategoryServiceInterface) *C

// CreateCategory godoc
//
// @Summary Create a category
// @Description Creates a category that is used to group tags
// @Summary Creates a category
// @Description Creates a category
// @ID create-category
// @Tags category
// @Accept json
// @Produce json
// @Param categoryBody body models.CategoryRequestBody true "Category Body"
// @Success 201 {object} models.Category
// @Failure 400 {string} string "failed to process the request"
// @Failure 400 {string} string "failed to validate data"
// @Failure 400 {string} string "category with that name already exists"
// @Failure 500 {string} string "failed to create category"
// @Router /api/v1/category/ [post]
// @Failure 400 {string} errors.Error
// @Failure 401 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/ [post]
func (cat *CategoryController) CreateCategory(c *fiber.Ctx) error {
var categoryBody models.CategoryRequestBody

Expand All @@ -49,13 +51,17 @@ func (cat *CategoryController) CreateCategory(c *fiber.Ctx) error {
// GetCategories godoc
//
// @Summary Retrieve all categories
// @Description Retrieves all existing categories
// @Description Retrieves all categories
// @ID get-categories
// @Tags category
// @Produce json
// @Success 200 {object} []models.Category
// @Failure 500 {string} string "unable to retrieve categories"
// @Router /api/v1/category/ [get]
// @Param limit query int false "Limit"
// @Param page query int false "Page"
// @Success 200 {object} []models.Category
// @Failure 400 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/ [get]
func (cat *CategoryController) GetCategories(c *fiber.Ctx) error {
defaultLimit := 10
defaultPage := 1
Expand All @@ -71,16 +77,16 @@ func (cat *CategoryController) GetCategories(c *fiber.Ctx) error {
// GetCategory godoc
//
// @Summary Retrieve a category
// @Description Retrieve a category by its ID
// @Description Retrieves a category
// @ID get-category
// @Tags category
// @Produce json
// @Param id path string true "Category ID"
// @Success 200 {object} models.Category
// @Failure 400 {string} string "failed to validate id"
// @Failure 404 {string} string "faied to find category"
// @Failure 500 {string} string "failed to retrieve category"
// @Router /api/v1/category/{id} [get]
// @Param categoryID path string true "Category ID"
// @Success 200 {object} models.Category
// @Failure 400 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/{categoryID} [get]
func (cat *CategoryController) GetCategory(c *fiber.Ctx) error {
category, err := cat.categoryService.GetCategory(c.Params("categoryID"))
if err != nil {
Expand All @@ -92,17 +98,18 @@ func (cat *CategoryController) GetCategory(c *fiber.Ctx) error {

// DeleteCategory godoc
//
// @Summary Delete a category
// @Description Delete a category by ID
// @Summary Deletes a category
// @Description Deletes a category
// @ID delete-category
// @Tags category
// @Produce json
// @Param id path string true "Category ID"
// @Success 204 {string} string "no content"
// @Failure 400 {string} string "failed to validate id"
// @Failure 404 {string} string "failed to find category"
// @Failure 500 {string} string "failed to delete category"
// @Router /api/v1/category/{id} [delete]
// @Param categoryID path string true "Category ID"
// @Success 204 {string} utilities.SuccessResponse
// @Failure 400 {string} errors.Error
// @Failure 401 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/{categoryID} [delete]
func (cat *CategoryController) DeleteCategory(c *fiber.Ctx) error {
if err := cat.categoryService.DeleteCategory(c.Params("categoryID")); err != nil {
return err.FiberError(c)
Expand All @@ -117,13 +124,16 @@ func (cat *CategoryController) DeleteCategory(c *fiber.Ctx) error {
// @Description Updates a category
// @ID update-category
// @Tags category
// @Accept json
// @Produce json
// @Param id path string true "Category ID"
// @Success 200 {object} models.Category
// @Failure 400 {string} string "failed to validate id"
// @Failure 404 {string} string "failed to find category"
// @Failure 500 {string} string "failed to update category"
// @Router /api/v1/category/{id} [patch]
// @Param categoryID path string true "Category ID"
// @Param categoryBody body models.CategoryRequestBody true "Category Body"
// @Success 200 {object} models.Category
// @Failure 400 {string} errors.Error
// @Failure 401 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/{categoryID} [put]
func (cat *CategoryController) UpdateCategory(c *fiber.Ctx) error {
var category models.CategoryRequestBody

Expand Down
Loading

0 comments on commit 58ce174

Please sign in to comment.