{ "swagger": "2.0", "info": { "description": "Dokumentasi REST API menggunakan Gin dan Swagger", "title": "API Koda Shortlink Documentation", "contact": {}, "version": "1.0" }, "basePath": "/api/v1", "paths": { "/auth/login": { "post": { "description": "Log in with existing email data", "consumes": [ "application/x-www-form-urlencoded" ], "produces": [ "application/json" ], "tags": [ "auth" ], "summary": "Login user", "parameters": [ { "type": "string", "description": "User email", "name": "email", "in": "formData", "required": true }, { "type": "string", "format": "password", "description": "User password", "name": "password", "in": "formData", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.ResponseSuccess" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/models.LoginResponse" } } } ] } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } } }, "/auth/logout": { "post": { "description": "Invalidate refresh token from httpOnly cookie", "produces": [ "application/json" ], "tags": [ "auth" ], "summary": "Logout user", "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/response.ResponseSuccess" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } } }, "/auth/refresh": { "post": { "description": "Get new access token using refresh token from httpOnly cookie", "produces": [ "application/json" ], "tags": [ "auth" ], "summary": "Refresh access token", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.ResponseSuccess" }, { "type": "object", "properties": { "data": { "type": "object", "properties": { "access_token": { "type": "string" } } } } } ] } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } } }, "/auth/register": { "post": { "description": "Create a new user with a unique email", "consumes": [ "application/x-www-form-urlencoded" ], "produces": [ "application/json" ], "tags": [ "auth" ], "summary": "Register new user", "parameters": [ { "type": "string", "description": "Full name user", "name": "fullname", "in": "formData", "required": true }, { "type": "string", "description": "Email user", "name": "email", "in": "formData", "required": true }, { "type": "string", "format": "password", "description": "Password user", "name": "password", "in": "formData", "required": true } ], "responses": { "201": { "description": "Created", "schema": { "allOf": [ { "$ref": "#/definitions/response.ResponseSuccess" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/models.User" } } } ] } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "409": { "description": "Conflict", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } } }, "/dashboard/stats": { "get": { "security": [ { "BearerAuth": [] } ], "description": "Retrieve user-specific statistics for dashboard overview", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "dashboard" ], "summary": "Get dashboard statistics", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.ResponseSuccess" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/services.DashboardStats" } } } ] } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } } }, "/links": { "get": { "security": [ { "BearerAuth": [] } ], "description": "Get all short links created by authenticated user with filters", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "links" ], "summary": "Get all short links", "parameters": [ { "type": "integer", "default": 1, "description": "Page number", "name": "page", "in": "query" }, { "type": "integer", "default": 10, "description": "Items per page", "name": "limit", "in": "query" }, { "type": "string", "description": "Search query", "name": "search", "in": "query" }, { "type": "string", "description": "Filter by status (active/inactive)", "name": "status", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/response.ResponseSuccess" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } }, "post": { "security": [ { "BearerAuth": [] } ], "description": "Create a new short link with auto-generated code", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "links" ], "summary": "Create short link", "parameters": [ { "description": "Short link details", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.CreateShortLinkRequest" } } ], "responses": { "201": { "description": "Created", "schema": { "$ref": "#/definitions/response.ResponseSuccess" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } } }, "/links/{shortCode}": { "get": { "security": [ { "BearerAuth": [] } ], "description": "Get specific short link details by short code", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "links" ], "summary": "Get short link by code", "parameters": [ { "type": "string", "description": "Short code", "name": "shortCode", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/response.ResponseSuccess" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } }, "put": { "security": [ { "BearerAuth": [] } ], "description": "Update short link details (original URL and/or active status)", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "links" ], "summary": "Update short link", "parameters": [ { "type": "string", "description": "Short code", "name": "shortCode", "in": "path", "required": true }, { "description": "Update details", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.UpdateShortLinkRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/response.ResponseSuccess" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } }, "delete": { "security": [ { "BearerAuth": [] } ], "description": "Delete short link by short code", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "links" ], "summary": "Delete short link", "parameters": [ { "type": "string", "description": "Short code", "name": "shortCode", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/response.ResponseSuccess" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } } }, "/users": { "get": { "security": [ { "BearerAuth": [] } ], "description": "Get specific user detail by ID", "produces": [ "application/json" ], "tags": [ "users" ], "summary": "Get user detail", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/response.ResponseSuccess" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/models.User" } } } ] } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/response.ResponseError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ResponseError" } } } } } }, "definitions": { "models.CreateShortLinkRequest": { "type": "object", "required": [ "originalUrl" ], "properties": { "originalUrl": { "type": "string" } } }, "models.LoginResponse": { "type": "object", "properties": { "accessToken": { "type": "string" }, "refreshToken": { "type": "string" } } }, "models.UpdateShortLinkRequest": { "type": "object", "properties": { "isActive": { "type": "boolean" }, "originalUrl": { "type": "string" } } }, "models.User": { "type": "object", "properties": { "email": { "type": "string" }, "fullName": { "type": "string" }, "id": { "type": "integer" }, "profilePhoto": { "type": "string" } } }, "response.ResponseError": { "type": "object", "properties": { "error": { "type": "string", "example": "Error message" }, "success": { "type": "boolean", "example": false } } }, "response.ResponseSuccess": { "type": "object", "properties": { "data": {}, "message": { "type": "string", "example": "Success message" }, "success": { "type": "boolean", "example": true } } }, "services.DashboardStats": { "type": "object", "properties": { "avgClickRate": { "type": "number", "format": "float64" }, "last7DaysStat": {}, "totalLinks": { "type": "integer" }, "totalVisits": { "type": "integer" } } } }, "securityDefinitions": { "BearerAuth": { "type": "apiKey", "name": "Authorization", "in": "header" } } }