mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 16:50:01 +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 {
|
HTTPRouteRegistrationArgs struct {
|
||||||
|
Accept []string
|
||||||
Description string
|
Description string
|
||||||
HandlerFunc http.HandlerFunc
|
HandlerFunc http.HandlerFunc
|
||||||
IsPrefix bool
|
IsPrefix bool
|
||||||
|
@ -34,4 +35,5 @@ const (
|
||||||
HTTPRouteResponseTypeNo200 HTTPRouteResponseType = iota
|
HTTPRouteResponseTypeNo200 HTTPRouteResponseType = iota
|
||||||
HTTPRouteResponseTypeTextPlain
|
HTTPRouteResponseTypeTextPlain
|
||||||
HTTPRouteResponseTypeJSON
|
HTTPRouteResponseTypeJSON
|
||||||
|
HTTPRouteResponseTypeMultiple
|
||||||
)
|
)
|
||||||
|
|
|
@ -100,6 +100,12 @@ func registerSwaggerRoute(route plugins.HTTPRouteRegistrationArgs) error {
|
||||||
case plugins.HTTPRouteResponseTypeJSON:
|
case plugins.HTTPRouteResponseTypeJSON:
|
||||||
op.Responses["200"] = spec.JSONResponse(nil).WithDescription("Successful execution with JSON object response")
|
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:
|
case plugins.HTTPRouteResponseTypeNo200:
|
||||||
// We don't add a 200 then
|
// We don't add a 200 then
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue