Define an HTTP DELETE Endpoint for a Node.js API Server with Swagger

Will Button
InstructorWill Button

Share this video with your friends

Send Tweet
Published 6 years ago
Updated 4 months ago

This lesson demonstrates how to access the ID of a Todo item being deleted from the URL parameters when used with an HTTP DELETE method.

Instructor: [0:01] In addition to the GET method on this endpoint, we're also going to have a DELETE method that's going to allow us to delete a specific ToDo by its ID. OperationId will be deleteTodo(id). Just like its GET counterpart, it's going to have parameters.

[0:22] The parameter will have a name of id. We'll find it in the path. It's also required, and it's also a type of integer with a format of N64. For the response, instead of a 200, we're going to respond with an HTTP 204 indicating that the operation was successful.

[0:47] That's kind of cool, right? Knowing that you can pick and choose which responses you want to send and the conditions that you want to send them in. Then finally, we'll have our x-swagger-router-controller. It's going to be called deleteTodo(id).