Skip to content

Commit b0c07fb

Browse files
committed
fix(controller): Update getAll method to return a Page of OtisPlayerDTO and enhance API response schema
1 parent 28ca7ef commit b0c07fb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

backend/src/main/java/net/onelitefeather/otis/controller/OtisRequestsController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import io.micronaut.http.annotation.Post;
99
import io.micronaut.validation.Validated;
1010
import io.swagger.v3.oas.annotations.Operation;
11+
import io.swagger.v3.oas.annotations.media.ArraySchema;
1112
import io.swagger.v3.oas.annotations.media.Content;
1213
import io.swagger.v3.oas.annotations.media.Schema;
1314
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -231,7 +232,9 @@ public HttpResponse<OtisPlayerDTO> delete(@Valid UUID owner) {
231232
description = "Players retrieved successfully",
232233
content = @Content(
233234
mediaType = "application/json",
234-
schema = @Schema(implementation = OtisPlayerDTO.class)
235+
array = @ArraySchema(schema = @Schema(implementation = OtisPlayerDTO.class),
236+
arraySchema = @Schema(implementation = Page.class)
237+
)
235238
)
236239
)
237240
@ApiResponse(
@@ -243,10 +246,10 @@ public HttpResponse<OtisPlayerDTO> delete(@Valid UUID owner) {
243246
)
244247
)
245248
@Get(uris = {"/all"})
246-
public HttpResponse<Iterable<OtisPlayerDTO>> getAll(Pageable pageable) {
249+
public HttpResponse<Page<OtisPlayerDTO>> getAll(Pageable pageable) {
247250
Page<OtisPlayer> entities = this.repository.findAll(pageable);
248251
if (entities.isEmpty()) {
249-
return HttpResponse.ok(List.of());
252+
return HttpResponse.ok(Page.empty());
250253
}
251254
return HttpResponse.ok(entities.map(OtisPlayer::toDto));
252255
}

0 commit comments

Comments
 (0)