SlideShare a Scribd company logo
GregLTurnquist.com/springone2020
Building Flexible APIs
with Spring HATEOAS
September 2–3, 2020
springone.io
1
GregLTurnquist.com/springone2020
Who am I?
GregLTurnquist.com/springone2020
Who am I?
GregLTurnquist.com/springone2020
Who am I?
bit.ly/hacking-with-spring-boot
GregLTurnquist.com/springone2020
Who am I?
bit.ly/hacking-with-spring-boot
● Principal developer on
the Spring team
● Nashville JUG co-founder
● Committer & Project
Lead for several Spring
projects
● YouTube/GregTurnquist
GregLTurnquist.com/springone2020
Let’s talk about…APIs!
GregLTurnquist.com/springone2020
What is an API?
GregLTurnquist.com/springone2020
What is an API?
● Place to get a little JSON/XML/whatever?
GregLTurnquist.com/springone2020
What is an API?
● Place to get a little JSON/XML/whatever?
● Way to interact with the app?
GregLTurnquist.com/springone2020
What is an API?
● Place to get a little JSON/XML/whatever?
● Way to interact with the app?
● Means to extract value from another app to help your own app?
GregLTurnquist.com/springone2020
What is an API?
● Place to get a little JSON/XML/whatever?
● Way to interact with the app?
● Means to extract value from another app to help your own app?
Let’s dig in and discover what it means to have a flexible API!
GregLTurnquist.com/springone2020
Simple API
6
● Spring MVC
● Simple
● Clear separation between layers
GregLTurnquist.com/springone2020
Simple API
6
● Spring MVC
● Simple
● Clear separation between layers
GregLTurnquist.com/springone2020
Simple API
6
● Spring MVC
● Simple
● Clear separation between layers
GregLTurnquist.com/springone2020
Simple API
6
● Spring MVC
● Simple
● Clear separation between layers
GregLTurnquist.com/springone2020
Simple API
6
● Spring MVC
● Simple
● Clear separation between layers
GregLTurnquist.com/springone2020
Simple API
{
"id": 0,
"name": "Frodo",
"role": "ring bearer"
}
6
GregLTurnquist.com/springone2020
Simple API
{
"id": 0,
"name": "Frodo",
"role": "ring bearer"
}
6
● Data and…
GregLTurnquist.com/springone2020
Simple API
{
"id": 0,
"name": "Frodo",
"role": "ring bearer"
}
6
● Data and…
● …nothing else!
GregLTurnquist.com/springone2020
Simple API
{
"id": 0,
"name": "Frodo",
"role": "ring bearer"
}
6
● Data and…
● …nothing else!
● Some value, but what about…
GregLTurnquist.com/springone2020
Simple API
{
"id": 0,
"name": "Frodo",
"role": "ring bearer"
}
6
● Data and…
● …nothing else!
● Some value, but what about…
● …updates?
GregLTurnquist.com/springone2020
Simple API
{
"id": 0,
"name": "Frodo",
"role": "ring bearer"
}
6
● Data and…
● …nothing else!
● Some value, but what about…
● …updates?
● …breaking changes?
GregLTurnquist.com/springone2020
Simple API
{
"id": 0,
"name": "Frodo",
"role": "ring bearer"
}
6
● Data and…
● …nothing else!
● Some value, but what about…
● …updates?
● …breaking changes?
● …backwards compatibility?
GregLTurnquist.com/springone2020
What happens when…
6
GregLTurnquist.com/springone2020
What happens when…
6
GregLTurnquist.com/springone2020
What happens when you serve this…
{
"id": 0,
"firstName": "Frodo",
"lastName": "Baggins",
"role": "ring bearer"
}
6
GregLTurnquist.com/springone2020
…but older clients try this?
6
GregLTurnquist.com/springone2020
…but older clients try this?
6
● What now?
GregLTurnquist.com/springone2020
…but older clients try this?
6
● What now?
● Tell users to just use your new API?
GregLTurnquist.com/springone2020
…but older clients try this?
6
● What now?
● Tell users to just use your new API?
● Roll out another version?
GregLTurnquist.com/springone2020
…but older clients try this?
6
● What now?
● Tell users to just use your new API?
● Roll out another version?
● Handle this AND the new format?
GregLTurnquist.com/springone2020
What about versioning?
6
https://www.infoq.com/news/2013/12/api-versioning/
● Knot = Single version of API
● P2P = Multiple versions
● Compatible = One API supports
multiple versions
GregLTurnquist.com/springone2020
What about versioning?
6
It is always possible for some unexpected reason to come along that requires a completely
different API, especially when the semantics of the interface change or security issues require the
abandonment of previously deployed software. My point was that there is no need to anticipate
such world-breaking changes with a version ID. We have the hostname for that. What you are
creating is not a new version of the API, but a new system with a new brand.
On the Web, we call that a new website. Websites don’t come with version numbers attached
because they never need to. Neither should a RESTful API. A RESTful API (done right) is just a
website for clients with a limited vocabulary.
—Dr. Roy Fielding
“
GregLTurnquist.com/springone2020
How rough can deprecating APIs be?
6
http://bit.ly/deprecating-apis
GregLTurnquist.com/springone2020
Just do this…
6
GregLTurnquist.com/springone2020
Just do this…
6
● “Never delete a
column”
GregLTurnquist.com/springone2020
Just do this…
6
● “Never delete a
column”
● Handle new
clients
GregLTurnquist.com/springone2020
Just do this…
6
● “Never delete a
column”
● Handle new
clients
● Support old
clients
GregLTurnquist.com/springone2020
Just do this…
6
● “Never delete a
column”
● Handle new
clients
● Support old
clients
● Everyone wins!
GregLTurnquist.com/springone2020
What else do you need?
GregLTurnquist.com/springone2020
What else do you need?
● Hypermedia controls
GregLTurnquist.com/springone2020
What else do you need?
● Hypermedia controls
● Instead of telling someone how to use your API on a portal…
GregLTurnquist.com/springone2020
What else do you need?
● Hypermedia controls
● Instead of telling someone how to use your API on a portal…
● …give them the controls right in the API
GregLTurnquist.com/springone2020
What else do you need?
● Hypermedia controls
● Instead of telling someone how to use your API on a portal…
● …give them the controls right in the API
● …using standard media types
GregLTurnquist.com/springone2020
What else do you need?
● Hypermedia controls
● Instead of telling someone how to use your API on a portal…
● …give them the controls right in the API
● …using standard media types
● It’s how the web functions
GregLTurnquist.com/springone2020
What else do you need?
● Hypermedia controls
● Instead of telling someone how to use your API on a portal…
● …give them the controls right in the API
● …using standard media types
● It’s how the web functions
● It’s the reason the web succeeded
GregLTurnquist.com/springone2020
What else do you need?
● Hypermedia controls
● Instead of telling someone how to use your API on a portal…
● …give them the controls right in the API
● …using standard media types
● It’s how the web functions
● It’s the reason the web succeeded
● The reason everyone today builds web apps
GregLTurnquist.com/springone2020
Just migrate from this…
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
…to this!
6
GregLTurnquist.com/springone2020
{
"id": 0,
"firstName": "Frodo",
"lastName": "Baggins",
"role": "ring bearer",
"name": "Frodo Baggins",
"_links": {
"self": {
"href": "http://localhost:8080/rest/employees/0"
},
"employees": {
"href": "http://localhost:8080/rest/employees"
}
},
…
So you can do this!
6
● New clients
GregLTurnquist.com/springone2020
{
"id": 0,
"firstName": "Frodo",
"lastName": "Baggins",
"role": "ring bearer",
"name": "Frodo Baggins",
"_links": {
"self": {
"href": "http://localhost:8080/rest/employees/0"
},
"employees": {
"href": "http://localhost:8080/rest/employees"
}
},
…
So you can do this!
6
● New clients
● Old clients
GregLTurnquist.com/springone2020
{
"id": 0,
"firstName": "Frodo",
"lastName": "Baggins",
"role": "ring bearer",
"name": "Frodo Baggins",
"_links": {
"self": {
"href": "http://localhost:8080/rest/employees/0"
},
"employees": {
"href": "http://localhost:8080/rest/employees"
}
},
…
So you can do this!
6
● New clients
● Old clients
● Navigate between related
components
GregLTurnquist.com/springone2020
…and this
6
…
"_templates": {
"default": {
"method": "put",
"properties": [
{
"name": "firstName"
},
{
"name": "id",
"readOnly": true
},
{
"name": "lastName"
},
{
"name": "name"
},
{
"name": "role"
}
]}}}
● New clients
● Old clients
● Navigate between related
components
● Effect change
GregLTurnquist.com/springone2020
…
"_templates": {
"default": {
"method": "put",
"properties": [
{
"name": "firstName"
},
{
"name": "id",
"readOnly": true
},
{
"name": "lastName"
},
{
"name": "name"
},
{
"name": "role"
}
]}}}
…and this
6
● New clients
● Old clients
● Navigate between related
components
● Effect change
GregLTurnquist.com/springone2020
…
"_templates": {
"default": {
"method": "put",
"properties": [
{
"name": "firstName"
},
{
"name": "id",
"readOnly": true
},
{
"name": "lastName"
},
{
"name": "name"
},
{
"name": "role"
}
]}}}
…and this
6
● New clients
● Old clients
● Navigate between related
components
● Effect change (even for
old clients!)
GregLTurnquist.com/springone2020
Consuming Hypermedia
GregLTurnquist.com/springone2020
What if…
GregLTurnquist.com/springone2020
What if…
● You wanted your client to consume hypermedia?
GregLTurnquist.com/springone2020
What if…
● You wanted your client to consume hypermedia?
● Ready to register all those messy message converters?
GregLTurnquist.com/springone2020
What if…
● You wanted your client to consume hypermedia?
● Ready to register all those messy message converters?
● Do you really want to look up how to customize RestTemplate (or
WebClient) to handle HAL, HAL-FORMS, etc., etc., etc.?
GregLTurnquist.com/springone2020
What if…
● You wanted your client to consume hypermedia?
● Ready to register all those messy message converters?
● Do you really want to look up how to customize RestTemplate (or
WebClient) to handle HAL, HAL-FORMS, etc., etc., etc.?
GregLTurnquist.com/springone2020
What if…
● You wanted your client to consume hypermedia?
● Ready to register all those messy message converters?
● Do you really want to look up how to customize RestTemplate (or
WebClient) to handle HAL, HAL-FORMS, etc., etc., etc.?
Spring HATEOAS has you covered!
GregLTurnquist.com/springone2020
RestTemplate support
GregLTurnquist.com/springone2020
RestTemplate support
GregLTurnquist.com/springone2020
RestTemplate support
GregLTurnquist.com/springone2020
RestTemplate support
GregLTurnquist.com/springone2020
RestTemplate support
GregLTurnquist.com/springone2020
We also support WebClient
● Inject WebClient.Builder into your app
● …and .build()!
GregLTurnquist.com/springone2020
We also support WebClient
● Inject WebClient.Builder into your app
● …and .build()!
GregLTurnquist.com/springone2020
We also support WebClient
GregLTurnquist.com/springone2020
We also support WebClient
GregLTurnquist.com/springone2020
We also support WebClient
GregLTurnquist.com/springone2020
We also support WebClient
😳Not in production!
GregLTurnquist.com/springone2020
Additional Features
GregLTurnquist.com/springone2020
Additional Features
● Spring WebFlux support
GregLTurnquist.com/springone2020
Additional Features
● Spring WebFlux support
● More media types (UBER+JSON, Collection+JSON, Your Own ™)
GregLTurnquist.com/springone2020
Additional Features
● Spring WebFlux support
● More media types (UBER+JSON, Collection+JSON, Your Own ™)
● Standardized errors with Problem+JSON (RFC-7807)
GregLTurnquist.com/springone2020
Additional Features
● Spring WebFlux support
● More media types (UBER+JSON, Collection+JSON, Your Own ™)
● Standardized errors with Problem+JSON (RFC-7807)
● Lots of performance improvements
GregLTurnquist.com/springone2020
Additional Features
● Spring WebFlux support
● More media types (UBER+JSON, Collection+JSON, Your Own ™)
● Standardized errors with Problem+JSON (RFC-7807)
● Lots of performance improvements
● Increasing community involvement
● JSON:API, Siren media types
● Document updates
● New ideas!
GregLTurnquist.com/springone2020
Additional Features
● Spring WebFlux support
● More media types (UBER+JSON, Collection+JSON, Your Own ™)
● Standardized errors with Problem+JSON (RFC-7807)
● Lots of performance improvements
● Increasing community involvement
● JSON:API, Siren media types
● Document updates
● New ideas!
GregLTurnquist.com/springone2020
Additional Features
● Spring WebFlux support
● More media types (UBER+JSON, Collection+JSON, Your Own ™)
● Standardized errors with Problem+JSON (RFC-7807)
● Lots of performance improvements
● Increasing community involvement
● JSON:API, Siren media types
● Document updates
● New ideas!
GregLTurnquist.com/springone2020
Additional Features
● Spring WebFlux support
● More media types (UBER+JSON, Collection+JSON, Your Own ™)
● Standardized errors with Problem+JSON (RFC-7807)
● Lots of performance improvements
● Increasing community involvement
● JSON:API, Siren media types
● Document updates
● New ideas!
Check it out!
GregLTurnquist.com/springone2020
Thank you SpringOne 2020!
Join me on #session-building-flexible-apis-with-spring-hateoas
for Q&A
Follow us on twitter @SpringHATEOAS
Visit GregLTurnquist.com/springone2020 to WIN a
paperback+ebook copy of Hacking with Spring Boot 2.3

