mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-07-19 11:19:58 +02:00
22 lines
581 B
Go
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)
|
|
}
|