From the course: Planning a Versioned RESTful API with GitHub Copilot

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Changing API behavior based on API version

Changing API behavior based on API version

- [Instructor] All right, so now we have a use case where we need to evolve our API. Currently, our get_books is returning a list of Book, but for the frontend application that is hitting this API, it also need pagination information as in how many books in general it has so that it can show the previous and next. So what we need to do is we need to create a preview release and change the behavior of this endpoint for that preview release while keeping the latest API version sending the list of books. So in order to do that, we need to make a few changes. We'll start with the Book model. So first thing is we need to create a concept of a paginated book. So I need to create a class called PaginatedBooks. So I'm going to paste the code here that says this is a class PaginatedBooks that inherits from the base model. It contains books, which is the list of Book. It contains the total, which is the total number of books found, the skip and the limit parameters, which is also sent by the…

Contents