Giter VIP home page Giter VIP logo

restapi-versioning-spring's Introduction

restapi-versioning-spring

How to implement the different approaches at REST API versioning with Spring MVC

use case

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.

resource definitions

/address (version 1)

GET /address
{
    address: "10243 Berlin"
}

POST /address
address=10243+Berlin

/address (version 2)

GET /address
{
    zip: "10243",
    town: "Berlin"
}

POST /address
zip=10243&town=Berlin

/hello (version 1 and 2)

GET /hello
{
    hello: "world"
}

api detection approaches

URL based:

/apiurl/v1/address

versus

/apiurl/v2/address

Custom HTTP header:

/apiheader/address

with

X-API-Version: 1.0

versus

X-API-Version: 2.0

Accept header with vendor and version

/apiaccept/address

with

Accept: application/vnd.company.app-v1+json

versus

Accept: application/vnd.company.app-v2+json

restapi-versioning-spring's People

Contributors

mindhaq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.