Merge pull request #3 from rede5/codex/mostrar-todas-as-rotas-de-jobs

Document all API routes in Swagger
This commit is contained in:
Tiago Yamamoto 2025-12-14 17:11:15 -03:00 committed by GitHub
commit f17a0c08cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 4146 additions and 48 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,7 @@ import (
"strconv"
"github.com/rede5/gohorsejobs/backend/internal/dto"
"github.com/rede5/gohorsejobs/backend/internal/models"
"github.com/rede5/gohorsejobs/backend/internal/services"
)
@ -17,6 +18,17 @@ func NewApplicationHandler(service *services.ApplicationService) *ApplicationHan
return &ApplicationHandler{Service: service}
}
// CreateApplication submits a new job application
// @Summary Create Application
// @Description Submit a new job application for a posting
// @Tags Applications
// @Accept json
// @Produce json
// @Param application body dto.CreateApplicationRequest true "Application data"
// @Success 201 {object} models.Application
// @Failure 400 {string} string "Bad Request"
// @Failure 500 {string} string "Internal Server Error"
// @Router /applications [post]
func (h *ApplicationHandler) CreateApplication(w http.ResponseWriter, r *http.Request) {
var req dto.CreateApplicationRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
@ -35,6 +47,17 @@ func (h *ApplicationHandler) CreateApplication(w http.ResponseWriter, r *http.Re
json.NewEncoder(w).Encode(app)
}
// GetApplications lists applications for a job
// @Summary List Applications
// @Description List all applications for a job
// @Tags Applications
// @Accept json
// @Produce json
// @Param jobId query int true "Filter applications by job ID"
// @Success 200 {array} models.Application
// @Failure 400 {string} string "Bad Request"
// @Failure 500 {string} string "Internal Server Error"
// @Router /applications [get]
func (h *ApplicationHandler) GetApplications(w http.ResponseWriter, r *http.Request) {
// For now, simple get by Job ID query param
jobIDStr := r.URL.Query().Get("jobId")
@ -58,6 +81,17 @@ func (h *ApplicationHandler) GetApplications(w http.ResponseWriter, r *http.Requ
json.NewEncoder(w).Encode(apps)
}
// GetApplicationByID returns a single application by ID
// @Summary Get Application
// @Description Retrieve a job application by its ID
// @Tags Applications
// @Accept json
// @Produce json
// @Param id path int true "Application ID"
// @Success 200 {object} models.Application
// @Failure 400 {string} string "Bad Request"
// @Failure 404 {string} string "Not Found"
// @Router /applications/{id} [get]
func (h *ApplicationHandler) GetApplicationByID(w http.ResponseWriter, r *http.Request) {
idStr := r.PathValue("id")
id, err := strconv.Atoi(idStr)
@ -76,6 +110,18 @@ func (h *ApplicationHandler) GetApplicationByID(w http.ResponseWriter, r *http.R
json.NewEncoder(w).Encode(app)
}
// UpdateApplicationStatus updates the status of an application
// @Summary Update Application Status
// @Description Update the status of a job application
// @Tags Applications
// @Accept json
// @Produce json
// @Param id path int true "Application ID"
// @Param body body dto.UpdateApplicationStatusRequest true "Status update"
// @Success 200 {object} models.Application
// @Failure 400 {string} string "Bad Request"
// @Failure 500 {string} string "Internal Server Error"
// @Router /applications/{id}/status [put]
func (h *ApplicationHandler) UpdateApplicationStatus(w http.ResponseWriter, r *http.Request) {
idStr := r.PathValue("id")
id, err := strconv.Atoi(idStr)

View file

@ -48,7 +48,18 @@ type DownloadURLResponse struct {
ExpiresIn int `json:"expiresIn"` // seconds
}
// GenerateUploadURL handles POST /api/v1/storage/upload-url
// GenerateUploadURL creates a pre-signed S3 URL for uploads
// @Summary Generate upload URL
// @Description Generate a pre-signed URL to upload a file to S3
// @Tags Storage
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param request body UploadURLRequest true "Upload request"
// @Success 200 {object} UploadURLResponse
// @Failure 400 {string} string "Bad Request"
// @Failure 500 {string} string "Internal Server Error"
// @Router /api/v1/storage/upload-url [post]
func (h *StorageHandler) GenerateUploadURL(w http.ResponseWriter, r *http.Request) {
var req UploadURLRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
@ -123,7 +134,18 @@ func (h *StorageHandler) GenerateUploadURL(w http.ResponseWriter, r *http.Reques
json.NewEncoder(w).Encode(response)
}
// GenerateDownloadURL handles POST /api/v1/storage/download-url
// GenerateDownloadURL creates a pre-signed S3 URL for downloads
// @Summary Generate download URL
// @Description Generate a pre-signed URL to download a private file from S3
// @Tags Storage
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param request body DownloadURLRequest true "Download request"
// @Success 200 {object} DownloadURLResponse
// @Failure 400 {string} string "Bad Request"
// @Failure 500 {string} string "Internal Server Error"
// @Router /api/v1/storage/download-url [post]
func (h *StorageHandler) GenerateDownloadURL(w http.ResponseWriter, r *http.Request) {
var req DownloadURLRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
@ -153,7 +175,18 @@ func (h *StorageHandler) GenerateDownloadURL(w http.ResponseWriter, r *http.Requ
json.NewEncoder(w).Encode(response)
}
// DeleteFile handles DELETE /api/v1/storage/files
// DeleteFile removes an object from S3
// @Summary Delete file
// @Description Delete a stored file by key
// @Tags Storage
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param key query string true "File key"
// @Success 204
// @Failure 400 {string} string "Bad Request"
// @Failure 500 {string} string "Internal Server Error"
// @Router /api/v1/storage/files [delete]
func (h *StorageHandler) DeleteFile(w http.ResponseWriter, r *http.Request) {
key := r.URL.Query().Get("key")
if key == "" {