Skip to content

Commit

Permalink
Refactor legacySearch to return a LegacyResponse wrapper
Browse files Browse the repository at this point in the history
This is done to ensure we return `{"results": ...}`
  • Loading branch information
Gcolon021 committed Nov 13, 2024
1 parent c6e26e6 commit c0bb7d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.harvard.dbmi.avillach.dictionary.legacysearch;

import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.LegacyResponse;
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.LegacySearchQuery;
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
Expand All @@ -21,9 +21,10 @@ public LegacySearchController(LegacySearchService legacySearchService) {
}

@RequestMapping(path = "/search")
public ResponseEntity<Results> legacySearch(@RequestBody String jsonString) throws IOException {
public ResponseEntity<LegacyResponse> legacySearch(@RequestBody String jsonString) throws IOException {
LegacySearchQuery legacySearchQuery = LegacySearchQueryMapper.mapFromJson(jsonString);
return ResponseEntity.ok(legacySearchService.getSearchResults(legacySearchQuery.filter(), legacySearchQuery.pageable()));
return ResponseEntity
.ok(new LegacyResponse(legacySearchService.getSearchResults(legacySearchQuery.filter(), legacySearchQuery.pageable())));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package edu.harvard.dbmi.avillach.dictionary.legacysearch.model;

import com.fasterxml.jackson.annotation.JsonProperty;

public record LegacyResponse(@JsonProperty("results") Results results) {
}

0 comments on commit c0bb7d3

Please sign in to comment.