feat: update swagger using script

This commit is contained in:
2025-11-10 21:44:48 +01:00
parent 78989eb9f8
commit a170085b89
3 changed files with 2723 additions and 2482 deletions

View File

@@ -14,8 +14,8 @@ const docTemplate = `{
"email": "sandro@cazzaniga.fr" "email": "sandro@cazzaniga.fr"
}, },
"license": { "license": {
"name": "MIT", "name": "GPLv3",
"url": "https://opensource.org/licenses/MIT" "url": "https://www.gnu.org/licenses/gpl-3.0.html"
}, },
"version": "{{.Version}}" "version": "{{.Version}}"
}, },
@@ -24,7 +24,7 @@ const docTemplate = `{
"paths": { "paths": {
"/api": { "/api": {
"get": { "get": {
"description": "Get information about the API endpoints and version", "description": "Retrieve API metadata, available endpoints, authentication details, and response formats",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -45,7 +45,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/account": { "/api/auth/account": {
"delete": { "delete": {
"security": [ "security": [
{ {
@@ -91,7 +91,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/account/confirm": { "/api/auth/account/confirm": {
"post": { "post": {
"description": "Confirm account deletion using the provided token", "description": "Confirm account deletion using the provided token",
"consumes": [ "consumes": [
@@ -143,7 +143,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/confirm": { "/api/auth/confirm": {
"get": { "get": {
"description": "Confirm user email with verification token", "description": "Confirm user email with verification token",
"consumes": [ "consumes": [
@@ -187,7 +187,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/email": { "/api/auth/email": {
"put": { "put": {
"security": [ "security": [
{ {
@@ -256,7 +256,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/forgot-password": { "/api/auth/forgot-password": {
"post": { "post": {
"description": "Send a password reset email using a username or email", "description": "Send a password reset email using a username or email",
"consumes": [ "consumes": [
@@ -296,7 +296,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/login": { "/api/auth/login": {
"post": { "post": {
"description": "Authenticate user with username and password", "description": "Authenticate user with username and password",
"consumes": [ "consumes": [
@@ -354,7 +354,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/logout": { "/api/auth/logout": {
"post": { "post": {
"security": [ "security": [
{ {
@@ -388,7 +388,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/me": { "/api/auth/me": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -428,7 +428,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/password": { "/api/auth/password": {
"put": { "put": {
"security": [ "security": [
{ {
@@ -485,7 +485,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/refresh": { "/api/auth/refresh": {
"post": { "post": {
"description": "Use a refresh token to get a new access token. This endpoint allows clients to obtain a new access token using a valid refresh token without requiring user credentials.", "description": "Use a refresh token to get a new access token. This endpoint allows clients to obtain a new access token using a valid refresh token without requiring user credentials.",
"consumes": [ "consumes": [
@@ -543,7 +543,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/register": { "/api/auth/register": {
"post": { "post": {
"description": "Register a new user with username, email and password", "description": "Register a new user with username, email and password",
"consumes": [ "consumes": [
@@ -595,7 +595,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/resend-verification": { "/api/auth/resend-verification": {
"post": { "post": {
"description": "Send a new verification email to the provided address", "description": "Send a new verification email to the provided address",
"consumes": [ "consumes": [
@@ -665,7 +665,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/reset-password": { "/api/auth/reset-password": {
"post": { "post": {
"description": "Reset a user's password using a reset token", "description": "Reset a user's password using a reset token",
"consumes": [ "consumes": [
@@ -711,7 +711,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/revoke": { "/api/auth/revoke": {
"post": { "post": {
"security": [ "security": [
{ {
@@ -768,7 +768,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/revoke-all": { "/api/auth/revoke-all": {
"post": { "post": {
"security": [ "security": [
{ {
@@ -808,7 +808,7 @@ const docTemplate = `{
} }
} }
}, },
"/auth/username": { "/api/auth/username": {
"put": { "put": {
"security": [ "security": [
{ {
@@ -871,55 +871,7 @@ const docTemplate = `{
} }
} }
}, },
"/health": { "/api/posts": {
"get": {
"description": "Check if the API is healthy with comprehensive database monitoring",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"api"
],
"summary": "Health check",
"responses": {
"200": {
"description": "Health check successful",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/metrics": {
"get": {
"description": "Get application metrics including post stats, user stats, vote stats, and database performance metrics",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"api"
],
"summary": "Get metrics",
"responses": {
"200": {
"description": "Application metrics with vote statistics and database monitoring",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/posts": {
"get": { "get": {
"description": "Get a list of posts with pagination. Posts include vote statistics (up_votes, down_votes, score) and current user's vote status.", "description": "Get a list of posts with pagination. Posts include vote statistics (up_votes, down_votes, score) and current user's vote status.",
"consumes": [ "consumes": [
@@ -1037,7 +989,7 @@ const docTemplate = `{
} }
} }
}, },
"/posts/search": { "/api/posts/search": {
"get": { "get": {
"description": "Search posts by title or content keywords. Results include vote statistics and current user's vote status.", "description": "Search posts by title or content keywords. Results include vote statistics and current user's vote status.",
"consumes": [ "consumes": [
@@ -1094,7 +1046,7 @@ const docTemplate = `{
} }
} }
}, },
"/posts/title": { "/api/posts/title": {
"get": { "get": {
"description": "Fetch the HTML title for the provided URL", "description": "Fetch the HTML title for the provided URL",
"consumes": [ "consumes": [
@@ -1144,7 +1096,7 @@ const docTemplate = `{
} }
} }
}, },
"/posts/{id}": { "/api/posts/{id}": {
"get": { "get": {
"description": "Get a post by ID with vote statistics and current user's vote status", "description": "Get a post by ID with vote statistics and current user's vote status",
"consumes": [ "consumes": [
@@ -1333,7 +1285,7 @@ const docTemplate = `{
} }
} }
}, },
"/posts/{id}/vote": { "/api/posts/{id}/vote": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1515,7 +1467,7 @@ const docTemplate = `{
} }
} }
}, },
"/posts/{id}/votes": { "/api/posts/{id}/votes": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1570,7 +1522,7 @@ const docTemplate = `{
} }
} }
}, },
"/users": { "/api/users": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1687,7 +1639,7 @@ const docTemplate = `{
} }
} }
}, },
"/users/{id}": { "/api/users/{id}": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1748,7 +1700,7 @@ const docTemplate = `{
} }
} }
}, },
"/users/{id}/posts": { "/api/users/{id}/posts": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1816,6 +1768,52 @@ const docTemplate = `{
} }
} }
} }
},
"/health": {
"get": {
"description": "Check the API health status along with database connectivity details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"api"
],
"summary": "Health check",
"responses": {
"200": {
"description": "Health check successful",
"schema": {
"$ref": "#/definitions/handlers.CommonResponse"
}
}
}
}
},
"/metrics": {
"get": {
"description": "Retrieve application metrics including aggregate counts and database performance data",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"api"
],
"summary": "Get metrics",
"responses": {
"200": {
"description": "Application metrics retrieved successfully",
"schema": {
"$ref": "#/definitions/handlers.CommonResponse"
}
}
}
}
} }
}, },
"definitions": { "definitions": {
@@ -1906,6 +1904,21 @@ const docTemplate = `{
} }
} }
}, },
"handlers.CommonResponse": {
"type": "object",
"properties": {
"data": {},
"error": {
"type": "string"
},
"message": {
"type": "string"
},
"success": {
"type": "boolean"
}
}
},
"handlers.ConfirmAccountDeletionRequest": { "handlers.ConfirmAccountDeletionRequest": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@@ -1,5 +1,7 @@
{ {
"schemes": ["http"], "schemes": [
"http"
],
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "Goyco is a Y Combinator-style news aggregation platform API.", "description": "Goyco is a Y Combinator-style news aggregation platform API.",
@@ -9,8 +11,8 @@
"email": "sandro@cazzaniga.fr" "email": "sandro@cazzaniga.fr"
}, },
"license": { "license": {
"name": "MIT", "name": "GPLv3",
"url": "https://opensource.org/licenses/MIT" "url": "https://www.gnu.org/licenses/gpl-3.0.html"
}, },
"version": "0.1.0" "version": "0.1.0"
}, },
@@ -19,10 +21,16 @@
"paths": { "paths": {
"/api": { "/api": {
"get": { "get": {
"description": "Get information about the API endpoints and version", "description": "Retrieve API metadata, available endpoints, authentication details, and response formats",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["api"], ],
"produces": [
"application/json"
],
"tags": [
"api"
],
"summary": "Get API information", "summary": "Get API information",
"responses": { "responses": {
"200": { "200": {
@@ -34,7 +42,7 @@
} }
} }
}, },
"/auth/account": { "/api/auth/account": {
"delete": { "delete": {
"security": [ "security": [
{ {
@@ -42,9 +50,15 @@
} }
], ],
"description": "Initiate the deletion process for the authenticated user's account", "description": "Initiate the deletion process for the authenticated user's account",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Request account deletion", "summary": "Request account deletion",
"responses": { "responses": {
"200": { "200": {
@@ -74,12 +88,18 @@
} }
} }
}, },
"/auth/account/confirm": { "/api/auth/account/confirm": {
"post": { "post": {
"description": "Confirm account deletion using the provided token", "description": "Confirm account deletion using the provided token",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Confirm account deletion", "summary": "Confirm account deletion",
"parameters": [ "parameters": [
{ {
@@ -120,12 +140,18 @@
} }
} }
}, },
"/auth/confirm": { "/api/auth/confirm": {
"get": { "get": {
"description": "Confirm user email with verification token", "description": "Confirm user email with verification token",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Confirm email address", "summary": "Confirm email address",
"parameters": [ "parameters": [
{ {
@@ -158,7 +184,7 @@
} }
} }
}, },
"/auth/email": { "/api/auth/email": {
"put": { "put": {
"security": [ "security": [
{ {
@@ -166,9 +192,15 @@
} }
], ],
"description": "Update the authenticated user's email address", "description": "Update the authenticated user's email address",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Update email address", "summary": "Update email address",
"parameters": [ "parameters": [
{ {
@@ -221,12 +253,18 @@
} }
} }
}, },
"/auth/forgot-password": { "/api/auth/forgot-password": {
"post": { "post": {
"description": "Send a password reset email using a username or email", "description": "Send a password reset email using a username or email",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Request a password reset", "summary": "Request a password reset",
"parameters": [ "parameters": [
{ {
@@ -255,12 +293,18 @@
} }
} }
}, },
"/auth/login": { "/api/auth/login": {
"post": { "post": {
"description": "Authenticate user with username and password", "description": "Authenticate user with username and password",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Login user", "summary": "Login user",
"parameters": [ "parameters": [
{ {
@@ -307,7 +351,7 @@
} }
} }
}, },
"/auth/logout": { "/api/auth/logout": {
"post": { "post": {
"security": [ "security": [
{ {
@@ -315,9 +359,15 @@
} }
], ],
"description": "Logout the authenticated user and invalidate their session", "description": "Logout the authenticated user and invalidate their session",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Logout user", "summary": "Logout user",
"responses": { "responses": {
"200": { "200": {
@@ -335,7 +385,7 @@
} }
} }
}, },
"/auth/me": { "/api/auth/me": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -343,9 +393,15 @@
} }
], ],
"description": "Retrieve the authenticated user's profile information", "description": "Retrieve the authenticated user's profile information",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Get current user profile", "summary": "Get current user profile",
"responses": { "responses": {
"200": { "200": {
@@ -369,7 +425,7 @@
} }
} }
}, },
"/auth/password": { "/api/auth/password": {
"put": { "put": {
"security": [ "security": [
{ {
@@ -377,9 +433,15 @@
} }
], ],
"description": "Update the authenticated user's password", "description": "Update the authenticated user's password",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Update password", "summary": "Update password",
"parameters": [ "parameters": [
{ {
@@ -420,12 +482,18 @@
} }
} }
}, },
"/auth/refresh": { "/api/auth/refresh": {
"post": { "post": {
"description": "Use a refresh token to get a new access token. This endpoint allows clients to obtain a new access token using a valid refresh token without requiring user credentials.", "description": "Use a refresh token to get a new access token. This endpoint allows clients to obtain a new access token using a valid refresh token without requiring user credentials.",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Refresh access token", "summary": "Refresh access token",
"parameters": [ "parameters": [
{ {
@@ -472,12 +540,18 @@
} }
} }
}, },
"/auth/register": { "/api/auth/register": {
"post": { "post": {
"description": "Register a new user with username, email and password", "description": "Register a new user with username, email and password",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Register a new user", "summary": "Register a new user",
"parameters": [ "parameters": [
{ {
@@ -518,12 +592,18 @@
} }
} }
}, },
"/auth/resend-verification": { "/api/auth/resend-verification": {
"post": { "post": {
"description": "Send a new verification email to the provided address", "description": "Send a new verification email to the provided address",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Resend verification email", "summary": "Resend verification email",
"parameters": [ "parameters": [
{ {
@@ -582,12 +662,18 @@
} }
} }
}, },
"/auth/reset-password": { "/api/auth/reset-password": {
"post": { "post": {
"description": "Reset a user's password using a reset token", "description": "Reset a user's password using a reset token",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Reset password", "summary": "Reset password",
"parameters": [ "parameters": [
{ {
@@ -622,7 +708,7 @@
} }
} }
}, },
"/auth/revoke": { "/api/auth/revoke": {
"post": { "post": {
"security": [ "security": [
{ {
@@ -630,9 +716,15 @@
} }
], ],
"description": "Revoke a specific refresh token. This endpoint allows authenticated users to invalidate a specific refresh token, preventing its future use.", "description": "Revoke a specific refresh token. This endpoint allows authenticated users to invalidate a specific refresh token, preventing its future use.",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Revoke refresh token", "summary": "Revoke refresh token",
"parameters": [ "parameters": [
{ {
@@ -673,7 +765,7 @@
} }
} }
}, },
"/auth/revoke-all": { "/api/auth/revoke-all": {
"post": { "post": {
"security": [ "security": [
{ {
@@ -681,9 +773,15 @@
} }
], ],
"description": "Revoke all refresh tokens for the authenticated user. This endpoint allows users to invalidate all their refresh tokens at once, effectively logging them out from all devices.", "description": "Revoke all refresh tokens for the authenticated user. This endpoint allows users to invalidate all their refresh tokens at once, effectively logging them out from all devices.",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Revoke all user tokens", "summary": "Revoke all user tokens",
"responses": { "responses": {
"200": { "200": {
@@ -707,7 +805,7 @@
} }
} }
}, },
"/auth/username": { "/api/auth/username": {
"put": { "put": {
"security": [ "security": [
{ {
@@ -715,9 +813,15 @@
} }
], ],
"description": "Update the authenticated user's username", "description": "Update the authenticated user's username",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["auth"], ],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Update username", "summary": "Update username",
"parameters": [ "parameters": [
{ {
@@ -764,48 +868,18 @@
} }
} }
}, },
"/health": { "/api/posts": {
"get": {
"description": "Check if the API is healthy with comprehensive database monitoring",
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["api"],
"summary": "Health check",
"responses": {
"200": {
"description": "Health check successful",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/metrics": {
"get": {
"description": "Get application metrics including post stats, user stats, vote stats, and database performance metrics",
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["api"],
"summary": "Get metrics",
"responses": {
"200": {
"description": "Application metrics with vote statistics and database monitoring",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/posts": {
"get": { "get": {
"description": "Get a list of posts with pagination. Posts include vote statistics (up_votes, down_votes, score) and current user's vote status.", "description": "Get a list of posts with pagination. Posts include vote statistics (up_votes, down_votes, score) and current user's vote status.",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["posts"], ],
"produces": [
"application/json"
],
"tags": [
"posts"
],
"summary": "Get posts", "summary": "Get posts",
"parameters": [ "parameters": [
{ {
@@ -851,9 +925,15 @@
} }
], ],
"description": "Create a new post with URL and optional title", "description": "Create a new post with URL and optional title",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["posts"], ],
"produces": [
"application/json"
],
"tags": [
"posts"
],
"summary": "Create a new post", "summary": "Create a new post",
"parameters": [ "parameters": [
{ {
@@ -906,12 +986,18 @@
} }
} }
}, },
"/posts/search": { "/api/posts/search": {
"get": { "get": {
"description": "Search posts by title or content keywords. Results include vote statistics and current user's vote status.", "description": "Search posts by title or content keywords. Results include vote statistics and current user's vote status.",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["posts"], ],
"produces": [
"application/json"
],
"tags": [
"posts"
],
"summary": "Search posts", "summary": "Search posts",
"parameters": [ "parameters": [
{ {
@@ -957,12 +1043,18 @@
} }
} }
}, },
"/posts/title": { "/api/posts/title": {
"get": { "get": {
"description": "Fetch the HTML title for the provided URL", "description": "Fetch the HTML title for the provided URL",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["posts"], ],
"produces": [
"application/json"
],
"tags": [
"posts"
],
"summary": "Fetch title from URL", "summary": "Fetch title from URL",
"parameters": [ "parameters": [
{ {
@@ -1001,12 +1093,18 @@
} }
} }
}, },
"/posts/{id}": { "/api/posts/{id}": {
"get": { "get": {
"description": "Get a post by ID with vote statistics and current user's vote status", "description": "Get a post by ID with vote statistics and current user's vote status",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["posts"], ],
"produces": [
"application/json"
],
"tags": [
"posts"
],
"summary": "Get a single post", "summary": "Get a single post",
"parameters": [ "parameters": [
{ {
@@ -1051,9 +1149,15 @@
} }
], ],
"description": "Update the title and content of a post owned by the authenticated user", "description": "Update the title and content of a post owned by the authenticated user",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["posts"], ],
"produces": [
"application/json"
],
"tags": [
"posts"
],
"summary": "Update a post", "summary": "Update a post",
"parameters": [ "parameters": [
{ {
@@ -1119,9 +1223,15 @@
} }
], ],
"description": "Delete a post owned by the authenticated user", "description": "Delete a post owned by the authenticated user",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["posts"], ],
"produces": [
"application/json"
],
"tags": [
"posts"
],
"summary": "Delete a post", "summary": "Delete a post",
"parameters": [ "parameters": [
{ {
@@ -1172,7 +1282,7 @@
} }
} }
}, },
"/posts/{id}/vote": { "/api/posts/{id}/vote": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1180,9 +1290,15 @@
} }
], ],
"description": "Retrieve the current user's vote for a specific post. Requires authentication and returns the vote type if it exists.\n\n**Response:**\n- If vote exists: Returns vote details with contextual metadata (including `is_anonymous`)\n- If no vote: Returns success with null vote data and metadata", "description": "Retrieve the current user's vote for a specific post. Requires authentication and returns the vote type if it exists.\n\n**Response:**\n- If vote exists: Returns vote details with contextual metadata (including `is_anonymous`)\n- If no vote: Returns success with null vote data and metadata",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["votes"], ],
"produces": [
"application/json"
],
"tags": [
"votes"
],
"summary": "Get current user's vote", "summary": "Get current user's vote",
"parameters": [ "parameters": [
{ {
@@ -1227,9 +1343,15 @@
} }
], ],
"description": "Vote on a post (upvote, downvote, or remove vote). Authentication is required; the vote is performed on behalf of the current user.\n\n**Vote Types:**\n- `up`: Upvote the post\n- `down`: Downvote the post\n- `none`: Remove existing vote\n\n**Response includes:**\n- Updated post vote counts (up_votes, down_votes, score)\n- Success message", "description": "Vote on a post (upvote, downvote, or remove vote). Authentication is required; the vote is performed on behalf of the current user.\n\n**Vote Types:**\n- `up`: Upvote the post\n- `down`: Downvote the post\n- `none`: Remove existing vote\n\n**Response includes:**\n- Updated post vote counts (up_votes, down_votes, score)\n- Success message",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["votes"], ],
"produces": [
"application/json"
],
"tags": [
"votes"
],
"summary": "Cast a vote on a post", "summary": "Cast a vote on a post",
"parameters": [ "parameters": [
{ {
@@ -1289,9 +1411,15 @@
} }
], ],
"description": "Remove a vote from a post for the authenticated user. This is equivalent to casting a vote with type 'none'.", "description": "Remove a vote from a post for the authenticated user. This is equivalent to casting a vote with type 'none'.",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["votes"], ],
"produces": [
"application/json"
],
"tags": [
"votes"
],
"summary": "Remove a vote", "summary": "Remove a vote",
"parameters": [ "parameters": [
{ {
@@ -1336,7 +1464,7 @@
} }
} }
}, },
"/posts/{id}/votes": { "/api/posts/{id}/votes": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1344,9 +1472,15 @@
} }
], ],
"description": "Retrieve all votes for a specific post. Returns all votes in a single format.\n\n**Authentication Required:** Yes (Bearer token)\n\n**Response includes:**\n- Array of all votes\n- Total vote count\n- Each vote includes type and unauthenticated status", "description": "Retrieve all votes for a specific post. Returns all votes in a single format.\n\n**Authentication Required:** Yes (Bearer token)\n\n**Response includes:**\n- Array of all votes\n- Total vote count\n- Each vote includes type and unauthenticated status",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["votes"], ],
"produces": [
"application/json"
],
"tags": [
"votes"
],
"summary": "Get post votes", "summary": "Get post votes",
"parameters": [ "parameters": [
{ {
@@ -1385,7 +1519,7 @@
} }
} }
}, },
"/users": { "/api/users": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1393,9 +1527,15 @@
} }
], ],
"description": "Retrieve a paginated list of users", "description": "Retrieve a paginated list of users",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["users"], ],
"produces": [
"application/json"
],
"tags": [
"users"
],
"summary": "List users", "summary": "List users",
"parameters": [ "parameters": [
{ {
@@ -1441,9 +1581,15 @@
} }
], ],
"description": "Create a new user account", "description": "Create a new user account",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["users"], ],
"produces": [
"application/json"
],
"tags": [
"users"
],
"summary": "Create user", "summary": "Create user",
"parameters": [ "parameters": [
{ {
@@ -1490,7 +1636,7 @@
} }
} }
}, },
"/users/{id}": { "/api/users/{id}": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1498,9 +1644,15 @@
} }
], ],
"description": "Retrieve a specific user by ID", "description": "Retrieve a specific user by ID",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["users"], ],
"produces": [
"application/json"
],
"tags": [
"users"
],
"summary": "Get user", "summary": "Get user",
"parameters": [ "parameters": [
{ {
@@ -1545,7 +1697,7 @@
} }
} }
}, },
"/users/{id}/posts": { "/api/users/{id}/posts": {
"get": { "get": {
"security": [ "security": [
{ {
@@ -1553,9 +1705,15 @@
} }
], ],
"description": "Retrieve posts created by a specific user", "description": "Retrieve posts created by a specific user",
"consumes": ["application/json"], "consumes": [
"produces": ["application/json"], "application/json"
"tags": ["users"], ],
"produces": [
"application/json"
],
"tags": [
"users"
],
"summary": "Get user posts", "summary": "Get user posts",
"parameters": [ "parameters": [
{ {
@@ -1607,6 +1765,52 @@
} }
} }
} }
},
"/health": {
"get": {
"description": "Check the API health status along with database connectivity details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"api"
],
"summary": "Health check",
"responses": {
"200": {
"description": "Health check successful",
"schema": {
"$ref": "#/definitions/handlers.CommonResponse"
}
}
}
}
},
"/metrics": {
"get": {
"description": "Retrieve application metrics including aggregate counts and database performance data",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"api"
],
"summary": "Get metrics",
"responses": {
"200": {
"description": "Application metrics retrieved successfully",
"schema": {
"$ref": "#/definitions/handlers.CommonResponse"
}
}
}
}
} }
}, },
"definitions": { "definitions": {
@@ -1697,6 +1901,21 @@
} }
} }
}, },
"handlers.CommonResponse": {
"type": "object",
"properties": {
"data": {},
"error": {
"type": "string"
},
"message": {
"type": "string"
},
"success": {
"type": "boolean"
}
}
},
"handlers.ConfirmAccountDeletionRequest": { "handlers.ConfirmAccountDeletionRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -1758,7 +1977,9 @@
}, },
"handlers.RefreshTokenRequest": { "handlers.RefreshTokenRequest": {
"type": "object", "type": "object",
"required": ["refresh_token"], "required": [
"refresh_token"
],
"properties": { "properties": {
"refresh_token": { "refresh_token": {
"type": "string", "type": "string",
@@ -1801,7 +2022,9 @@
}, },
"handlers.RevokeTokenRequest": { "handlers.RevokeTokenRequest": {
"type": "object", "type": "object",
"required": ["refresh_token"], "required": [
"refresh_token"
],
"properties": { "properties": {
"refresh_token": { "refresh_token": {
"type": "string", "type": "string",
@@ -1868,7 +2091,11 @@
"properties": { "properties": {
"type": { "type": {
"type": "string", "type": "string",
"enum": ["up", "down", "none"], "enum": [
"up",
"down",
"none"
],
"example": "up" "example": "up"
} }
} }

File diff suppressed because it is too large Load Diff