diff --git a/controllers/rest/controller_standard.go b/controllers/rest/controller_standard.go index 59d6d6d7..563258b3 100644 --- a/controllers/rest/controller_standard.go +++ b/controllers/rest/controller_standard.go @@ -286,7 +286,7 @@ func APIDiscovery(api *RESTAPI, projection projections.Projection, commandDispat //get content type expected for 200 response responseType := newContext.Value(weoscontext.RESPONSE_PREFIX + strconv.Itoa(http.StatusOK)) if responseType == "application/json" { - return ctxt.Redirect(http.StatusPermanentRedirect, SWAGGERJSONENDPOINT) + return ctxt.JSON(http.StatusOK, api.Swagger) } else if responseType == "application/html" { return ctxt.Redirect(http.StatusPermanentRedirect, SWAGGERUIENDPOINT) } diff --git a/end2end_test.go b/end2end_test.go index 2a49e2f1..9b7a005a 100644 --- a/end2end_test.go +++ b/end2end_test.go @@ -1435,9 +1435,18 @@ func theTotalNoEventsAndProcessedAndFailuresShouldBeReturned() error { } func theApiAsJsonShouldBeShown() error { - url := rec.HeaderMap.Get("Location") - if url != api.SWAGGERJSONENDPOINT { - return fmt.Errorf("the json result should have been returned") + contentEntity := map[string]interface{}{} + err := json.NewDecoder(rec.Body).Decode(&contentEntity) + + if err != nil { + return err + } + + if len(contentEntity) == 0 { + return fmt.Errorf("expected a response to be returned") + } + if _, ok := contentEntity["openapi"]; !ok { + return fmt.Errorf("expected the content entity to have a content 'openapi'") } return nil }