From 3e10a3542f70f23313fc6a43c41aaca518e3d344 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Thu, 13 Apr 2023 01:28:48 +0300 Subject: doc: swagger init for login and user routes (#34) --- backend/controllers/userController.go | 39 ++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'backend/controllers/userController.go') diff --git a/backend/controllers/userController.go b/backend/controllers/userController.go index 95b2b52..cb6c15d 100644 --- a/backend/controllers/userController.go +++ b/backend/controllers/userController.go @@ -11,6 +11,15 @@ import ( "github.com/pektezol/leastportals/backend/models" ) +// GET Profile +// +// @Summary Get profile page of session user. +// @Accept json +// @Produce json +// @Success 200 {object} models.Response{data=models.ProfileResponse} +// @Failure 400 {object} models.Response +// @Failure 401 {object} models.Response +// @Router /profile [get] func Profile(c *gin.Context) { // Check if user exists user, exists := c.Get("user") @@ -87,6 +96,16 @@ func Profile(c *gin.Context) { return } +// GET User +// +// @Summary Get profile page of another user. +// @Accept json +// @Produce json +// @Param id path int true "User ID" +// @Success 200 {object} models.Response{data=models.ProfileResponse} +// @Failure 400 {object} models.Response +// @Failure 404 {object} models.Response +// @Router /user/{id} [get] func FetchUser(c *gin.Context) { id := c.Param("id") // Check if id is all numbers and 17 length @@ -178,6 +197,15 @@ func FetchUser(c *gin.Context) { return } +// PUT Profile +// +// @Summary Update profile page of session user. +// @Accept json +// @Produce json +// @Success 200 {object} models.Response{data=models.ProfileResponse} +// @Failure 400 {object} models.Response +// @Failure 401 {object} models.Response +// @Router /profile [post] func UpdateUser(c *gin.Context) { // Check if user exists user, exists := c.Get("user") @@ -208,9 +236,18 @@ func UpdateUser(c *gin.Context) { CountryCode: profile.LocCountryCode, }, }) - return } +// PUT Profile/CountryCode +// +// @Summary Update country code of session user. +// @Accept json +// @Produce json +// @Param country_code query string true "Country Code [XX]" +// @Success 200 {object} models.Response{data=models.ProfileResponse} +// @Failure 400 {object} models.Response +// @Failure 401 {object} models.Response +// @Router /profile [put] func UpdateCountryCode(c *gin.Context) { // Check if user exists user, exists := c.Get("user") -- cgit v1.2.3