-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-api.http
149 lines (114 loc) · 2.87 KB
/
test-api.http
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# This file could be used for testing the API with Visual Studio Code
## Retrieving all the films.
GET http://localhost:3001/api/films HTTP/1.1
###
## Retrieving a specific film specifing its ID.
GET http://localhost:3001/api/films/{{$randomInt 1 6}} HTTP/1.1
###
## Retrieving all the films with a specified filter (in this example "unseen").
GET http://localhost:3001/api/films?filter=filter-unseen HTTP/1.1
###
## Create new film (without id)
POST http://localhost:3001/api/films HTTP/1.1
content-type: application/json
{
"title": "Guardians of the Galaxy Vol.3",
"favorite": 1,
"watchDate": "{{$datetime 'YYYY-MM-DD' -15 d }}",
"rating": 4,
"user": 1
}
###
## Retrieving all the films with a specified filter.
GET http://localhost:3001/api/films?filter=filter-lastmonth HTTP/1.1
###
## Updates the first film.
PUT http://localhost:3001/api/films/1 HTTP/1.1
content-type: application/json
{
"id": 1,
"title": "The Hangover",
"favorite": 0,
"watchDate": "",
"rating": 0,
"user": 1
}
###
## Updates film favorite property.
PUT http://localhost:3001/api/films/1/favorite HTTP/1.1
content-type: application/json
{
"id": 1,
"favorite": 1
}
###
## Updates film rating property.
PUT http://localhost:3001/api/films/1/rating HTTP/1.1
content-type: application/json
{
"id": 1,
"rating": {{$randomInt 0 6}}
}
###
## Deletes film.
DELETE http://localhost:3001/api/films/1 HTTP/1.1
###
## Retrieving all the films.
GET http://localhost:3001/api/films HTTP/1.1
###
# Wrong Requests
## Trying to retrieve a film with an ID that does not exist.
GET http://localhost:3001/api/films/1000 HTTP/1.1
###
## Trying to retrieve a film with a wrong ID.
GET http://localhost:3001/api/films/ThisIsAStringId HTTP/1.1
###
## Trying to create a wrong film.
POST http://localhost:3001/api/films HTTP/1.1
content-type: application/json
{
"wrong_title_field": "Guardians of the Galaxy Vol.3",
"favorite": "I really liked it!",
"watchDate": "May the 15th, 2023",
"rating": 35
}
###
## Trying to update a film with wrong values.
PUT http://localhost:3001/api/films/1 HTTP/1.1
content-type: application/json
{
"id": 1,
"title": "The Hangover",
"favorite": 7,
"watchDate": "",
"rating": 7
}
###
## Trying to updates film favorite property with a wrong value.
PUT http://localhost:3001/api/films/1/favorite HTTP/1.1
content-type: application/json
{
"id": 1,
"favorite": "Really like it!"
}
###
## Trying to update film rating property with a wrong value.
PUT http://localhost:3001/api/films/1/rating HTTP/1.1
content-type: application/json
{
"id": 1,
"rating": 50
}
###
## Updates film with and id that does not exists
PUT http://localhost:3001/api/films/999 HTTP/1.1
content-type: application/json
{
"id": 999,
"title": "The Hangover",
"favorite": 0,
"watchDate": "",
"rating": 0,
"user": 1
}
###