SlideShare a Scribd company logo
CONTRACT
DRIVEN
DEVELOPMENT
GAP BETWEEN PRODUCER AND
CONSUMERS
▪ No way to sync them
▪ Have to code two mechanically matching versions
▪ Changes on one side or the other may lead to errors that will only be
exposed with live interactions
PROBLEM – CLIENT/SERVER TEAMS
DEPEND ON EACH OTHER
▪ No standard format to describe API
▪ Client team needed functioning server to do most of their work
▪ Had to spin up full application to get data integration
▪ Changes that were not communicated, leading to bugs
▪ Maintaining separate versions was cumbersome
▪ In monolith, division is between UI and server, but once you get into
microservice world, it is among all services that call each other
API CONTRACT
▪ Agreed upon standard language understandable by teams and
▪ Teams could work independently, as long as they design to the contract
▪ Can create stubs based on the contract with whatever behavior you
want
▪ Server
▪ Client
▪ Contract can be explicitly versioned
▪ Easy to compare the versions of the contract to detect changes and communicate
differences
OPEN API/SWAGGER
(HTTPS://SWAGGER.IO/)
▪ Industry standard language for describing APIs
▪ JSON or YAML dialects
▪ Tool ecosystem
▪ Swagger editor (https://editor.swagger.io)
▪ Restlet studio (https://studio.restlet.com)
▪ Swagger UI (https://petstore.swagger.io)
▪ Swagger-diff (https://github.com/civisanalytics/swagger-diff)
SWAGGER DEFINES
▪ https://swagger.io/docs/specification/basic-structure/
▪ Paths
▪ Operations
▪ Models
▪ Security Authentication
GENERATING CONTRACT FROM CODE
▪ SpringFox (http://springfox.github.io/springfox/)
▪ Can generate without running server by creating SpringTest that makes a
MockMvc call to the swagger path
▪ Swagger Jax-rs (https://github.com/swagger-api/swagger-
core/wiki/swagger-core-jax-rs-project-setup-1.5.x)
CONTRACT MUTATION TESTING
▪ Set your base api version
▪ On build:
▪ Generate spec from current code
▪ Pull base spec version from repo
▪ Compare spec versions
▪ On no difference, do nothing
▪ Non-breaking changes, update version
▪ Breaking change, fail build
▪ You can accommodate breaking changes by setting base api version
▪ Diff tool provides exactly what was changed in new version
SPEC AS MODEL
▪ Most of the parts of a CRUD server and all of the parts of a client are
boilerplate
▪ The only difference is the domain model and operations, which are fully described
by the contract
▪ Dozens of templates already created for both server stubs and clients
▪ Easy to generate your own template
IMPLEMENTATION OF CONTRACT
BECOMES IRRELEVANT
▪ Servers or clients can be Java, Python, node, whatever you want
▪ Swap out an implementation with confidence
▪ Choose your communication protocol
▪ HTTP REST
▪ WSDL
▪ Protocal buffers
▪ Sync/Aync
SPLIT YOUR MONOLITH
▪ Grab the contract for a bounded part of your domain
▪ New microservice for it
▪ Replace old calls with calls to client
VERSIONED CLIENTS
▪ API structure no longer that important as long as the functionality is
maintained
▪ Including api version with client calls allows for out of date detection
▪ Can send error message with updating instructions
▪ Can enable registered translations to service outdated clients by coercing into
later versions
TEST CLIENTS
▪ Replace external http calls to in-memory datastores
▪ Can pull from examples embedded in contract to provide built in
expected functionality
MY SERVER SETUP
▪ Generates Spring Boot app
▪ Controllers that correspond to api spec
▪ Base Interface, Dynamic Interface, Base Implementation, Dynamic Implementation
▪ Services for CRUD + stubs for additional operations (same components as
Controllers)
▪ Spring Data Repositories
▪ Models with validation
EXTENDING THE CONTRACT
▪ Swagger allows for vendor extensions
▪ Add a key value pair with the key starting with x- prefix
▪ Example:
▪ EntityOperation (x-entity-operation)
▪ entity
▪ display
▪ operation
▪ subtype
▪ subtype-display
AUTOGENERATED UI
▪ Takes the swagger contract and generates section for each model
▪ Section has table, details panel, and linked subtypes
BEYOND IMPERATIVE API CONTRACTS
▪ What do we actually want to model?
▪ Declare that, let your generators handle the boilerplate mechanics and
stub what cannot be captured
MY DREAM
▪ Effective model of domain entity graphs
▪ Fully captured semantic relationships
▪ Hierarchies supported automatically with nested set model
▪ Linked versus owned versus shared versus whatever else
▪ Semantic domain modeling
▪ Unique keys allow transparent specification of entity
▪ Properties identified as dimensions, comparable, dependent, etc.
▪ Contexts for models that need it, like for workflows
▪ Operations attached to entities and contexts
▪ All of the mechanics of this is hidden from consumers. They just works
with entities
Steve Erdman
steve.erdman77@gmail.com
@MrSquicky

More Related Content

PPTX
Intro to openfaas
PDF
OpenFaaS
PDF
Introduction to WSO2 Developer Studio
PPTX
CI/CD with Bitbucket pipelines
PDF
community day 2013 - Daniel talks about camunda BPM technical vision
PPTX
Feature flag launchdarkly
PDF
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
PDF
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Intro to openfaas
OpenFaaS
Introduction to WSO2 Developer Studio
CI/CD with Bitbucket pipelines
community day 2013 - Daniel talks about camunda BPM technical vision
Feature flag launchdarkly
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]

What's hot (20)

PDF
Vagrant Plugin development
PPTX
Build your own dev tools with salesforce cli plugin generator
PDF
Bring api manager into your stack
PDF
Best Practices with WSO2 Developer Studio
PPT
Migrating to git
PDF
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
PPTX
The next step from Microsoft - Vnext (Srdjan Poznic)
PDF
Hands on Ruby on Rails
PPTX
The fall of the BizTalk Architect – From something abstract to something useful
PPTX
Building Reliable Applications Using React, .NET & Azure
PPTX
Backward Compatibility Developer's Guide in Magento 2
PDF
CamundaCon 2018: Using Zeebe with Spring Boot and Apache Camel (Holisticon)
PPT
TDD with ASP.NET MVC 1.0
KEY
Is OSGi modularity always worth it?
PPTX
Workflows and Digital Signatures
PPTX
ASP.NET 5 Overview
PDF
Itb2018 integrating mvc into legacy
PDF
A Gentle Introduction to Functions-as-a-Service
PDF
TRAX technical highlights
PPTX
Lightning Web Components
Vagrant Plugin development
Build your own dev tools with salesforce cli plugin generator
Bring api manager into your stack
Best Practices with WSO2 Developer Studio
Migrating to git
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
The next step from Microsoft - Vnext (Srdjan Poznic)
Hands on Ruby on Rails
The fall of the BizTalk Architect – From something abstract to something useful
Building Reliable Applications Using React, .NET & Azure
Backward Compatibility Developer's Guide in Magento 2
CamundaCon 2018: Using Zeebe with Spring Boot and Apache Camel (Holisticon)
TDD with ASP.NET MVC 1.0
Is OSGi modularity always worth it?
Workflows and Digital Signatures
ASP.NET 5 Overview
Itb2018 integrating mvc into legacy
A Gentle Introduction to Functions-as-a-Service
TRAX technical highlights
Lightning Web Components
Ad

Similar to Contract driven development (20)

PPTX
Swagger - Making REST APIs friendlier
PDF
Jcon 2017 How to use Swagger to develop REST applications
PPTX
Swagger APIs for Humans and Robots (Gluecon)
PPTX
How to generate a rest application - DevFest Vienna 2016
PPTX
Scaling with swagger
PDF
How to generate a REST CXF3 application from Swagger ApacheConEU 2016
PDF
Swagger - Make your REST APIs accessible - Victor Trakhtenberg
PPTX
Document your rest api using swagger - Devoxx 2015
PDF
Swagger for-your-api
PPTX
Rest API with Swagger and NodeJS
PPTX
Another API-Blueprint, RAML and Swagger Comparison
PDF
Fastest to Mobile with Scalatra + Swagger
PPTX
API Design first with Swagger
PDF
Swagger code motion talk
PPTX
Introducing swagger
PPTX
Swagger - make your API accessible
PPTX
Building REST APIs with Django
PDF
"Design First" APIs with Swagger
PDF
API Description Languages: Which Is The Right One For Me?
PDF
SGCE 2015 REST APIs
Swagger - Making REST APIs friendlier
Jcon 2017 How to use Swagger to develop REST applications
Swagger APIs for Humans and Robots (Gluecon)
How to generate a rest application - DevFest Vienna 2016
Scaling with swagger
How to generate a REST CXF3 application from Swagger ApacheConEU 2016
Swagger - Make your REST APIs accessible - Victor Trakhtenberg
Document your rest api using swagger - Devoxx 2015
Swagger for-your-api
Rest API with Swagger and NodeJS
Another API-Blueprint, RAML and Swagger Comparison
Fastest to Mobile with Scalatra + Swagger
API Design first with Swagger
Swagger code motion talk
Introducing swagger
Swagger - make your API accessible
Building REST APIs with Django
"Design First" APIs with Swagger
API Description Languages: Which Is The Right One For Me?
SGCE 2015 REST APIs
Ad

More from Stephen Erdman (6)

PPTX
Next generation testing
ODP
Against Morality: A Case for Heresy
ODP
The abstract art of software development
PPT
Why do complex software application projects drag?
PPTX
Dependency Injection and Aspect Oriented Programming presentation
PPTX
Google web toolkit web conference presenation
Next generation testing
Against Morality: A Case for Heresy
The abstract art of software development
Why do complex software application projects drag?
Dependency Injection and Aspect Oriented Programming presentation
Google web toolkit web conference presenation

Recently uploaded (20)

PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
PDF
Approach and Philosophy of On baking technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Monthly Chronicles - July 2025
Advanced Soft Computing BINUS July 2025.pdf
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.
Approach and Philosophy of On baking technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Network Security Unit 5.pdf for BCA BBA.
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Contract driven development

  • 2. GAP BETWEEN PRODUCER AND CONSUMERS ▪ No way to sync them ▪ Have to code two mechanically matching versions ▪ Changes on one side or the other may lead to errors that will only be exposed with live interactions
  • 3. PROBLEM – CLIENT/SERVER TEAMS DEPEND ON EACH OTHER ▪ No standard format to describe API ▪ Client team needed functioning server to do most of their work ▪ Had to spin up full application to get data integration ▪ Changes that were not communicated, leading to bugs ▪ Maintaining separate versions was cumbersome ▪ In monolith, division is between UI and server, but once you get into microservice world, it is among all services that call each other
  • 4. API CONTRACT ▪ Agreed upon standard language understandable by teams and ▪ Teams could work independently, as long as they design to the contract ▪ Can create stubs based on the contract with whatever behavior you want ▪ Server ▪ Client ▪ Contract can be explicitly versioned ▪ Easy to compare the versions of the contract to detect changes and communicate differences
  • 5. OPEN API/SWAGGER (HTTPS://SWAGGER.IO/) ▪ Industry standard language for describing APIs ▪ JSON or YAML dialects ▪ Tool ecosystem ▪ Swagger editor (https://editor.swagger.io) ▪ Restlet studio (https://studio.restlet.com) ▪ Swagger UI (https://petstore.swagger.io) ▪ Swagger-diff (https://github.com/civisanalytics/swagger-diff)
  • 7. GENERATING CONTRACT FROM CODE ▪ SpringFox (http://springfox.github.io/springfox/) ▪ Can generate without running server by creating SpringTest that makes a MockMvc call to the swagger path ▪ Swagger Jax-rs (https://github.com/swagger-api/swagger- core/wiki/swagger-core-jax-rs-project-setup-1.5.x)
  • 8. CONTRACT MUTATION TESTING ▪ Set your base api version ▪ On build: ▪ Generate spec from current code ▪ Pull base spec version from repo ▪ Compare spec versions ▪ On no difference, do nothing ▪ Non-breaking changes, update version ▪ Breaking change, fail build ▪ You can accommodate breaking changes by setting base api version ▪ Diff tool provides exactly what was changed in new version
  • 9. SPEC AS MODEL ▪ Most of the parts of a CRUD server and all of the parts of a client are boilerplate ▪ The only difference is the domain model and operations, which are fully described by the contract ▪ Dozens of templates already created for both server stubs and clients ▪ Easy to generate your own template
  • 10. IMPLEMENTATION OF CONTRACT BECOMES IRRELEVANT ▪ Servers or clients can be Java, Python, node, whatever you want ▪ Swap out an implementation with confidence ▪ Choose your communication protocol ▪ HTTP REST ▪ WSDL ▪ Protocal buffers ▪ Sync/Aync
  • 11. SPLIT YOUR MONOLITH ▪ Grab the contract for a bounded part of your domain ▪ New microservice for it ▪ Replace old calls with calls to client
  • 12. VERSIONED CLIENTS ▪ API structure no longer that important as long as the functionality is maintained ▪ Including api version with client calls allows for out of date detection ▪ Can send error message with updating instructions ▪ Can enable registered translations to service outdated clients by coercing into later versions
  • 13. TEST CLIENTS ▪ Replace external http calls to in-memory datastores ▪ Can pull from examples embedded in contract to provide built in expected functionality
  • 14. MY SERVER SETUP ▪ Generates Spring Boot app ▪ Controllers that correspond to api spec ▪ Base Interface, Dynamic Interface, Base Implementation, Dynamic Implementation ▪ Services for CRUD + stubs for additional operations (same components as Controllers) ▪ Spring Data Repositories ▪ Models with validation
  • 15. EXTENDING THE CONTRACT ▪ Swagger allows for vendor extensions ▪ Add a key value pair with the key starting with x- prefix ▪ Example: ▪ EntityOperation (x-entity-operation) ▪ entity ▪ display ▪ operation ▪ subtype ▪ subtype-display
  • 16. AUTOGENERATED UI ▪ Takes the swagger contract and generates section for each model ▪ Section has table, details panel, and linked subtypes
  • 17. BEYOND IMPERATIVE API CONTRACTS ▪ What do we actually want to model? ▪ Declare that, let your generators handle the boilerplate mechanics and stub what cannot be captured
  • 18. MY DREAM ▪ Effective model of domain entity graphs ▪ Fully captured semantic relationships ▪ Hierarchies supported automatically with nested set model ▪ Linked versus owned versus shared versus whatever else ▪ Semantic domain modeling ▪ Unique keys allow transparent specification of entity ▪ Properties identified as dimensions, comparable, dependent, etc. ▪ Contexts for models that need it, like for workflows ▪ Operations attached to entities and contexts ▪ All of the mechanics of this is hidden from consumers. They just works with entities