_*This is a continuation of an earlier article on REST API design patterns found in my profile. Be sure to check that out as well. _

Introduction: Design patterns are important, but often overlooked, aspect of the software design-and-development life cycle. In the last article on the subject, we reviewed some of the basic REST API design patters. In this one, let’s take a look at some of the more advanced design patterns in a RESTful API architecture.

Versioning: It is hard to write all APIs in one release, so avoiding versioning is not possible in many cases. The general rules of thumb we’d like to follow when versioning APIs are as follows:

  • Upgrade the API to a new major version when the new implementation breaks the existing customer implementations
  • Upgrade the API to a new minor version of the API when \

Types of Versioning

  • Versioning through the URI path

The major and minor version changes can be a part of the URI, for example, to represent v1 or v2 of the API the URI can be http://localhost:9090/v1/books or http://localhost:9090/v2/books, respectively.

E.g.

Java

@GetMapping({"/v1/books","/v1.1/books","/v2/books"})  
public List<books> fetchAllBooks()    {
       return booksService.fetchAllBooks();   
}

#java #integration #software testing #design #rest api #best practices #static analysis #architechture #webservices #java design pattern

A Look at REST API Design Patterns: Advanced
5.60 GEEK