Skip to content

Commit 6c74bce

Browse files
Added openapi doc
1 parent 0e43d38 commit 6c74bce

File tree

1 file changed

+254
-0
lines changed

1 file changed

+254
-0
lines changed

backend/api.yaml

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
openapi: 3.0.2
2+
info:
3+
title: TermPlan Backend API
4+
description: API documentation
5+
version: 1.0.0
6+
7+
servers:
8+
- url: http://localhost:3000
9+
description: Development server
10+
11+
paths:
12+
/register:
13+
post:
14+
summary: Register a new user
15+
requestBody:
16+
required: true
17+
content:
18+
application/json:
19+
schema:
20+
$ref: '#/components/schemas/UserRegister'
21+
responses:
22+
201:
23+
description: User created
24+
content:
25+
application/json:
26+
schema:
27+
type: object
28+
properties:
29+
status:
30+
type: integer
31+
example: 201
32+
message:
33+
type: string
34+
example: User created
35+
accessToken:
36+
type: string
37+
example: <token>
38+
refreshToken:
39+
type: string
40+
example: <token>
41+
42+
/login:
43+
post:
44+
summary: Login a user
45+
requestBody:
46+
required: true
47+
content:
48+
application/json:
49+
schema:
50+
$ref: '#/components/schemas/UserLogin'
51+
responses:
52+
200:
53+
description: User logged in
54+
content:
55+
application/json:
56+
schema:
57+
type: object
58+
properties:
59+
status:
60+
type: integer
61+
example: 200
62+
message:
63+
type: string
64+
example: User logged in
65+
accessToken:
66+
type: string
67+
example: <token>
68+
refreshToken:
69+
type: string
70+
example: <token>
71+
72+
/api/events:
73+
get:
74+
summary: Get events for the authenticated user
75+
security:
76+
- bearerAuth: []
77+
responses:
78+
200:
79+
description: Events retrieved
80+
content:
81+
application/json:
82+
schema:
83+
type: object
84+
properties:
85+
status:
86+
type: integer
87+
example: 200
88+
events:
89+
type: array
90+
items:
91+
$ref: '#/components/schemas/Events'
92+
post:
93+
summary: Create a new event
94+
security:
95+
- bearerAuth: []
96+
requestBody:
97+
required: true
98+
content:
99+
application/json:
100+
schema:
101+
type: object
102+
properties:
103+
timeStart:
104+
type: string
105+
format: date-time
106+
timeEnd:
107+
type: string
108+
format: date-time
109+
name:
110+
type: string
111+
description:
112+
type: string
113+
nullable: true
114+
isAllDay:
115+
type: boolean
116+
responses:
117+
201:
118+
description: Event created
119+
content:
120+
application/json:
121+
schema:
122+
type: object
123+
properties:
124+
status:
125+
type: integer
126+
example: 201
127+
message:
128+
type: string
129+
example: Event created
130+
delete:
131+
summary: Delete an event
132+
security:
133+
- bearerAuth: []
134+
requestBody:
135+
required: true
136+
content:
137+
application/json:
138+
schema:
139+
type: object
140+
properties:
141+
_id:
142+
type: string
143+
responses:
144+
204:
145+
description: Event deleted
146+
content:
147+
application/json:
148+
schema:
149+
type: object
150+
properties:
151+
status:
152+
type: integer
153+
example: 204
154+
/api/logout:
155+
post:
156+
summary: Logout a user
157+
security:
158+
- bearerAuth: []
159+
parameters:
160+
- in: header
161+
name: refreshtoken
162+
required: true
163+
schema:
164+
type: string
165+
description: The refresh token
166+
responses:
167+
200:
168+
description: User logged out
169+
content:
170+
application/json:
171+
schema:
172+
type: object
173+
properties:
174+
status:
175+
type: integer
176+
example: 200
177+
message:
178+
type: string
179+
example: User logged out
180+
/refreshToken:
181+
post:
182+
summary: Refresh access token
183+
parameters:
184+
- in: header
185+
name: refreshtoken
186+
required: true
187+
schema:
188+
type: string
189+
description: The refresh token
190+
responses:
191+
200:
192+
description: Access token refreshed
193+
content:
194+
application/json:
195+
schema:
196+
type: object
197+
properties:
198+
status:
199+
type: integer
200+
example: 200
201+
accessToken:
202+
type: string
203+
204+
components:
205+
schemas:
206+
UserRegister:
207+
type: object
208+
properties:
209+
email:
210+
type: string
211+
format: email
212+
username:
213+
type: string
214+
password:
215+
type: string
216+
format: password
217+
218+
UserLogin:
219+
type: object
220+
properties:
221+
email:
222+
type: string
223+
format: email
224+
password:
225+
type: string
226+
format: password
227+
228+
Events:
229+
type: object
230+
properties:
231+
_id:
232+
type: string
233+
format: objectId
234+
timeStart:
235+
type: string
236+
format: date-time
237+
timeEnd:
238+
type: string
239+
format: date-time
240+
name:
241+
type: string
242+
description:
243+
type: string
244+
isAllDay:
245+
type: boolean
246+
userId:
247+
type: string
248+
format: objectId
249+
250+
securitySchemes:
251+
bearerAuth:
252+
type: http
253+
scheme: bearer
254+
bearerFormat: JWT

0 commit comments

Comments
 (0)