More Related Content

PDF
PDF
Top-20 Agile Quotes
PDF
AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek Mah...
PPTX
AWS VS AZURE VS GCP.pptx
PDF
Prompt Engineering by Dr. Naveed.pdf
PPTX
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
PPTX
unleshing the the Power Azure Open AI - MCT Summit middle east 2024 Riyhad.pptx
Top-20 Agile Quotes
AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek Mah...
AWS VS AZURE VS GCP.pptx
Prompt Engineering by Dr. Naveed.pdf
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
unleshing the the Power Azure Open AI - MCT Summit middle east 2024 Riyhad.pptx

What's hot (20)

PPTX
Soutenance fin d'étude
PDF
Interpretable Machine Learning Using LIME Framework - Kasia Kulma (PhD), Data...
PPTX
Using CATs and REAs to inform decision-making
PPT
Conception d'un site web
PPT
SaaS Presentation
PPTX
2011 11-28 sccm-2012_technical_overview
PPTX
AWS VPC Fundamentals- Webinar
PDF
Fairness and Bias in Machine Learning
PDF
Migration vers le Cloud public
PPTX
Management 3.0 - Empower Teams
PDF
Alphorm.com Formation Java,avancé OCP (1Z0-804)
PPTX
QAOps e a sua impotância para a qualidade de software
PPTX
The Software-Defined Perimeter: Securing Network Access for the Modern Workforce
PPT
Understanding complexity - The Cynefin framework
PDF
Getting started with Site Reliability Engineering (SRE)
PPTX
Intranet Information Architecture
PDF
Gestion et Suivi des Projets informatique
PPTX
Azure security and Compliance
PDF
EPV_PCI DSS White Paper (3) Cyber Ark
PDF
Andreas Tschas - Pioneers - Building Startup Marketplaces in Europe & Asia - ...
Soutenance fin d'étude
Interpretable Machine Learning Using LIME Framework - Kasia Kulma (PhD), Data...
Using CATs and REAs to inform decision-making
Conception d'un site web
SaaS Presentation
2011 11-28 sccm-2012_technical_overview
AWS VPC Fundamentals- Webinar
Fairness and Bias in Machine Learning
Migration vers le Cloud public
Management 3.0 - Empower Teams
Alphorm.com Formation Java,avancé OCP (1Z0-804)
QAOps e a sua impotância para a qualidade de software
The Software-Defined Perimeter: Securing Network Access for the Modern Workforce
Understanding complexity - The Cynefin framework
Getting started with Site Reliability Engineering (SRE)
Intranet Information Architecture
Gestion et Suivi des Projets informatique
Azure security and Compliance
EPV_PCI DSS White Paper (3) Cyber Ark
Andreas Tschas - Pioneers - Building Startup Marketplaces in Europe & Asia - ...
Ad

