mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 11:51:17 +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
2 changed files with 8 additions and 0 deletions
|
@ -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 a new issue