fix: add missing swagger annotation for /api, /health and /metrics

This commit is contained in:
2025-11-10 21:43:53 +01:00
parent 1338447524
commit 22d5773c7c

View File

@@ -60,6 +60,13 @@ func NewAPIHandlerWithMonitoring(config *config.Config, postRepo repositories.Po
type APIInfo = CommonResponse type APIInfo = CommonResponse
// @Summary Get API information
// @Description Retrieve API metadata, available endpoints, authentication details, and response formats
// @Tags api
// @Accept json
// @Produce json
// @Success 200 {object} APIInfo "API information retrieved successfully"
// @Router /api [get]
func (h *APIHandler) GetAPIInfo(w http.ResponseWriter, r *http.Request) { func (h *APIHandler) GetAPIInfo(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/api" { if r.URL.Path != "/api" {
http.NotFound(w, r) http.NotFound(w, r)
@@ -127,6 +134,13 @@ func (h *APIHandler) GetAPIInfo(w http.ResponseWriter, r *http.Request) {
SendSuccessResponse(w, "API information retrieved successfully", apiInfo) SendSuccessResponse(w, "API information retrieved successfully", apiInfo)
} }
// @Summary Health check
// @Description Check the API health status along with database connectivity details
// @Tags api
// @Accept json
// @Produce json
// @Success 200 {object} CommonResponse "Health check successful"
// @Router /health [get]
func (h *APIHandler) GetHealth(w http.ResponseWriter, r *http.Request) { func (h *APIHandler) GetHealth(w http.ResponseWriter, r *http.Request) {
if h.healthChecker != nil { if h.healthChecker != nil {
@@ -151,6 +165,13 @@ func (h *APIHandler) GetHealth(w http.ResponseWriter, r *http.Request) {
SendSuccessResponse(w, "Health check successful", health) SendSuccessResponse(w, "Health check successful", health)
} }
// @Summary Get metrics
// @Description Retrieve application metrics including aggregate counts and database performance data
// @Tags api
// @Accept json
// @Produce json
// @Success 200 {object} CommonResponse "Application metrics retrieved successfully"
// @Router /metrics [get]
func (h *APIHandler) GetMetrics(w http.ResponseWriter, r *http.Request) { func (h *APIHandler) GetMetrics(w http.ResponseWriter, r *http.Request) {
postCount, err := h.postRepo.Count() postCount, err := h.postRepo.Count()