Similar to Building Flexible APIs with Spring HATEOAS (20)

PPTX
Rest WebAPI with OData
PPTX
Best Practices for Architecting a Pragmatic Web API.
PPTX
Pragmatic REST APIs
PPT
RESTful SOA - 中科院暑期讲座
PDF
PPTX
RESTful Web Services
PDF
Restinpeaceosidays2011 111121093818-phpapp02
PPTX
Introduction to Web Services
PDF
What is REST?
PPTX
Restful webservice
PDF
Restful风格ž„web服务架构
PDF
Web Services
PPT
APITalkMeetupSharable
PPTX
L18 REST API Design
PPTX
Restful web services
PDF
REST Api with Asp Core
PPTX
A Deep Dive into RESTful API Design Part 2
PPTX
RESTful Web Services
PPTX
Http and REST APIs.
PPTX
RESTful design
Rest WebAPI with OData
Best Practices for Architecting a Pragmatic Web API.
Pragmatic REST APIs
RESTful SOA - 中科院暑期讲座
RESTful Web Services
Restinpeaceosidays2011 111121093818-phpapp02
Introduction to Web Services
What is REST?
Restful webservice
Restful风格ž„web服务架构
Web Services
APITalkMeetupSharable
L18 REST API Design
Restful web services
REST Api with Asp Core
A Deep Dive into RESTful API Design Part 2
RESTful Web Services
Http and REST APIs.
RESTful design
Ad

