Fix error response documentation for field attribute

Separated ErrorResponse and ValidationErrorResponse types:
- ErrorResponse: general errors (401, 403, 404, 500) - no field attribute
- ValidationErrorResponse: form validation errors (400) - includes field attribute

Updated respondValidationError to return appropriate type based on error format.
Updated Swagger documentation to use ValidationErrorResponse only for validation endpoints.

This ensures the field attribute only appears in API responses for actual form field validation errors, not in general error responses.
This commit is contained in:
2025-11-28 18:05:25 +01:00
parent 8d631f8fab
commit 6fb4823183
3 changed files with 14 additions and 7 deletions
+6 -2
View File
@@ -85,6 +85,10 @@ type HabitEntriesResponse struct {
}
type ErrorResponse struct {
Error string `json:"error"`
Field *string `json:"field,omitempty"`
Error string `json:"error"`
}
type ValidationErrorResponse struct {
Error string `json:"error"`
Field string `json:"field"`
}