feat: integrate swag fmt and improve CI/CD workflows
Some checks failed
Go CI/CD Pipeline / Lint and Format (push) Successful in 4m51s
Docker Build and Publish / Version Bump (push) Successful in 4m54s
Docker Build and Publish / Build and Push Docker Image (push) Failing after 2m51s
Go CI/CD Pipeline / Build and Test (push) Successful in 9m47s
Go CI/CD Pipeline / Version Management (push) Successful in 12s

- Add swag fmt to git pre-commit hook and CI/CD pipeline
- Create comprehensive CONTRIBUTING.md guide with AI section
- Update ADR-0013 with swag fmt documentation
- Fix swagger generation to include all endpoints
- Improve local testing scripts and workflows
- Update Dockerfile for better swagger handling
- Fix CI/CD workflow file references
This commit is contained in:
2026-04-06 15:36:55 +02:00
parent 48b7051a33
commit 183933b43e
21 changed files with 1500 additions and 78 deletions

View File

@@ -10,34 +10,39 @@ import (
)
// GreetResponse represents a greeting response
// @Description GreetResponse represents a greeting response with a message
// @Property message string "The greeting message" example("Hello John!")
//
// @Description GreetResponse represents a greeting response with a message
// @Property message string "The greeting message" example("Hello John!")
type GreetResponse struct {
Message string `json:"message" example:"Hello John!"`
}
// GreetRequest represents a greeting request
// @Description GreetRequest represents a request with a name to greet
// @Property name string "The name to greet" example("John")
//
// @Description GreetRequest represents a request with a name to greet
// @Property name string "The name to greet" example("John")
type GreetRequest struct {
Name string `json:"name" example:"John"`
}
// ErrorResponse represents an error response
// @Description ErrorResponse represents an error response
//
// @Description ErrorResponse represents an error response
type ErrorResponse struct {
Error string `json:"error" example:"invalid_request"`
Message string `json:"message" example:"Invalid name parameter"`
}
// GreetResponseV2 represents a v2 greeting response
// @Description GreetResponseV2 represents a v2 greeting response
//
// @Description GreetResponseV2 represents a v2 greeting response
type GreetResponseV2 struct {
Message string `json:"message" example:"Hello my friend John!"`
}
// ValidationError represents a validation error response
// @Description ValidationError represents a validation error with details
//
// @Description ValidationError represents a validation error with details
type ValidationError struct {
Error string `json:"error" example:"validation_failed"`
Message string `json:"message" example:"Invalid request data"`
@@ -45,7 +50,8 @@ type ValidationError struct {
}
// ValidationDetail represents a single validation error detail
// @Description ValidationDetail represents a single field validation error
//
// @Description ValidationDetail represents a single field validation error
type ValidationDetail struct {
Field string `json:"field" example:"name"`
Error string `json:"error" example:"must be <= 100 characters"`
@@ -75,28 +81,30 @@ func (h *apiV1GreetHandler) RegisterRoutes(router chi.Router) {
}
// handleGreetQuery godoc
// @Summary Get default greeting
// @Description Returns a default greeting message
// @Tags API/v1/Greeting
// @Accept json
// @Produce json
// @Success 200 {object} GreetResponse "Successful response"
// @Router /v1/greet [get]
//
// @Summary Get default greeting
// @Description Returns a default greeting message
// @Tags API/v1/Greeting
// @Accept json
// @Produce json
// @Success 200 {object} GreetResponse "Successful response"
// @Router /v1/greet [get]
func (h *apiV1GreetHandler) handleGreetQuery(w http.ResponseWriter, r *http.Request) {
name := r.URL.Query().Get("name")
h.writeJSONResponse(w, h.greeter.Greet(r.Context(), name))
}
// handleGreetPath godoc
// @Summary Get personalized greeting
// @Description Returns a greeting with the specified name
// @Tags API/v1/Greeting
// @Accept json
// @Produce json
// @Param name path string true "Name to greet"
// @Success 200 {object} GreetResponse "Successful response"
// @Failure 400 {object} ErrorResponse "Invalid name parameter"
// @Router /v1/greet/{name} [get]
//
// @Summary Get personalized greeting
// @Description Returns a greeting with the specified name
// @Tags API/v1/Greeting
// @Accept json
// @Produce json
// @Param name path string true "Name to greet"
// @Success 200 {object} GreetResponse "Successful response"
// @Failure 400 {object} ErrorResponse "Invalid name parameter"
// @Router /v1/greet/{name} [get]
func (h *apiV1GreetHandler) handleGreetPath(w http.ResponseWriter, r *http.Request) {
name := chi.URLParam(r, "name")
h.writeJSONResponse(w, h.greeter.Greet(r.Context(), name))