|
1 | 1 | export const registerSchema = { |
| 2 | + tags: ["Authentication"], |
| 3 | + summary: "Register a user", |
| 4 | + description: "Creates a user account and returns access and refresh tokens.", |
2 | 5 | body: { |
3 | 6 | type: "object", |
4 | 7 | additionalProperties: false, |
5 | 8 | required: ["email", "password"], |
6 | 9 | properties: { |
7 | | - email: { |
8 | | - type: "string", |
9 | | - format: "email" |
10 | | - }, |
11 | | - password: { |
12 | | - type: "string", |
13 | | - minLength: 8 |
14 | | - }, |
15 | | - name: { |
16 | | - type: "string", |
17 | | - minLength: 1, |
18 | | - maxLength: 100 |
19 | | - } |
| 10 | + email: { type: "string", format: "email", examples: ["user@example.com"] }, |
| 11 | + password: { type: "string", minLength: 8, examples: ["strong-password"] }, |
| 12 | + name: { type: "string", minLength: 1, maxLength: 100, examples: ["Example User"] } |
20 | 13 | } |
| 14 | + }, |
| 15 | + response: { |
| 16 | + 201: { $ref: "AuthResponse#" }, |
| 17 | + 409: { $ref: "ErrorResponse#" } |
21 | 18 | } |
22 | 19 | } as const; |
23 | 20 |
|
24 | 21 | export const loginSchema = { |
| 22 | + tags: ["Authentication"], |
| 23 | + summary: "Log in a user", |
| 24 | + description: "Authenticates credentials and returns access and refresh tokens.", |
25 | 25 | body: { |
26 | 26 | type: "object", |
27 | 27 | additionalProperties: false, |
28 | 28 | required: ["email", "password"], |
29 | 29 | properties: { |
30 | | - email: { |
31 | | - type: "string", |
32 | | - format: "email" |
33 | | - }, |
34 | | - password: { |
35 | | - type: "string", |
36 | | - minLength: 1 |
37 | | - } |
| 30 | + email: { type: "string", format: "email" }, |
| 31 | + password: { type: "string", minLength: 1 } |
38 | 32 | } |
| 33 | + }, |
| 34 | + response: { |
| 35 | + 200: { $ref: "AuthResponse#" }, |
| 36 | + 401: { $ref: "ErrorResponse#" } |
39 | 37 | } |
40 | 38 | } as const; |
41 | 39 |
|
42 | 40 | export const refreshSchema = { |
| 41 | + tags: ["Authentication"], |
| 42 | + summary: "Refresh authentication tokens", |
| 43 | + description: "Rotates a valid refresh token and returns a new token pair.", |
43 | 44 | body: { |
44 | 45 | type: "object", |
45 | 46 | additionalProperties: false, |
46 | 47 | required: ["refreshToken"], |
47 | | - properties: { |
48 | | - refreshToken: { |
49 | | - type: "string", |
50 | | - minLength: 1 |
51 | | - } |
52 | | - } |
| 48 | + properties: { refreshToken: { type: "string", minLength: 1 } } |
| 49 | + }, |
| 50 | + response: { |
| 51 | + 200: { $ref: "TokenPair#" }, |
| 52 | + 401: { $ref: "ErrorResponse#" } |
| 53 | + } |
| 54 | +} as const; |
| 55 | + |
| 56 | +export const logoutSchema = { |
| 57 | + tags: ["Authentication"], |
| 58 | + summary: "Log out a user", |
| 59 | + description: "Revokes the supplied refresh token.", |
| 60 | + body: { |
| 61 | + type: "object", |
| 62 | + additionalProperties: false, |
| 63 | + required: ["refreshToken"], |
| 64 | + properties: { refreshToken: { type: "string", minLength: 1 } } |
| 65 | + }, |
| 66 | + response: { 204: { type: "null" } } |
| 67 | +} as const; |
| 68 | + |
| 69 | +export const meSchema = { |
| 70 | + tags: ["Authentication"], |
| 71 | + summary: "Get the authenticated user", |
| 72 | + description: "Returns the currently authenticated user's public profile.", |
| 73 | + security: [{ bearerAuth: [] }], |
| 74 | + response: { |
| 75 | + 200: { $ref: "UserResponse#" }, |
| 76 | + 401: { $ref: "ErrorResponse#" } |
53 | 77 | } |
54 | 78 | } as const; |
0 commit comments