-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathAuthSwagger.php
113 lines (109 loc) · 4.35 KB
/
AuthSwagger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace App\Api\Swagger\Auth;
use Illuminate\Http\Response;
use OpenApi\Attributes as OA;
trait AuthSwagger
{
#[
OA\Post(
path: "/auth/login",
summary: "Login User",
tags: ["Authenticate"],
requestBody: new OA\RequestBody(
required: true,
content: new OA\MediaType(
mediaType: "application/json",
schema: new OA\Schema(
required: ["email", "password"],
properties: [
new OA\Property(property: 'email', description: "User email", type: "string"),
new OA\Property(property: 'password', description: "User password", type: "string"),
]
),
example: [
'email' => '[email protected]',
'password' => 'password'
]
)
),
responses: [
new OA\Response(
response: Response::HTTP_ACCEPTED,
description: "Login success.",
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'data', type: 'object', example: [
"success" => true,
"statusCode" => Response::HTTP_ACCEPTED,
"message" => "User has been logged successfully.",
"data" => [
"id" => 1,
"name" => "User Teste",
"email" => "[email protected]",
"created_at" => "2024-07-27T15:39:28.000000Z",
"updated_at" => "2024-07-28T21:49:06.000000Z",
"bearer_token" => "17|QJmAJPmZPxxcAFCp8XgfgQf6GzEghBvTEgkgEHrAf7040d89"
]
])
]
)
),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized", content: new OA\JsonContent(
properties: [
new OA\Property(property: 'data', type: 'object', example: [
"meta" => [
"code" => Response::HTTP_UNAUTHORIZED,
"status" => "fails",
"message" => "The provided credentials are incorrect.!"
],
"user" => [],
"access_token" => [
"token" => '',
"type" => "Bearer"
]
])
]
)),
]
)
]
private function swagger_login()
{
}
#[
OA\Post(
path: '/auth/logout',
summary: 'Logout User',
tags: ['Authenticate'],
security: [
[
'bearerAuth' => []
]
],
responses: [
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: 'Unauthenticated', content: new OA\JsonContent(
properties: [
new OA\Property(property: 'data', type: 'object', example: [
"message" => "Unauthenticated."
])
]
)),
new OA\Response(response: Response::HTTP_ACCEPTED, description: 'Successfully logged out', content: new OA\JsonContent(
properties: [
new OA\Property(property: 'data', type: 'object', example: [
'meta' => [
'code' => Response::HTTP_ACCEPTED,
'status' => 'success',
'message' => 'Successfully logged out',
],
'data' => [],
])
]
)),
]
)
]
private function swagger_logout(): void
{
}
}