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

Will Button
InstructorWill Button
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 2 years 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).

egghead
egghead
~ 19 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today