SlideShare a Scribd company logo
INTERFACE
API Versioning with REST, JSON and Swagger
BREAKING THE
Thomas Bayer
bayer@predic8.de
@thomasub
ABOUT ME: THOMAS BAYER
25 years of experience in distributed computing
REST since 2002
Cofounder of predic8 & Orientation in Objects (Germany)
Open Source Developer ( Membrane Service Proxy )
Father of three
Yogi
@thomasub
Content
RESTful APIs & Versioning
APIs & Versioning
JSON Versioning
Swagger Versioning
INTERF
ACE
BREAKING THE
{
"products": [
{
"name": "Pineapples",
"product_url": "https://api.predic8.de/shop/products/33“
}
...
]
}
{
"name": "Pineapples",
"price": 3.55,
"photo_url": "https://api.predic8.de//shop/products/33/photo",
}
{
"products": [
{
"name": "Pineapples",
"product_url": "https://api.predic8.de/shop/products/33“
}
...
]
}
{
"name": "Pineapples",
"price": 3.55,
"photo_url": "https://api.predic8.de//shop/products/33/photo",
}
{
"products": [
{
"name": "Pineapples",
"product_url": "https://api.predic8.de/shop/products/33“
}
...
]
}
{
"name": "Pineapples",
"price": 3.55,
"photo_url": "https://api.predic8.de//shop/products/33/photo",
}
{
"products": [
{
"name": "Pineapples",
"product_url": "https://api.predic8.de/articles/87“
}
...
]
}
{
"name": "Pineapples",
"price": 3.55,
"photo_url": "https://api.predic8.de//shop/products/33/photo",
}
{
"products": [
{
"name": "Pineapples",
"product_url": "https://asfkafal.com/obscure-shit“
}
...
]
}
Contract = Representation
{
"products": [
{
"name": "Pineapples",
"product_url": "https://api.predic8.de/shop/products/33“
}
...
]
}
Contract!
Does not
matter!
URIs are not part of the contract!
Hypermedia Format with Method & URI
For RESTful APIs most of
“API Versioning” is not needed!
Who uses hypermedia?
... on the Client?
Content
RESTful APIs & Versioning
APIs & Versioning
JSON Versioning
Swagger Versioning
INTERF
ACE
BREAKING THE
/shop/v2.7.4/
Major
Minor
Bugfix
/shop/v2
.7.4/
/shop/v1/
/shop/v2/
/shop/v3/
Client
New Client
Newest Client
New Version => New Endpoint?
/shop/v1/Client
New Client
Newest Client
Updated Interface,
same path & version!
Only introduce new versions if you break the interface!
How do you know if the
interface is brea
king?
What can change?
• Request
• HTTP
• Path
• Methods
• Parameters
• Path
• Query
• Header
• Body
• Response
• HTTP
• Status Codes
• Header
• Body
New endpoint?
BREAKING?
GET /categories/
API /shop/
/products/
Client
/categories/
Version 1 Version 2
GET /products/
API /shop/
/products/
Client
Version 2 Version 1
GET /categories/
404 Not Found
See: https://predic8.de/rest-api-versioning.htm
Adding a new field „weight“
{
"id": 8,
"name": "Apple"
}
Server supports a new field
„weight“.
Adding a new field „weight“
{
"id": 8,
"name": "Apple"
}
{
"id": 8,
"name": "Apple",
"weight": 0.4
}
Client gets the new
field? Will he ignore it?
BREAKING?
Direction matters!
1. Where will be the new version deployed?
2. How are the requests/responses are affected?
Query Parameters
• Sequence does not matter
• Unknown parameters are ignored
• Should have defaults
TIP: Do not make a query parameter mandatory!
https://api.predic8.de/shop/products/?page=2&limit=10
https://www.google.com/?q=Helsinki&Foo=true
https://httpstatusdogs.com/
https://http.cat/201
201 instead of 200.
BREAKING?
HttpResponse<JsonNode> res = get("http://api.predic8.de/persons").asJson();
if (res.getStatus() == 200) {
System.out.println("Success!");
} else {
System.out.println("Error: " + res.getStatus());
}
if (res.getStatus() > 200 && res.getStatus() < 299) {
System.out.println("Success!");
} else {
System.out.println("Error: " + res.getStatus());
}
integer
Type Changes
BREAKING?
More specific
integer > number > string
Content
RESTful APIs & Versioning
APIs & Versioning
JSON Versioning
Swagger Versioning
INTERF
ACE
BREAKING THE
What changes more often?
Endpoints or the payload format?
XML Type
UPA constraint!
{
"name": "Mango",
"id": 57,
"weight": 0.7
}
public class Fruit {
Long id;
String name;
String language = “en“;
}
Additional Properties
are ignored Default
Property order does
not matter.
Do not be strict!
@JsonIgnoreProperties(ignoreUnknown=false)
JSON (limitations)
•JSON has no versioning features
•Renaming of fields is not supported
•JSON can be read without a schema
• Oposed to Avro, ProtoBuf
JSON Schema
{
"$schema": "http://predic8.de/shop/product/v2/",
...
}
Content-Type: application/shop+json; schema=http://predic8.de/shop/product/v2/
Content
RESTful APIs & Versioning
APIs & Versioning
JSON Versioning
Swagger Versioning
INTERF
ACE
BREAKING THE
{
"swagger": "2.0",
"host": "api.predic8.de:443",
"basePath": "/shop",
"schemes": [
"https"
],
"info": {
"title": "Fruit Shop API",
"version": "1.0.0",
},
…
/products/{pid}:
get:
…
responses:
'200‘:
content:
application/json:
schema:
type: object
properties:
id:
type: integer
name:
type: string
vendor:
type: integer
links:
getVendorById:
operationId: getVendorById
parameters:
vid: '$response.body#/vendor‘
/vendors/{vid}:
get:
operationId: getVendorById
parameters:
- in: path
name: vid
schema:
type: integer
{
“id“: 357,
“name“: “Dauerlutscher“,
“vendor_url“: “/vendor/27“,
“vendor“: 27
}
/vendors/27
GET /products/357
Swagger 3
Link = fn(Response + Swagger)
paths
/products/
get post delete
parameters
body
schema
object
properties
weight size
description
paths
/products/
get post delete
parameters
body
schema
object
properties
weight size
description
==
Version a Version b
Swaggerhub
Swagger-diff
https://github.com/Sayi/swagger-diff
APIdays Helsinki 2019 - API Versioning with REST, JSON and Swagger with Thomas Bayer, Predic8
Summary
• RESTful APIs do not need versioning, everyday APIs do
• JSON is good for compatibility
• Evolution not Revolution
• Swagger allows to compare versions

More Related Content

PDF
APIdays Helsinki 2019 - Specification-Driven Development of REST APIs with Al...
PDF
APIdays Zurich 2019 - Specification Driven Development for REST APIS Alexande...
PPTX
Oracle APEX Performance
PPTX
REST with Eve and Python
PPTX
Phing all the things
PDF
Mobile Device APIs
PDF
Take My Logs. Please!
PDF
Metrics-Driven Engineering at Etsy
APIdays Helsinki 2019 - Specification-Driven Development of REST APIs with Al...
APIdays Zurich 2019 - Specification Driven Development for REST APIS Alexande...
Oracle APEX Performance
REST with Eve and Python
Phing all the things
Mobile Device APIs
Take My Logs. Please!
Metrics-Driven Engineering at Etsy

What's hot (19)

PDF
KISS Automation.py
PPTX
DevOps and Chef
PDF
Primefaces Nextgen Lju
PDF
Make WordPress realtime.
PDF
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
PPTX
Angular Tutorial Freshers and Experienced
PDF
Metrics-Driven Engineering
PPTX
Poisoning Google images
PPTX
Javascript Testing with Jasmine 101
PDF
Your code are my tests
PDF
Rails 3: Dashing to the Finish
PDF
Python: the coolest is yet to come
PPTX
Good karma: UX Patterns and Unit Testing in Angular with Karma
PDF
Offline strategies for HTML5 web applications - IPC12
PDF
Web Performance Culture and Tools at Etsy
PDF
Phing for power users - dpc_uncon13
PPTX
Python Code Camp for Professionals 1/4
PPTX
Python Code Camp for Professionals 2/4
PPTX
Python Code Camp for Professionals 3/4
KISS Automation.py
DevOps and Chef
Primefaces Nextgen Lju
Make WordPress realtime.
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Angular Tutorial Freshers and Experienced
Metrics-Driven Engineering
Poisoning Google images
Javascript Testing with Jasmine 101
Your code are my tests
Rails 3: Dashing to the Finish
Python: the coolest is yet to come
Good karma: UX Patterns and Unit Testing in Angular with Karma
Offline strategies for HTML5 web applications - IPC12
Web Performance Culture and Tools at Etsy
Phing for power users - dpc_uncon13
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 3/4
Ad

Similar to APIdays Helsinki 2019 - API Versioning with REST, JSON and Swagger with Thomas Bayer, Predic8 (20)

PDF
Behavior Driven Development and Automation Testing Using Cucumber
PDF
The Big Picture and How to Get Started
ODP
Apache Aries Blog Sample
PPT
PHP Server side restful API - linkedin
PDF
RESTFul API Design and Documentation - an Introduction
ODP
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
PPT
Google Gears
PPT
Internet Explorer 8 for Developers by Christian Thilmany
ODP
Integration Testing in Python
PPTX
Spicy javascript: Create your first Chrome extension for web analytics QA
PDF
The vJUG talk about jOOQ: Get Back in Control of Your SQL
PDF
Тестирование Spring-based приложений
PPT
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
PDF
Beyond PrettyFaces - Einführung in Rewrite
PPTX
สปริงเฟรมเวิร์ค4.1
KEY
Workshop quality assurance for php projects tek12
PPT
Facebook + Ruby
PDF
Data Seeding via Parameterized API Requests
PDF
Harnessing the Power of the Web via R Clients for Web APIs
KEY
Socket applications
Behavior Driven Development and Automation Testing Using Cucumber
The Big Picture and How to Get Started
Apache Aries Blog Sample
PHP Server side restful API - linkedin
RESTFul API Design and Documentation - an Introduction
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Google Gears
Internet Explorer 8 for Developers by Christian Thilmany
Integration Testing in Python
Spicy javascript: Create your first Chrome extension for web analytics QA
The vJUG talk about jOOQ: Get Back in Control of Your SQL
Тестирование Spring-based приложений
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
Beyond PrettyFaces - Einführung in Rewrite
สปริงเฟรมเวิร์ค4.1
Workshop quality assurance for php projects tek12
Facebook + Ruby
Data Seeding via Parameterized API Requests
Harnessing the Power of the Web via R Clients for Web APIs
Socket applications
Ad

More from apidays (20)

PDF
apidays Munich 2025 - The Physics of Requirement Sciences Through Application...
PDF
apidays Munich 2025 - Developer Portals, API Catalogs, and Marketplaces, Miri...
PDF
apidays Munich 2025 - Making Sense of AI-Ready APIs in a Buzzword World, Andr...
PDF
apidays Munich 2025 - Integrate Your APIs into the New AI Marketplace, Senthi...
PDF
apidays Munich 2025 - The Double Life of the API Product Manager, Emmanuel Pa...
PDF
apidays Munich 2025 - Let’s build, debug and test a magic MCP server in Postm...
PDF
apidays Munich 2025 - The life-changing magic of great API docs, Jens Fischer...
PDF
apidays Munich 2025 - Automating Operations Without Reinventing the Wheel, Ma...
PDF
apidays Munich 2025 - Geospatial Artificial Intelligence (GeoAI) with OGC API...
PPTX
apidays Munich 2025 - GraphQL 101: I won't REST, until you GraphQL, Surbhi Si...
PPTX
apidays Munich 2025 - Effectively incorporating API Security into the overall...
PPTX
apidays Munich 2025 - Federated API Management and Governance, Vince Baker (D...
PPTX
apidays Munich 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (Aavista Oy)
PPTX
apidays Munich 2025 - Streamline & Secure LLM Traffic with APISIX AI Gateway ...
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
PPTX
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
PDF
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
PDF
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
PDF
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
PDF
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays Munich 2025 - The Physics of Requirement Sciences Through Application...
apidays Munich 2025 - Developer Portals, API Catalogs, and Marketplaces, Miri...
apidays Munich 2025 - Making Sense of AI-Ready APIs in a Buzzword World, Andr...
apidays Munich 2025 - Integrate Your APIs into the New AI Marketplace, Senthi...
apidays Munich 2025 - The Double Life of the API Product Manager, Emmanuel Pa...
apidays Munich 2025 - Let’s build, debug and test a magic MCP server in Postm...
apidays Munich 2025 - The life-changing magic of great API docs, Jens Fischer...
apidays Munich 2025 - Automating Operations Without Reinventing the Wheel, Ma...
apidays Munich 2025 - Geospatial Artificial Intelligence (GeoAI) with OGC API...
apidays Munich 2025 - GraphQL 101: I won't REST, until you GraphQL, Surbhi Si...
apidays Munich 2025 - Effectively incorporating API Security into the overall...
apidays Munich 2025 - Federated API Management and Governance, Vince Baker (D...
apidays Munich 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (Aavista Oy)
apidays Munich 2025 - Streamline & Secure LLM Traffic with APISIX AI Gateway ...
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
A Presentation on Touch Screen Technology
PDF
Hybrid model detection and classification of lung cancer
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PPTX
Tartificialntelligence_presentation.pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
project resource management chapter-09.pdf
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Mushroom cultivation and it's methods.pdf
Programs and apps: productivity, graphics, security and other tools
1 - Historical Antecedents, Social Consideration.pdf
Group 1 Presentation -Planning and Decision Making .pptx
A Presentation on Touch Screen Technology
Hybrid model detection and classification of lung cancer
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
DP Operators-handbook-extract for the Mautical Institute
Tartificialntelligence_presentation.pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
A comparative analysis of optical character recognition models for extracting...
project resource management chapter-09.pdf
Web App vs Mobile App What Should You Build First.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
Hindi spoken digit analysis for native and non-native speakers
WOOl fibre morphology and structure.pdf for textiles
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Mushroom cultivation and it's methods.pdf

APIdays Helsinki 2019 - API Versioning with REST, JSON and Swagger with Thomas Bayer, Predic8