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

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.