@@ -295,11 +295,11 @@ uniqueness.
295
295
296
296
### Responses:
297
297
298
- | Response Code | Explanation |
299
- | -----------------------------| --------------------------------------------------------------------|
300
- | 201 (Created) | The question is created successfully. |
301
- | 400 (Bad Request) | Required fields are missing or invalid or question already exists. |
302
- | 500 (Internal Server Error) | Unexpected error in the database or server. |
298
+ | Response Code | Explanation |
299
+ | -----------------------------| --------------------------------------------------------------------- |
300
+ | 201 (Created) | The question is created successfully. |
301
+ | 400 (Bad Request) | Required fields are missing or invalid, or question already exists. |
302
+ | 500 (Internal Server Error) | Unexpected error in the database or server. |
303
303
304
304
### Command Line Example:
305
305
@@ -318,12 +318,9 @@ curl -X POST http://localhost:8081/questions -H "Content-Type: application/json"
318
318
"id" : 21 ,
319
319
"title" : " New Question" ,
320
320
"description" : " This is a description for a new question." ,
321
- "topics" : [
322
- " Data Structures" ,
323
- " Algorithms"
324
- ],
321
+ "topics" : [" Data Structures" , " Algorithms" ],
325
322
"difficulty" : " Medium" ,
326
- "_id" : " 66eedf739672ca081e9fd5ff "
323
+ "_id" : " 66f77e7bf9530832bd839239 "
327
324
}
328
325
}
329
326
```
@@ -350,11 +347,12 @@ This endpoint allows updating an existing question. Only the title, description,
350
347
351
348
### Responses:
352
349
353
- | Response Code | Explanation |
354
- | -----------------------------| ------------------------------------------------|
355
- | 200 (OK) | Success, the question is updated successfully. |
356
- | 404 (Not Found) | Question with the specified ` id ` not found. |
357
- | 500 (Internal Server Error) | Unexpected error in the database or server. |
350
+ | Response Code | Explanation |
351
+ | -----------------------------| ------------------------------------------------------------------------------------|
352
+ | 200 (OK) | Success, the question is updated successfully. |
353
+ | 400 (Bad Request) | Invalid request body such as including ` id ` or duplicate ` title ` or ` description ` . |
354
+ | 404 (Not Found) | Question with the specified ` id ` not found. |
355
+ | 500 (Internal Server Error) | Unexpected error in the database or server. |
358
356
359
357
### Command Line Example:
360
358
@@ -370,14 +368,11 @@ curl -X PUT http://localhost:8081/questions/21 -H "Content-Type: application/jso
370
368
"status" : " Success" ,
371
369
"message" : " Question updated successfully" ,
372
370
"data" : {
373
- "_id" : " 66eedf739672ca081e9fd5ff " ,
371
+ "_id" : " 66f77e7bf9530832bd839239 " ,
374
372
"id" : 21 ,
375
- "title" : " Updated Title" ,
376
- "description" : " Updated description for the existing question." ,
377
- "topics" : [
378
- " Data Structures" ,
379
- " Algorithms"
380
- ],
373
+ "title" : " Updated Question Title" ,
374
+ "description" : " This is the updated description." ,
375
+ "topics" : [" Updated Topic" ],
381
376
"difficulty" : " Hard"
382
377
}
383
378
}
@@ -418,14 +413,11 @@ curl -X DELETE http://localhost:8081/questions/21
418
413
"status" : " Success" ,
419
414
"message" : " Question deleted successfully" ,
420
415
"data" : {
421
- "_id" : " 66eedf739672ca081e9fd5ff " ,
416
+ "_id" : " 66f77e7bf9530832bd839239 " ,
422
417
"id" : 21 ,
423
- "title" : " Updated Title" ,
424
- "description" : " Updated description for the existing question." ,
425
- "topics" : [
426
- " Data Structures" ,
427
- " Algorithms"
428
- ],
418
+ "title" : " Duplicate Title" ,
419
+ "description" : " This is the updated description." ,
420
+ "topics" : [" Updated Topic" ],
429
421
"difficulty" : " Hard"
430
422
}
431
423
}
0 commit comments