Skip to content

Commit 3c258ec

Browse files
committed
feat: Add authentication endpoints
1 parent be434b0 commit 3c258ec

2 files changed

Lines changed: 505 additions & 0 deletions

File tree

src/openapi/authSchemas.ts

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
import type { JSONSchema4 } from 'json-schema'
2+
import type { OpenAPIV3_1 } from 'openapi-types'
3+
4+
export const forgotPasswordRequestBodySchema: OpenAPIV3_1.SchemaObject = {
5+
title: 'Forgot password request',
6+
properties: {
7+
email: {
8+
type: 'string',
9+
},
10+
},
11+
required: ['email'],
12+
}
13+
14+
export const forgotPasswordResponseSchema: JSONSchema4 = {
15+
title: 'Forgot password response',
16+
properties: {
17+
message: {
18+
type: 'string',
19+
},
20+
},
21+
required: ['message'],
22+
}
23+
24+
export const loginRequestBodySchema: OpenAPIV3_1.SchemaObject = {
25+
title: 'Login request',
26+
properties: {
27+
email: {
28+
type: 'string',
29+
},
30+
password: {
31+
type: 'string',
32+
},
33+
},
34+
required: ['email', 'password'],
35+
}
36+
37+
export const loginResponseSchema: JSONSchema4 = {
38+
title: 'Login response',
39+
properties: {
40+
message: {
41+
type: 'string',
42+
},
43+
user: {
44+
type: 'object',
45+
additionalProperties: false,
46+
properties: {
47+
id: {
48+
type: 'string',
49+
},
50+
email: {
51+
type: 'string',
52+
},
53+
_verified: {
54+
type: 'boolean',
55+
},
56+
createdAt: {
57+
type: 'string',
58+
format: 'date-time',
59+
},
60+
updatedAt: {
61+
type: 'string',
62+
format: 'date-time',
63+
},
64+
},
65+
required: ['id', 'email', '_verified', 'createdAt', 'updatedAt'],
66+
},
67+
token: {
68+
type: 'string',
69+
},
70+
exp: {
71+
type: 'number',
72+
},
73+
},
74+
required: ['message', 'user', 'token', 'exp'],
75+
}
76+
77+
export const logoutResponseSchema: JSONSchema4 = {
78+
title: 'Logout response',
79+
properties: {
80+
message: {
81+
type: 'string',
82+
},
83+
},
84+
required: ['message'],
85+
}
86+
87+
export const meResponseSchema: JSONSchema4 = {
88+
title: 'Me response',
89+
properties: {
90+
user: {
91+
type: 'object',
92+
additionalProperties: false,
93+
properties: {
94+
id: {
95+
type: 'string',
96+
},
97+
email: {
98+
type: 'string',
99+
},
100+
_verified: {
101+
type: 'boolean',
102+
},
103+
createdAt: {
104+
type: 'string',
105+
format: 'date-time',
106+
},
107+
updatedAt: {
108+
type: 'string',
109+
format: 'date-time',
110+
},
111+
_strategy: {
112+
type: 'string',
113+
},
114+
},
115+
required: ['id', 'email', '_verified', 'createdAt', 'updatedAt', '_strategy'],
116+
},
117+
collection: {
118+
type: 'string',
119+
},
120+
token: {
121+
type: 'string',
122+
},
123+
exp: {
124+
type: 'number',
125+
},
126+
},
127+
required: ['user', 'collection', 'token', 'exp'],
128+
}
129+
130+
export const refreshTokenResponseSchema: JSONSchema4 = {
131+
title: 'Refresh token response',
132+
properties: {
133+
message: {
134+
type: 'string',
135+
},
136+
user: {
137+
type: 'object',
138+
additionalProperties: false,
139+
properties: {
140+
id: {
141+
type: 'string',
142+
},
143+
email: {
144+
type: 'string',
145+
},
146+
collection: {
147+
type: 'string',
148+
},
149+
},
150+
required: ['id', 'email', 'collection'],
151+
},
152+
refreshedToken: {
153+
type: 'string',
154+
},
155+
exp: {
156+
type: 'number',
157+
},
158+
},
159+
required: ['message', 'user', 'refreshedToken', 'exp'],
160+
}
161+
162+
export const resetPasswordRequestBodySchema: OpenAPIV3_1.SchemaObject = {
163+
title: 'Reset password request',
164+
properties: {
165+
token: {
166+
type: 'string',
167+
},
168+
password: {
169+
type: 'string',
170+
},
171+
},
172+
required: ['token', 'password'],
173+
}
174+
175+
export const resetPasswordResponseSchema: JSONSchema4 = {
176+
title: 'Reset password response',
177+
properties: {
178+
message: {
179+
type: 'string',
180+
},
181+
token: {
182+
type: 'string',
183+
},
184+
user: {
185+
type: 'object',
186+
additionalProperties: false,
187+
properties: {
188+
id: {
189+
type: 'string',
190+
},
191+
email: {
192+
type: 'string',
193+
},
194+
_verified: {
195+
type: 'boolean',
196+
},
197+
createdAt: {
198+
type: 'string',
199+
format: 'date-time',
200+
},
201+
updatedAt: {
202+
type: 'string',
203+
format: 'date-time',
204+
},
205+
},
206+
required: ['id', 'email', '_verified', 'createdAt', 'updatedAt'],
207+
},
208+
},
209+
required: ['message', 'token', 'user'],
210+
}
211+
212+
export const unlockRequestBodySchema: OpenAPIV3_1.SchemaObject = {
213+
title: 'Unlock request',
214+
properties: {
215+
email: {
216+
type: 'string',
217+
},
218+
},
219+
required: ['email'],
220+
}
221+
222+
export const unlockResponseSchema: JSONSchema4 = {
223+
title: 'Unlock response',
224+
properties: {
225+
message: {
226+
type: 'string',
227+
},
228+
},
229+
required: ['message'],
230+
}
231+
232+
export const verifyUserResponseSchema: JSONSchema4 = {
233+
title: 'Verify user response',
234+
properties: {
235+
message: {
236+
type: 'string',
237+
},
238+
},
239+
required: ['message'],
240+
}

0 commit comments

Comments
 (0)