SlideShare a Scribd company logo
TED EPSTEIN, FOUNDER & CEO | Ted.Epstein@RepreZen.com
1COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED.
API Contract as Code
Rapid Development with OpenAPI
First Swagger Value Proposition
• Keep your API docs in sync with implementation!
… and look cool
doing it!
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 2
Code-First
• Or “API Code-as-Contract”
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 3
So why not all code, all the time?
• Not Cross-functional team-friendly
◦ Coders aren’t always the best communicators.
◦ Tech writers don’t want to maintain embedded code comments
(and you may not want them to).
• De-emphasizes API design
◦ Outside-in design, from the user’s perspective
◦ As a distinct process
◦ Leveraging available tools for docs, mocking, testing, etc.
◦ Conscious, collaborative focus to API design quality
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 4
But there’s another reason…
• Leverage
◦ Higher productivity
◦ Greater expressive power
• An OpenAPI Description is code!
◦ High focus, high abstraction
◦ Generated code can be a scaffold to get started quickly…
◦ … and it can be first-class code.
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 5
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 6
API Contract-As-Code
Development Workflow
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 7
API Contract-As-Code
Development Workflow
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 8
API Contract-As-Code
Development Workflow
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 9
API Contract-As-Code
Development Workflow
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 10
API Contract-As-Code
Development Workflow
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 11
API Contract-As-Code
Development Workflow
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 12
API Contract-As-Code
Development Workflow
Demo
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 13
Achieving Separation
• “Write-once” codegen for implementation
• Delegation
• Interface / Implementation
• Abstract Base Class / Concrete Implementation
• Dependency Injection
• Dynamic merge (e.g. C# partial classes)
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 14
Project Layout
• All in one project
• One project for API spec, generate into
second project for implementation
• Generated library
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 15
Validating Implementation vs. Spec
Implementation Completeness:
“Every method is implemented”
◦ Use static typing when available
◦ Use generated or dynamic unit tests for
dynamic languages
Specification Completeness
“Every method implemented is in the
specification”
◦ Harder to enforce, but easy to prevent.
◦ Static code analysis or reflective tests could
be useful
Correctness
Methods implement the contract
(mechanics)
Methods have the expected outcome
(semantics)
◦ Use testing tools or frameworks, same as as
you would with code-first
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 16
OpenAPI 3.0 - More Descriptive Power,
New Possibilities…-
• Links
• Callbacks
• oneOf / anyOf Schemas
• Component Model
COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 17

More Related Content

PDF
API first approach for frontend developers
PDF
排隊 Paiduei App, | React Native | iOS | Android
PPTX
Introduction to NativeScript - BuildTruly Native Apps using JavaScript
PPTX
Native Script by Sebastian Witalec
PPTX
Branching Your Way to Low-Code Perfection
PDF
Getting Developers hooked on your API by Nicolas Garnier at Codemotion Dubai
PPTX
ng-conf NativeScript and Angular 2 Workshop
PDF
Rabix Benten: A language server for Common Workflow Language
API first approach for frontend developers
排隊 Paiduei App, | React Native | iOS | Android
Introduction to NativeScript - BuildTruly Native Apps using JavaScript
Native Script by Sebastian Witalec
Branching Your Way to Low-Code Perfection
Getting Developers hooked on your API by Nicolas Garnier at Codemotion Dubai
ng-conf NativeScript and Angular 2 Workshop
Rabix Benten: A language server for Common Workflow Language

What's hot (20)

PDF
Lessons Learned from Revamping Our Doc Site
PPTX
NativeScript - Open source framework for building truly native mobile apps wi...
PPT
apidays LIVE New York 2021 - Designing API's: Less Data is More! by Damir Svr...
PDF
API SDK Development – Lessons Learned
PDF
Benten: An experimental language server for CWL
PDF
Swagger for-your-api
PDF
Continuous integration for Ruby on Rails
PPTX
API First Workflow: How could we have better API Docs through DevOps pipeline
PPTX
Introduction to xamarin
PDF
E031202024029
PDF
An overview of devportal technologies and their (dis)advantages
PDF
Leaping Forward: Finding The Future of Your API Docs
PDF
Advancing Your API Strategy in an Infrastructure World
PPTX
API-first development
PDF
Rest api best practices – comprehensive handbook
PDF
OpenAPI Spec at Google (Open API Initiative Meetup on 2016-09-15)
PPTX
Ciprian redinciuc continuous integration with jenkins for i os
PDF
Capacitor 2.0 Launch
PDF
Ionic in 30
PDF
Capacitor 1.0 launch
Lessons Learned from Revamping Our Doc Site
NativeScript - Open source framework for building truly native mobile apps wi...
apidays LIVE New York 2021 - Designing API's: Less Data is More! by Damir Svr...
API SDK Development – Lessons Learned
Benten: An experimental language server for CWL
Swagger for-your-api
Continuous integration for Ruby on Rails
API First Workflow: How could we have better API Docs through DevOps pipeline
Introduction to xamarin
E031202024029
An overview of devportal technologies and their (dis)advantages
Leaping Forward: Finding The Future of Your API Docs
Advancing Your API Strategy in an Infrastructure World
API-first development
Rest api best practices – comprehensive handbook
OpenAPI Spec at Google (Open API Initiative Meetup on 2016-09-15)
Ciprian redinciuc continuous integration with jenkins for i os
Capacitor 2.0 Launch
Ionic in 30
Capacitor 1.0 launch
Ad

Similar to API Contract as Code: Rapid Development with OpenAPI (20)

PDF
Why You Should Be Doing Contract-First API Development
PDF
Spec-first API Design for Speed and Safety
PPTX
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
PPTX
OpenAPI v.Next - Events, Alternative Schemas & the Road Ahead
PPTX
Design and Evolution of APIs in Microservice Architecture
PDF
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
PDF
APIdays Singapore 2019 - Bringing OpenAPI to devOps, Vincenzo Chianese, Softw...
PDF
Space Camp June 2022 - API First.pdf
PDF
Apidays Paris 2023 - API design first: A case for a better language, Emmanu...
PPTX
Reaching 1 Million APIs and what to do when we get there
PDF
apidays Paris 2022 - OpenAPI: An Early Design Feedback Engine, Lukas Rosensto...
PDF
apidays LIVE Australia 2020 - Contract-first API development with Spot by Fra...
PDF
Apidays Paris 2023 - Why API Contracts Matter, Stève Sfartz, Cisco
PPTX
The Arazzo Specification: A New Way to Describe API Workflows - Budhaditya Bh...
PDF
Api design best practice
PDF
Dependency Down, Flexibility Up – The Benefits of API-First Development
PPTX
API Versioning for Zero Downtime | Devoxx Belgium 2017
PDF
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
PPTX
Building a REST API for Longevity
PDF
API Docs Made Right / RAML - Swagger rant
Why You Should Be Doing Contract-First API Development
Spec-first API Design for Speed and Safety
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
OpenAPI v.Next - Events, Alternative Schemas & the Road Ahead
Design and Evolution of APIs in Microservice Architecture
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Singapore 2019 - Bringing OpenAPI to devOps, Vincenzo Chianese, Softw...
Space Camp June 2022 - API First.pdf
Apidays Paris 2023 - API design first: A case for a better language, Emmanu...
Reaching 1 Million APIs and what to do when we get there
apidays Paris 2022 - OpenAPI: An Early Design Feedback Engine, Lukas Rosensto...
apidays LIVE Australia 2020 - Contract-first API development with Spot by Fra...
Apidays Paris 2023 - Why API Contracts Matter, Stève Sfartz, Cisco
The Arazzo Specification: A New Way to Describe API Workflows - Budhaditya Bh...
Api design best practice
Dependency Down, Flexibility Up – The Benefits of API-First Development
API Versioning for Zero Downtime | Devoxx Belgium 2017
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
Building a REST API for Longevity
API Docs Made Right / RAML - Swagger rant
Ad

More from SmartBear (20)

PPTX
Enforcing Your Organization's API Design Standards with SwaggerHub
PPTX
Introducing OpenAPI Version 3.1
PPTX
IATA Open Air: How API Standardization Enables Innovation in the Airline Indu...
PPTX
The State of API 2020 Webinar – Exploring Trends, Tools & Takeaways to Drive ...
PPTX
How LISI Automotive Accelerated Application Delivery with SwaggerHub
PPTX
Standardising APIs: Powering the Platform Economy in Financial Services
PPTX
Getting Started with API Standardization in SwaggerHub
PPTX
Adopting a Design-First Approach to API Development with SwaggerHub
PPTX
Standardizing APIs Across Your Organization with Swagger and OAS | A SmartBea...
PPTX
Effective API Lifecycle Management
PDF
The API Lifecycle Series: Exploring Design-First and Code-First Approaches to...
PPTX
Artificial intelligence for faster and smarter software testing - Galway Mee...
PDF
Successfully Implementing BDD in an Agile World
PPTX
The Best Kept Secrets of Code Review | SmartBear Webinar
PPTX
How Capital One Scaled API Design to Deliver New Products Faster
PPTX
Testing Without a GUI Using TestComplete
PPTX
Hidden Treasure - TestComplete Script Extensions
PDF
How Bdd Can Save Agile
PPTX
API Automation and TDD to Implement Master Data Survivorship Rules
PDF
Support Rapid Systems Growth with a Design-First Approach
Enforcing Your Organization's API Design Standards with SwaggerHub
Introducing OpenAPI Version 3.1
IATA Open Air: How API Standardization Enables Innovation in the Airline Indu...
The State of API 2020 Webinar – Exploring Trends, Tools & Takeaways to Drive ...
How LISI Automotive Accelerated Application Delivery with SwaggerHub
Standardising APIs: Powering the Platform Economy in Financial Services
Getting Started with API Standardization in SwaggerHub
Adopting a Design-First Approach to API Development with SwaggerHub
Standardizing APIs Across Your Organization with Swagger and OAS | A SmartBea...
Effective API Lifecycle Management
The API Lifecycle Series: Exploring Design-First and Code-First Approaches to...
Artificial intelligence for faster and smarter software testing - Galway Mee...
Successfully Implementing BDD in an Agile World
The Best Kept Secrets of Code Review | SmartBear Webinar
How Capital One Scaled API Design to Deliver New Products Faster
Testing Without a GUI Using TestComplete
Hidden Treasure - TestComplete Script Extensions
How Bdd Can Save Agile
API Automation and TDD to Implement Master Data Survivorship Rules
Support Rapid Systems Growth with a Design-First Approach

Recently uploaded (20)

PPT
Introduction Database Management System for Course Database
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
System and Network Administraation Chapter 3
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Nekopoi APK 2025 free lastest update
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Transform Your Business with a Software ERP System
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
System and Network Administration Chapter 2
Introduction Database Management System for Course Database
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
System and Network Administraation Chapter 3
Operating system designcfffgfgggggggvggggggggg
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
How to Migrate SBCGlobal Email to Yahoo Easily
Wondershare Filmora 15 Crack With Activation Key [2025
Reimagine Home Health with the Power of Agentic AI​
Design an Analysis of Algorithms II-SECS-1021-03
Nekopoi APK 2025 free lastest update
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Transform Your Business with a Software ERP System
Digital Systems & Binary Numbers (comprehensive )
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Computer Software and OS of computer science of grade 11.pptx
System and Network Administration Chapter 2

API Contract as Code: Rapid Development with OpenAPI

  • 1. TED EPSTEIN, FOUNDER & CEO | Ted.Epstein@RepreZen.com 1COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. API Contract as Code Rapid Development with OpenAPI
  • 2. First Swagger Value Proposition • Keep your API docs in sync with implementation! … and look cool doing it! COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 2
  • 3. Code-First • Or “API Code-as-Contract” COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 3
  • 4. So why not all code, all the time? • Not Cross-functional team-friendly ◦ Coders aren’t always the best communicators. ◦ Tech writers don’t want to maintain embedded code comments (and you may not want them to). • De-emphasizes API design ◦ Outside-in design, from the user’s perspective ◦ As a distinct process ◦ Leveraging available tools for docs, mocking, testing, etc. ◦ Conscious, collaborative focus to API design quality COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 4
  • 5. But there’s another reason… • Leverage ◦ Higher productivity ◦ Greater expressive power • An OpenAPI Description is code! ◦ High focus, high abstraction ◦ Generated code can be a scaffold to get started quickly… ◦ … and it can be first-class code. COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 5
  • 6. COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 6 API Contract-As-Code Development Workflow
  • 7. COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 7 API Contract-As-Code Development Workflow
  • 8. COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 8 API Contract-As-Code Development Workflow
  • 9. COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 9 API Contract-As-Code Development Workflow
  • 10. COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 10 API Contract-As-Code Development Workflow
  • 11. COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 11 API Contract-As-Code Development Workflow
  • 12. COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 12 API Contract-As-Code Development Workflow
  • 13. Demo COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 13
  • 14. Achieving Separation • “Write-once” codegen for implementation • Delegation • Interface / Implementation • Abstract Base Class / Concrete Implementation • Dependency Injection • Dynamic merge (e.g. C# partial classes) COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 14
  • 15. Project Layout • All in one project • One project for API spec, generate into second project for implementation • Generated library COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 15
  • 16. Validating Implementation vs. Spec Implementation Completeness: “Every method is implemented” ◦ Use static typing when available ◦ Use generated or dynamic unit tests for dynamic languages Specification Completeness “Every method implemented is in the specification” ◦ Harder to enforce, but easy to prevent. ◦ Static code analysis or reflective tests could be useful Correctness Methods implement the contract (mechanics) Methods have the expected outcome (semantics) ◦ Use testing tools or frameworks, same as as you would with code-first COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 16
  • 17. OpenAPI 3.0 - More Descriptive Power, New Possibilities…- • Links • Callbacks • oneOf / anyOf Schemas • Component Model COPYRIGHT © 2017, MODELSOLV, INC. | ALL RIGHTS RESERVED. 17