Skip to content

Commit d3f09e1

Browse files
authored
Update README.md
1 parent 1271bab commit d3f09e1

File tree

1 file changed

+82
-6
lines changed

1 file changed

+82
-6
lines changed

README.md

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,55 @@ The application will start and be available at http://localhost:8000.
3939
GET /users
4040
```
4141

42-
Returns a list of all users in the system.
42+
Returns a list of all users in the system:
43+
44+
```console
45+
curl http://localhost:8000/users/ -H "Accept: application/json"
46+
```
47+
Response:
48+
49+
```json
50+
[
51+
{
52+
"email": "alice@example.com",
53+
"id": 1,
54+
"password": "password1",
55+
"name": "Alice"
56+
},
57+
{
58+
"email": "bob@example.com",
59+
"id": 2,
60+
"password": "password2",
61+
"name": "Bob"
62+
},
63+
{
64+
"email": "charlie@example.com",
65+
"id": 3,
66+
"password": "password3",
67+
"name": "Charlie"
68+
}
69+
]
70+
```
4371

4472
### Retrieve details for a specific user:
4573

4674
```http
4775
GET /users/{user_id}
4876
```
49-
Returns details for a specific user with the given user_id.
77+
Returns details for a specific user with the given user_id:
78+
79+
```console
80+
curl http://localhost:8000/users/1 -H "Accept: application/json"
81+
```
82+
Response:
83+
```json
84+
{
85+
"email": "alice@example.com",
86+
"id": 1,
87+
"password": "password1",
88+
"name": "Alice"
89+
}
90+
```
5091

5192
### Add a new user
5293

@@ -60,24 +101,59 @@ Adds a new user to the system. The request body should include a JSON object wit
60101
- `email` (string, required): the email address of the user
61102
- `password` (string, required): the password for the user
62103

104+
```console
105+
curl -X POST http://localhost:8000/users/
106+
-H 'Content-Type: application/json'
107+
-d '{"name":"Ali","password":"123456", "email": "AliAhmadi@gmail.com"}'
108+
```
109+
Response:
110+
111+
```json
112+
{
113+
"email": "AliAhmadi@gmail.com",
114+
"password": "123456",
115+
"id": 4,
116+
"name": "Ali"
117+
}
118+
```
119+
120+
63121
### Update an existing user
64122
```http
65123
PUT /users/{user_id}
66124
```
67125

68126
Updates an existing user with the given user_id. The request body should include a JSON object with the following properties:
69127

70-
- `name` (string, optional): the new name for the user
71-
- `email` (string, optional): the new email address for the user
72-
- `password` (string, optional): the new password for the user
128+
- `name` (string): the new name for the user
129+
- `email` (string): the new email address for the user
130+
131+
```console
132+
curl -X PUT http://localhost:8000/users/1
133+
-H "Accept: application/json"
134+
-d '{"name": "Reza", "email": "reza@yahoo.com"}'
135+
```
136+
Response:
137+
```json
138+
{"message": "User updated successfully"}
139+
```
73140

74141
### Delete a user
75142

76143
```http
77144
DELETE /users/{user_id}
78145
```
79146

80-
Deletes the user with the given user_id.
147+
Deletes the user with the given user_id:
148+
149+
```console
150+
curl -X DELETE http://localhost:8000/2
151+
```
152+
153+
Response:
154+
```json
155+
{"message": "User deleted successfully"}
156+
```
81157

82158
## License
83159

0 commit comments

Comments
 (0)