12
12
use Symfony \Component \Serializer \SerializerInterface ;
13
13
use Symfony \Component \Validator \Validator \ValidatorInterface ;
14
14
15
+ /**
16
+ * @OA\Tag(name="Bands")
17
+ */
15
18
class BandController extends AbstractController
16
19
{
17
20
public function __construct (
18
21
private readonly BandRepository $ bandRepository ,
19
22
) {
20
23
}
21
24
25
+ /**
26
+ * List all bands.
27
+ *
28
+ * @OA\Get(
29
+ * path="/band",
30
+ * summary="List all bands",
31
+ *
32
+ * @OA\Response(response=200, description="List of bands")
33
+ * )
34
+ */
22
35
#[Route('/band ' , name: 'app_band_list ' , methods: ['GET ' ])]
23
36
public function index (): JsonResponse
24
37
{
@@ -27,12 +40,54 @@ public function index(): JsonResponse
27
40
);
28
41
}
29
42
43
+ /**
44
+ * Retrieve a single band by ID.
45
+ *
46
+ * @OA\Get(
47
+ * path="/band/{id}",
48
+ * summary="Retrieve a single band",
49
+ *
50
+ * @OA\Parameter(
51
+ * name="id",
52
+ * in="path",
53
+ * required=true,
54
+ *
55
+ * @OA\Schema(type="integer"),
56
+ * description="Band ID"
57
+ * ),
58
+ *
59
+ * @OA\Response(response=200, description="Band details"),
60
+ * @OA\Response(response=404, description="Band not found")
61
+ * )
62
+ */
30
63
#[Route('/band/{id} ' , name: 'app_band_show_one ' , methods: ['GET ' ])]
31
64
public function show (Band $ band ): JsonResponse
32
65
{
33
66
return $ this ->json ($ band );
34
67
}
35
68
69
+ /**
70
+ * Add a new band.
71
+ *
72
+ * @OA\Post(
73
+ * path="/band",
74
+ * summary="Add a new band",
75
+ *
76
+ * @OA\RequestBody(
77
+ * required=true,
78
+ *
79
+ * @OA\JsonContent(
80
+ * required={"name"},
81
+ *
82
+ * @OA\Property(property="name", type="string", description="Band name"),
83
+ * @OA\Property(property="genre", type="string", description="Music genre")
84
+ * )
85
+ * ),
86
+ *
87
+ * @OA\Response(response=201, description="Band created"),
88
+ * @OA\Response(response=400, description="Invalid input")
89
+ * )
90
+ */
36
91
#[Route('/band ' , name: 'app_band_create ' , methods: ['POST ' ])]
37
92
public function create (
38
93
Request $ request ,
@@ -55,6 +110,29 @@ public function create(
55
110
return $ this ->json ($ band , 201 );
56
111
}
57
112
113
+ /**
114
+ * Update an existing band.
115
+ *
116
+ * @OA\Put(
117
+ * path="/band/{id}",
118
+ * summary="Update an existing band",
119
+ *
120
+ * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
121
+ *
122
+ * @OA\RequestBody(
123
+ * required=true,
124
+ *
125
+ * @OA\JsonContent(
126
+ *
127
+ * @OA\Property(property="name", type="string"),
128
+ * @OA\Property(property="genre", type="string")
129
+ * )
130
+ * ),
131
+ *
132
+ * @OA\Response(response=200, description="Band updated"),
133
+ * @OA\Response(response=404, description="Band not found")
134
+ * )
135
+ */
58
136
#[Route('/band/{id} ' , name: 'app_band_update ' , methods: ['PUT ' ])]
59
137
public function update (
60
138
Request $ request ,
@@ -82,6 +160,19 @@ public function update(
82
160
return $ this ->json ($ band );
83
161
}
84
162
163
+ /**
164
+ * Delete a band.
165
+ *
166
+ * @OA\Delete(
167
+ * path="/band/{id}",
168
+ * summary="Delete a band",
169
+ *
170
+ * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
171
+ *
172
+ * @OA\Response(response=204, description="Band deleted"),
173
+ * @OA\Response(response=404, description="Band not found")
174
+ * )
175
+ */
85
176
#[Route('/band/{id} ' , name: 'app_band_delete ' , methods: ['DELETE ' ])]
86
177
public function delete (Band $ band ): JsonResponse
87
178
{
0 commit comments