Skip to content

Commit 79ff061

Browse files
update swagger docs
1 parent d52b7a0 commit 79ff061

File tree

9 files changed

+11205
-351
lines changed

9 files changed

+11205
-351
lines changed

docs/docs.go

Lines changed: 4114 additions & 65 deletions
Large diffs are not rendered by default.

docs/swagger.json

Lines changed: 4114 additions & 65 deletions
Large diffs are not rendered by default.

docs/swagger.yaml

Lines changed: 2724 additions & 15 deletions
Large diffs are not rendered by default.

internal/handlers/post.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ func NewPostHandler(postService *services.PostService) *PostHandler {
2929
// @Accept json
3030
// @Produce json
3131
// @Param post body models.CreatePostRequest true "Post data"
32-
// @Success 201 {object} models.Post "Post created successfully"
33-
// @Failure 400 {object} gin.H "Bad request"
34-
// @Failure 401 {object} gin.H "Unauthorized"
35-
// @Failure 500 {object} gin.H "Internal server error"
32+
// @Success 201 {object} map[string]interface{} "Post created successfully"
33+
// @Failure 400 {object} map[string]interface{} "Bad request"
34+
// @Failure 401 {object} map[string]interface{} "Unauthorized"
35+
// @Failure 500 {object} models.ErrorResponse
3636
// @Router /posts [post]
3737
func (h *PostHandler) CreatePost(c *gin.Context) {
3838
useridRaw, exists := c.Get("user_id")
@@ -76,10 +76,10 @@ func (h *PostHandler) CreatePost(c *gin.Context) {
7676
// @Accept json
7777
// @Produce json
7878
// @Param id path int true "Post ID"
79-
// @Success 200 {object} models.Post "Post retrieved successfully"
80-
// @Failure 400 {object} gin.H "Bad request"
81-
// @Failure 404 {object} gin.H "Post not found"
82-
// @Failure 500 {object} gin.H "Internal server error"
79+
// @Success 200 {object} map[string]interface{} "Post retrieved successfully"
80+
// @Failure 400 {object} map[string]interface{} "Bad request"
81+
// @Failure 404 {object} map[string]interface{} "Post not found"
82+
// @Failure 500 {object} models.ErrorResponse
8383
// @Router /posts/{id} [get]
8484
func (h *PostHandler) GetPostByID(c *gin.Context) {
8585
idParam := c.Param("id")
@@ -110,9 +110,9 @@ func (h *PostHandler) GetPostByID(c *gin.Context) {
110110
// @Param id path int true "Post ID"
111111
// @Param post body models.UpdatePostRequest true "Updated post data"
112112
// @Success 200 {object} models.Post "Post updated successfully"
113-
// @Failure 400 {object} gin.H "Bad request"
114-
// @Failure 404 {object} gin.H "Post not found"
115-
// @Failure 500 {object} gin.H "Internal server error"
113+
// @Failure 400 {object} map[string]interface{} "Bad request"
114+
// @Failure 404 {object} map[string]interface{} "Post not found"
115+
// @Failure 500 {object} models.ErrorResponse
116116
// @Router /posts/{id} [put]
117117
func (h *PostHandler) UpdatePost(c *gin.Context) {
118118
idParam := c.Param("id")
@@ -156,9 +156,9 @@ func (h *PostHandler) UpdatePost(c *gin.Context) {
156156
// @Produce json
157157
// @Param id path int true "Post ID"
158158
// @Success 204 {object} nil "Post deleted successfully"
159-
// @Failure 400 {object} gin.H "Bad request"
160-
// @Failure 404 {object} gin.H "Post not found"
161-
// @Failure 500 {object} gin.H "Internal server error"
159+
// @Failure 400 {object} map[string]interface{} "Bad request"
160+
// @Failure 404 {object} map[string]interface{} "Post not found"
161+
// @Failure 500 {object} models.ErrorResponse
162162
// @Router /posts/{id} [delete]
163163
func (h *PostHandler) DeletePost(c *gin.Context) {
164164
idParam := c.Param("id")
@@ -187,8 +187,8 @@ func (h *PostHandler) DeletePost(c *gin.Context) {
187187
// @Produce json
188188
// @Param id path int true "User ID"
189189
// @Success 200 {array} models.Post "Posts retrieved successfully"
190-
// @Failure 400 {object} gin.H "Bad request"
191-
// @Failure 500 {object} gin.H "Internal server error"
190+
// @Failure 400 {object} map[string]interface{} "Bad request"
191+
// @Failure 500 {object} models.ErrorResponse
192192
// @Router /users/{id}/posts [get]
193193
func (h *PostHandler) ListPostsByUserID(c *gin.Context) {
194194
userIDParam := c.Param("id")
@@ -214,8 +214,8 @@ func (h *PostHandler) ListPostsByUserID(c *gin.Context) {
214214
// @Produce json
215215
// @Param id path int true "Club ID"
216216
// @Success 200 {array} models.Post "Posts retrieved successfully"
217-
// @Failure 400 {object} gin.H "Bad request"
218-
// @Failure 500 {object} gin.H "Internal server error"
217+
// @Failure 400 {object} map[string]interface{} "Bad request"
218+
// @Failure 500 {object} models.ErrorResponse
219219
// @Router /clubs/{id}/posts [get]
220220
func (h *PostHandler) ListPostsByClubID(c *gin.Context) {
221221
clubIDParam := c.Param("id")
@@ -239,8 +239,8 @@ func (h *PostHandler) ListPostsByClubID(c *gin.Context) {
239239
// @Tags Posts
240240
// @Accept json
241241
// @Produce json
242-
// @Success 200 {array} models.Post "Posts retrieved successfully"
243-
// @Failure 500 {object} gin.H "Internal server error"
242+
// @Success 200 {array} map[string]interface{} "Posts retrieved successfully"
243+
// @Failure 500 {object} models.ErrorResponse
244244
// @Router /posts [get]
245245
func (h *PostHandler) ListAllPosts(c *gin.Context) {
246246
posts, err := h.postService.ListAllPosts()
@@ -258,7 +258,7 @@ func (h *PostHandler) ListAllPosts(c *gin.Context) {
258258
// @Accept json
259259
// @Produce json
260260
// @Success 200 {array} models.Post "Public posts retrieved successfully"
261-
// @Failure 500 {object} gin.H "Internal server error"
261+
// @Failure 500 {object} models.ErrorResponse
262262
// @Router /posts/public [get]
263263
func (h *PostHandler) ListPublicPosts(c *gin.Context) {
264264
posts, err := h.postService.ListPublicPosts()
@@ -276,7 +276,7 @@ func (h *PostHandler) ListPublicPosts(c *gin.Context) {
276276
// @Accept json
277277
// @Produce json
278278
// @Success 200 {array} models.Post "Popular public posts retrieved successfully"
279-
// @Failure 500 {object} gin.H "Internal server error"
279+
// @Failure 500 {object} models.ErrorResponse
280280
// @Router /posts/popular [get]
281281
func (h *PostHandler) ListPopularPublicPosts(c *gin.Context) {
282282
posts, err := h.postService.ListPopularPublicPosts(20)
@@ -294,11 +294,11 @@ func (h *PostHandler) ListPopularPublicPosts(c *gin.Context) {
294294
// @Accept json
295295
// @Produce json
296296
// @Param id path int true "Post ID"
297-
// @Success 200 {object} gin.H "Post liked successfully"
298-
// @Failure 400 {object} gin.H "Bad request"
299-
// @Failure 401 {object} gin.H "Unauthorized"
300-
// @Failure 404 {object} gin.H "Post not found"
301-
// @Failure 500 {object} gin.H "Internal server error"
297+
// @Success 200 {object} map[string]interface{} "Post liked successfully"
298+
// @Failure 400 {object} map[string]interface{} "Bad request"
299+
// @Failure 401 {object} map[string]interface{} "Unauthorized"
300+
// @Failure 404 {object} map[string]interface{} "Post not found"
301+
// @Failure 500 {object} models.ErrorResponse
302302
// @Router /posts/{id}/like [post]
303303
func (h *PostHandler) LikePost(c *gin.Context) {
304304
postIdParam := c.Param("id")
@@ -341,11 +341,11 @@ func (h *PostHandler) LikePost(c *gin.Context) {
341341
// @Accept json
342342
// @Produce json
343343
// @Param id path int true "Post ID"
344-
// @Success 200 {object} gin.H "Post unliked successfully"
345-
// @Failure 400 {object} gin.H "Bad request"
346-
// @Failure 401 {object} gin.H "Unauthorized"
347-
// @Failure 404 {object} gin.H "Post not found"
348-
// @Failure 500 {object} gin.H "Internal server error"
344+
// @Success 200 {object} map[string]interface{} "Post unliked successfully"
345+
// @Failure 400 {object} map[string]interface{} "Bad request"
346+
// @Failure 401 {object} map[string]interface{} "Unauthorized"
347+
// @Failure 404 {object} map[string]interface{} "Post not found"
348+
// @Failure 500 {object} models.ErrorResponse
349349
// @Router /posts/{id}/unlike [post]
350350
func (h *PostHandler) UnlikePost(c *gin.Context) {
351351
postIdParam := c.Param("id")
@@ -388,10 +388,10 @@ func (h *PostHandler) UnlikePost(c *gin.Context) {
388388
// @Accept json
389389
// @Produce json
390390
// @Param id path int true "Post ID"
391-
// @Success 200 {array} models.Like "Likes retrieved successfully"
392-
// @Failure 400 {object} gin.H "Bad request"
393-
// @Failure 404 {object} gin.H "Post not found or no likes found"
394-
// @Failure 500 {object} gin.H "Internal server error"
391+
// @Success 200 {array} models.PostLikeResponse "Likes retrieved successfully"
392+
// @Failure 400 {object} map[string]interface{} "Bad request"
393+
// @Failure 404 {object} map[string]interface{} "Post not found or no likes found"
394+
// @Failure 500 {object} models.ErrorResponse
395395
// @Router /posts/{id}/likes [get]
396396
func (h *PostHandler) ListLikesByPostID(c *gin.Context) {
397397
postIdParam := c.Param("id")

0 commit comments

Comments
 (0)