More from VMware Tanzu (20)

PDF
Spring into AI presented by Dan Vega 5/14
PDF
What AI Means For Your Product Strategy And What To Do About It
PDF
Make the Right Thing the Obvious Thing at Cardinal Health 2023
PPTX
Enhancing DevEx and Simplifying Operations at Scale
PDF
Spring Update | July 2023
PPTX
Platforms, Platform Engineering, & Platform as a Product
PPTX
Building Cloud Ready Apps
PDF
Spring Boot 3 And Beyond
PDF
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
PDF
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
PDF
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
PPTX
tanzu_developer_connect.pptx
PDF
Tanzu Virtual Developer Connect Workshop - French
PDF
Tanzu Developer Connect Workshop - English
PDF
Virtual Developer Connect Workshop - English
PDF
Tanzu Developer Connect - French
PDF
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
PDF
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
PDF
SpringOne Tour: The Influential Software Engineer
PDF
SpringOne Tour: Domain-Driven Design: Theory vs Practice
Spring into AI presented by Dan Vega 5/14
What AI Means For Your Product Strategy And What To Do About It
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Enhancing DevEx and Simplifying Operations at Scale
Spring Update | July 2023
Platforms, Platform Engineering, & Platform as a Product
Building Cloud Ready Apps
Spring Boot 3 And Beyond
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
tanzu_developer_connect.pptx
Tanzu Virtual Developer Connect Workshop - French
Tanzu Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
Tanzu Developer Connect - French
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: Domain-Driven Design: Theory vs Practice

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PDF
Digital Strategies for Manufacturing Companies
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
System and Network Administraation Chapter 3
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
medical staffing services at VALiNTRY
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Introduction to Artificial Intelligence
PDF
Design an Analysis of Algorithms I-SECS-1021-03
Understanding Forklifts - TECH EHS Solution
Digital Strategies for Manufacturing Companies
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
wealthsignaloriginal-com-DS-text-... (1).pdf
System and Network Administraation Chapter 3
CHAPTER 2 - PM Management and IT Context
How to Migrate SBCGlobal Email to Yahoo Easily
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Upgrade and Innovation Strategies for SAP ERP Customers
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
How to Choose the Right IT Partner for Your Business in Malaysia
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
medical staffing services at VALiNTRY
Odoo POS Development Services by CandidRoot Solutions
Softaken Excel to vCard Converter Software.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Introduction to Artificial Intelligence
Design an Analysis of Algorithms I-SECS-1021-03

Building Flexible APIs with Spring HATEOAS