How to implement the different approaches at REST API versioning with Spring MVC
v1 of API requires address data as a single address parameter in the (german) format
(five digit zip code)(one space character)(name of town)
v2 changes that, requiring a (five digit) zip parameter and a (alphanumeric) town parameter.
Sending data in a format not matching the used version should therefore result in a HTTP/1.1 400
Also, getting the data will provide JSON data accordingly.
Internal storage is considered to always have two fields.
Additionally, there is one simple /hello resource available, which did not change between versions, but is available in both.
GET /address
{
address: "10243 Berlin"
}
POST /address
address=10243+Berlin
GET /address
{
zip: "10243",
town: "Berlin"
}
POST /address
zip=10243&town=Berlin
GET /hello
{
hello: "world"
}
/apiurl/v1/address
versus
/apiurl/v2/address
/apiheader/address
with
X-API-Version: 1.0
versus
X-API-Version: 2.0
/apiaccept/address
with
Accept: application/vnd.company.app-v1+json
versus
Accept: application/vnd.company.app-v2+json