Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/WEOS-1250 - PR Changes #106

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/rest/controller_standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
15 changes: 12 additions & 3 deletions end2end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down