Skip to content

Commit

Permalink
minor updates completed swagger docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOduneye committed Feb 25, 2024
1 parent aa8dfeb commit 1d4ddd8
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 209 deletions.
7 changes: 4 additions & 3 deletions backend/src/controllers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (a *AuthController) Refresh(c *fiber.Ctx) error {
return errors.Unauthorized.FiberError(c)
}

// Set the access token in the response (e.g., in a cookie or JSON response)
// Set the access token in the response
c.Cookie(auth.CreateCookie("access_token", *accessToken, time.Now().Add(time.Minute*60)))

return utilities.FiberMessage(c, fiber.StatusOK, "success")
Expand Down Expand Up @@ -159,14 +159,15 @@ func (a *AuthController) Logout(c *fiber.Ctx) error {
// @Tags auth
// @Accept json
// @Produce json
// @Param userID path string true "User ID"
// @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 429 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Failure 429 {object}
// @Router /auth/update-password/:userID [post]
// @Router /auth/update-password/{userID} [post]
func (a *AuthController) UpdatePassword(c *fiber.Ctx) error {
var userBody models.UpdatePasswordRequestBody

Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/club.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewClubController(clubService services.ClubServiceInterface) *ClubControlle
// @Failure 400 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /clubs/ [get]
func (cl *ClubController) GetAllClubs(c *fiber.Ctx) error {
func (cl *ClubController) GetClubs(c *fiber.Ctx) error {
var queryParams models.ClubQueryParams

queryParams.Limit = 10 // default limit
Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/user_follower.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (uf *UserFollowerController) DeleteFollowing(c *fiber.Ctx) error {
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /users/{userID}/follower/ [get]
func (uf *UserFollowerController) GetAllFollowing(c *fiber.Ctx) error {
func (uf *UserFollowerController) GetFollowing(c *fiber.Ctx) error {
clubs, err := uf.userFollowerService.GetFollowing(c.Params("userID"))
if err != nil {
return err.FiberError(c)
Expand Down
98 changes: 23 additions & 75 deletions backend/src/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ const docTemplate = `{
},
"/auth/me": {
"get": {
"security": [
{
"cookie": []
}
],
"description": "Returns the current user associated with an auth session",
"produces": [
"application/json"
Expand Down Expand Up @@ -187,7 +182,7 @@ const docTemplate = `{
}
}
},
"/auth/update-password/:userID": {
"/auth/update-password/{userID}": {
"post": {
"description": "Updates a user's password",
"consumes": [
Expand All @@ -202,6 +197,13 @@ const docTemplate = `{
"summary": "Updates a user's password",
"operationId": "update-password",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "userID",
"in": "path",
"required": true
},
{
"description": "User Body",
"name": "userBody",
Expand Down Expand Up @@ -237,6 +239,12 @@ const docTemplate = `{
"$ref": "#/definitions/errors.Error"
}
},
"429": {
"description": "Too Many Requests",
"schema": {
"$ref": "#/definitions/errors.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
Expand Down Expand Up @@ -2122,8 +2130,8 @@ const docTemplate = `{
}
}
},
"/tags/": {
"post": {
"/tags": {
"get": {
"description": "Retrieves all tags",
"produces": [
"application/json"
Expand Down Expand Up @@ -2284,70 +2292,6 @@ const docTemplate = `{
}
}
},
"put": {
"description": "Updates a tag",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"tag"
],
"summary": "Update a tag",
"operationId": "update-tag",
"parameters": [
{
"type": "string",
"description": "Tag ID",
"name": "tagID",
"in": "path",
"required": true
},
{
"description": "Tag",
"name": "tag",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.UpdateTagRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Tag"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/errors.Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/errors.Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/errors.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/errors.Error"
}
}
}
},
"delete": {
"description": "Deletes a tag",
"produces": [
Expand Down Expand Up @@ -2427,7 +2371,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.TagRequestBody"
"$ref": "#/definitions/models.UpdateTagRequestBody"
}
}
],
Expand Down Expand Up @@ -4037,10 +3981,14 @@ const docTemplate = `{
],
"properties": {
"new_password": {
"type": "string"
"type": "string",
"maxLength": 255,
"minLength": 8
},
"old_password": {
"type": "string"
"type": "string",
"maxLength": 255,
"minLength": 8
}
}
},
Expand Down
101 changes: 26 additions & 75 deletions backend/src/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"version": "1.0"
},
"host": "127.0.0.1:8080",
"schemes": [
"http"
],
"basePath": "/api/v1",
"paths": {
"/auth/login": {
Expand Down Expand Up @@ -91,11 +94,6 @@
},
"/auth/me": {
"get": {
"security": [
{
"cookie": []
}
],
"description": "Returns the current user associated with an auth session",
"produces": [
"application/json"
Expand Down Expand Up @@ -181,7 +179,7 @@
}
}
},
"/auth/update-password/:userID": {
"/auth/update-password/{userID}": {
"post": {
"description": "Updates a user's password",
"consumes": [
Expand All @@ -196,6 +194,13 @@
"summary": "Updates a user's password",
"operationId": "update-password",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "userID",
"in": "path",
"required": true
},
{
"description": "User Body",
"name": "userBody",
Expand Down Expand Up @@ -231,6 +236,12 @@
"$ref": "#/definitions/errors.Error"
}
},
"429": {
"description": "Too Many Requests",
"schema": {
"$ref": "#/definitions/errors.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
Expand Down Expand Up @@ -2116,8 +2127,8 @@
}
}
},
"/tags/": {
"post": {
"/tags": {
"get": {
"description": "Retrieves all tags",
"produces": [
"application/json"
Expand Down Expand Up @@ -2278,70 +2289,6 @@
}
}
},
"put": {
"description": "Updates a tag",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"tag"
],
"summary": "Update a tag",
"operationId": "update-tag",
"parameters": [
{
"type": "string",
"description": "Tag ID",
"name": "tagID",
"in": "path",
"required": true
},
{
"description": "Tag",
"name": "tag",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.UpdateTagRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Tag"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/errors.Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/errors.Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/errors.Error"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/errors.Error"
}
}
}
},
"delete": {
"description": "Deletes a tag",
"produces": [
Expand Down Expand Up @@ -2421,7 +2368,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.TagRequestBody"
"$ref": "#/definitions/models.UpdateTagRequestBody"
}
}
],
Expand Down Expand Up @@ -4031,10 +3978,14 @@
],
"properties": {
"new_password": {
"type": "string"
"type": "string",
"maxLength": 255,
"minLength": 8
},
"old_password": {
"type": "string"
"type": "string",
"maxLength": 255,
"minLength": 8
}
}
},
Expand Down
Loading

0 comments on commit 1d4ddd8

Please sign in to comment.