Define an HTTP GET Endpoint with URL Parameters for a Node.js Server with Swagger

Will Button
InstructorWill Button
Share this video with your friends

Social Share Links

Send Tweet
Published 8 years ago
Updated 2 years ago

In this lesson, you will learn how to define an HTTP GET endpoint using Swagger with URL parameters to identify the ID of the Todo item being requested.

Instructor: [0:01] We also want to access a ToDo by its ID number. To do that, we'll specify a /ToDo endpoint, and then a /ID where ID represents the number of the ToDo that we're trying to retrieve. We'll have an HTTP getMethod() for that.

[0:23] We'll have an operation ID that's going to define ToDo by ID. It produces application/json Content Type. For parameters, we've got an ID parameter, and the location for that is going to be in path. Whenever we posted a new ToDo, we did that in the body.

[0:48] This one's going to be in the path because it's going to be in the URL itself. Obviously, this is a required field. The type of field is an integer, and the format is that of N64.

[1:04] For the responses section, we have 200 response. The schema of that response is again with the dollar sign ref and refers to our ToDos schema. Then last again, we have the x-swagger-router-controller that's going to define ToDo by ID.

egghead
egghead
~ 4 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