api/v2: serve OpenAPI specification (#1751)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2019-02-20 15:36:19 +01:00 committed by Max Inden
parent f809c45f4e
commit 57c4ff10ab
1 changed files with 4 additions and 3 deletions

View File

@ -99,10 +99,11 @@ func NewAPI(
// create new service API
openAPI := operations.NewAlertmanagerAPI(swaggerSpec)
// Skip swagger spec and redoc middleware, only serving the API itself via
// RoutesHandler. See: https://github.com/go-swagger/go-swagger/issues/1779
// Skip the redoc middleware, only serving the OpenAPI specification and
// the API itself via RoutesHandler. See:
// https://github.com/go-swagger/go-swagger/issues/1779
openAPI.Middleware = func(b middleware.Builder) http.Handler {
return middleware.Spec("", nil, openAPI.Context().RoutesHandler(b))
return middleware.Spec("", swaggerSpec.Raw(), openAPI.Context().RoutesHandler(b))
}
openAPI.AlertGetAlertsHandler = alert_ops.GetAlertsHandlerFunc(api.getAlertsHandler)