Skip to content

Commit

Permalink
Merge pull request #106 from wepala/WEOS-1250
Browse files Browse the repository at this point in the history
feature/WEOS-1250  - PR Changes
  • Loading branch information
shaniah868 committed Feb 18, 2022
2 parents c0154df + 5c04e6c commit dff1a02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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

0 comments on commit dff1a02

Please sign in to comment.