mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-09-18 17:52:54 +00:00
[openapi] Allow multiple mime-types on single route
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
96140670a7
commit
411756fa45
@ -11,6 +11,7 @@ type (
|
||||
}
|
||||
|
||||
HTTPRouteRegistrationArgs struct {
|
||||
Accept []string
|
||||
Description string
|
||||
HandlerFunc http.HandlerFunc
|
||||
IsPrefix bool
|
||||
@ -34,4 +35,5 @@ const (
|
||||
HTTPRouteResponseTypeNo200 HTTPRouteResponseType = iota
|
||||
HTTPRouteResponseTypeTextPlain
|
||||
HTTPRouteResponseTypeJSON
|
||||
HTTPRouteResponseTypeMultiple
|
||||
)
|
||||
|
@ -100,6 +100,12 @@ func registerSwaggerRoute(route plugins.HTTPRouteRegistrationArgs) error {
|
||||
case plugins.HTTPRouteResponseTypeJSON:
|
||||
op.Responses["200"] = spec.JSONResponse(nil).WithDescription("Successful execution with JSON object response")
|
||||
|
||||
case plugins.HTTPRouteResponseTypeMultiple:
|
||||
op.Responses["200"] = (&spec.Response{}).WithDescription("Successful execution with variable response based on Accept header")
|
||||
for _, a := range route.Accept {
|
||||
op.Responses["200"].AddContent(a, &spec.MediaType{Schema: nil})
|
||||
}
|
||||
|
||||
case plugins.HTTPRouteResponseTypeNo200:
|
||||
// We don't add a 200 then
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user