From 5aa6865391390ea78699ea6dacc9ec31c8bb6813 Mon Sep 17 00:00:00 2001 From: Nathan Rauh Date: Fri, 1 Dec 2023 08:49:56 -0600 Subject: [PATCH] use produces application/json for better formatting --- .../io/openliberty/sample/application/CrewService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/openliberty/sample/application/CrewService.java b/src/main/java/io/openliberty/sample/application/CrewService.java index 9259843..52dbb48 100755 --- a/src/main/java/io/openliberty/sample/application/CrewService.java +++ b/src/main/java/io/openliberty/sample/application/CrewService.java @@ -64,6 +64,7 @@ public void remove(@PathParam("id") int id) { } @GET + @Produces(MediaType.APPLICATION_JSON) public String retrieve() { Iterable crewMembersIterable = crewMembers.findAll()::iterator; @@ -73,6 +74,7 @@ public String retrieve() { @GET @Path("/rank/{rank}") + @Produces(MediaType.APPLICATION_JSON) public String retrieveByRank(@PathParam("rank") String rank) { List crewMembersList = crewMembers.findByRank(Rank.fromString(rank)); @@ -82,6 +84,7 @@ public String retrieveByRank(@PathParam("rank") String rank) { @GET @Path("/rank/{rank}/page/{pageNum}") + @Produces(MediaType.APPLICATION_JSON) public String retrieveByRank(@PathParam("rank") String rank, @PathParam("pageNum") long pageNum) { @@ -89,9 +92,9 @@ public String retrieveByRank(@PathParam("rank") String rank, .page(pageNum) .sortBy(Sort.asc("name"), Sort.asc("id")); - Page crewMembersPage = crewMembers.findByRank(Rank.fromString(rank), pageRequest); + Page page = crewMembers.findByRank(Rank.fromString(rank), pageRequest); - return crewMembersToJsonArray(crewMembersPage); + return crewMembersToJsonArray(page); } @DELETE