Files
pocket-id/backend/internal/utils/huma/raw.go
2026-07-12 13:42:05 -05:00

22 lines
581 B
Go

package humautils
import (
"net/http"
"strconv"
"github.com/danielgtaylor/huma/v2"
)
// AddRawOperation documents a Gin endpoint that must retain direct response control
func AddRawOperation(api huma.API, operation huma.Operation, statuses ...int) {
if len(statuses) == 0 {
statuses = []int{http.StatusOK}
}
responses := make(map[string]*huma.Response, len(statuses))
for _, status := range statuses {
responses[strconv.Itoa(status)] = &huma.Response{Description: http.StatusText(status)}
}
operation.Responses = responses
api.OpenAPI().AddOperation(&operation)
}