1010
1111use App \Utils \JSON ;
1212use JsonException ;
13- use OpenApi \Annotations as OA ;
13+ use OpenApi \Attributes as OA ;
14+ use OpenApi \Attributes \JsonContent ;
15+ use OpenApi \Attributes \Property ;
1416use Symfony \Component \HttpFoundation \Request ;
1517use Symfony \Component \HttpFoundation \Response ;
1618use Symfony \Component \HttpKernel \Attribute \AsController ;
@@ -30,52 +32,77 @@ class GetTokenController
3032 /**
3133 * Endpoint action to get user Json Web Token (JWT) for authentication.
3234 *
33- * @OA\RequestBody(
34- * request="body",
35- * description="Credentials object",
36- * required=true,
37- * @OA\Schema(
38- * example={"username": "username", "password": "password"},
39- * )
40- * )
41- * @OA\Response(
42- * response=200,
43- * description="JSON Web Token for user",
44- * @OA\Schema(
45- * type="object",
46- * example={"token": "_json_web_token_"},
47- * @OA\Property(property="token", type="string", description="Json Web Token"),
48- * ),
49- * )
50- * @OA\Response(
51- * response=400,
52- * description="Bad Request",
53- * @OA\Schema(
54- * type="object",
55- * example={"code": 400, "message": "Bad Request"},
56- * @OA\Property(property="code", type="integer", description="Error code"),
57- * @OA\Property(property="message", type="string", description="Error description"),
58- * ),
59- * )
60- * @OA\Response(
61- * response=401,
62- * description="Unauthorized",
63- * @OA\Schema(
64- * type="object",
65- * example={"code": 401, "message": "Bad credentials"},
66- * @OA\Property(property="code", type="integer", description="Error code"),
67- * @OA\Property(property="message", type="string", description="Error description"),
68- * ),
69- * )
70- * @OA\Tag(name="Authentication")
71- *
7235 * @throws HttpException
7336 * @throws JsonException
7437 */
7538 #[Route(
7639 path: '/v1/auth/get_token ' ,
7740 methods: [Request::METHOD_POST ],
7841 )]
42+ #[OA \RequestBody(
43+ request: 'body ' ,
44+ description: 'Credentials object ' ,
45+ required: true ,
46+ content: new JsonContent (
47+ properties: [
48+ new Property (property: 'username ' , type: 'string ' ),
49+ new Property (property: 'password ' , type: 'string ' ),
50+ ],
51+ type: 'object ' ,
52+ example: [
53+ 'username ' => 'username ' ,
54+ 'password ' => 'password ' ,
55+ ],
56+ ),
57+ )]
58+ #[OA \Response(
59+ response: 200 ,
60+ description: 'JSON Web Token for user ' ,
61+ content: new JsonContent (
62+ properties: [
63+ new Property (
64+ property: 'token ' ,
65+ description: 'Json Web Token ' ,
66+ type: 'string ' ,
67+ ),
68+ ],
69+ type: 'object ' ,
70+ example: [
71+ 'token ' => '_json_web_token_ ' ,
72+ ],
73+ ),
74+ )]
75+ #[OA \Response(
76+ response: 400 ,
77+ description: 'Bad Request ' ,
78+ content: new JsonContent (
79+ properties: [
80+ new Property (property: 'code ' , type: 'integer ' ),
81+ new Property (property: 'message ' , type: 'string ' ),
82+ ],
83+ type: 'object ' ,
84+ example: [
85+ 'code ' => 400 ,
86+ 'message ' => 'Bad Request ' ,
87+ ],
88+ ),
89+ )]
90+ #[OA \Response(
91+ response: 401 ,
92+ description: 'Unauthorized ' ,
93+ content: new JsonContent (
94+ properties: [
95+ new Property (property: 'code ' , type: 'integer ' ),
96+ new Property (property: 'message ' , type: 'string ' ),
97+ ],
98+ type: 'object ' ,
99+ example: [
100+ 'code ' => 401 ,
101+ 'message ' => 'Bad credentials ' ,
102+ ],
103+ ),
104+ )]
105+ #[OA \Tag(name: 'Authentication ' )]
79106 public function __invoke (): never
80107 {
81108 $ message = sprintf (
0 commit comments