Skip to content

Commit 97802ef

Browse files
committed
add annotation OpenAPI to PlayerController;
1 parent 7f3d94c commit 97802ef

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

T23-G1/src/main/java/com/example/db_setup/controller/PlayerController.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
import com.example.db_setup.model.Player;
44
import com.example.db_setup.model.dto.gamification.PlayerDTO;
5-
import com.example.db_setup.model.repository.PlayerRepository;
65
import com.example.db_setup.service.PlayerService;
7-
import org.slf4j.Logger;
8-
import org.slf4j.LoggerFactory;
6+
import io.swagger.v3.oas.annotations.Operation;
7+
import io.swagger.v3.oas.annotations.media.ArraySchema;
8+
import io.swagger.v3.oas.annotations.media.Content;
9+
import io.swagger.v3.oas.annotations.media.Schema;
10+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
11+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
912
import org.springframework.http.ResponseEntity;
1013
import org.springframework.web.bind.annotation.*;
1114

@@ -26,6 +29,20 @@ public PlayerController(PlayerService playerService) {
2629
this.playerService = playerService;
2730
}
2831

32+
@Operation(
33+
summary = "Get all players",
34+
description = "Returns a list of all registered players"
35+
)
36+
@ApiResponses(value = {
37+
@ApiResponse(
38+
responseCode = "200",
39+
description = "List of player returned successfully or empty if there are no players",
40+
content = @Content(
41+
mediaType = "application/json",
42+
array = @ArraySchema(schema = @Schema(implementation = PlayerDTO.class))
43+
)
44+
)
45+
})
2946
@GetMapping("/players")
3047
public ResponseEntity<List<PlayerDTO>> getAllPlayers() {
3148
return ResponseEntity.ok(playerService.getAllPlayers());

0 commit comments

Comments
 (0)