diff --git a/plugins/http_api.go b/plugins/http_api.go index 92f761f..46a05f8 100644 --- a/plugins/http_api.go +++ b/plugins/http_api.go @@ -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 ) diff --git a/swagger.go b/swagger.go index 3b580ce..b06c7fd 100644 --- a/swagger.go +++ b/swagger.go @@ -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