SlideShare une entreprise Scribd logo
1  sur  25
API-First
development
From specification to code and back
Photo by Edho Pratama on Unsplash
Your host today
• Vasco Veloso
• Working in software development since 1996.
• Currently interested in designing software systems
and giving back to the community.
• Author and speaker.
• Portuguese living in the Netherlands.
linkedin.com/in/vascoveloso @vveloso
API-first design
The interface specification comes first.
• Dependencies are discovered.
• Data flows become apparent.
• Data needs can be challenged.
• Great input for threat modelling sessions.
3 Photo by Med Badr Chemmaoui on Unsplash
The problem…
There are many different ways to capture interface designs...
… that are not technical in nature …
… and all require further translation before implementation!
4
The problem…
Many API specifications have little value
• The interface is not complete.
• Examples are missing.
• Data formats or constraints are not defined.
• The specification is outdated.
• Code has changed but the specification did
not.
• There is little connection with the implementation.
5 Photo by Brett Jordan on Unsplash
API-First
Development
Photo by Andrew George on Unsplash
7
API-first development
The interface specification comes first.
Share
Control
Review
Stakeholders
CI/CD
8
API-first development
Capability enabler
cf. 2019 Accelerate State of DevOps Report (DORA)
✅
✅
9
API-first development
Teams with quality documentation are…
cf. 2020 Accelerate State of DevOps Report (DORA)
API-first development
The interface specification needs to be complete.
• All inputs are present.
• Data is properly described.
• Descriptions and examples are included.
Code needs to be generated from the
specification.
• Generate the server interface.
• Generate client code.
10
Photo
by
Julia
Joppien
on
Unsplash
API-first development
Advantages:
• The API specification is the single source of
truth.
• Code and specification are always in sync.
• Specification is good enough to generate code?
• Then it’s good enough to be used for
testing!
• Automatic implementation validation becomes
possible.
11 Photo by Glenn Carstens-Peters on Unsplash
 OpenAPI plugin
 Restler
 Schemathesis
12
API-first development
High-level workflow for developing the server:
Design API
Write OpenAPI
specification
Generate code
Implement & test
business rules
Deploy
Workflow
Refinement
Validate
implementation
Imagine a Java
service using
Spring…
Photo by Scott Graham on Unsplash
… with two operations …
paths:
'/hello':
get:
summary: 'Retrieve a greeting.'
operationId: 'getHelloWorld'
tags:
- "helloWorld"
responses:
'200':
description: 'OK: Returning a greeting.'
schema:
$ref: '#/definitions/Greeting'
'500':
description: 'Internal Server Error'
schema:
$ref: '#/definitions/ResponseError’
put:
summary: 'Set the greeting.'
operationId: 'putHelloWorld'
parameters:
- in: body
name: greeting
schema:
$ref: '#/definitions/Greeting'
required: true
description: 'The new greeting definition.'
tags:
- "helloWorld"
responses:
'200':
description: 'OK: The greeting was stored.'
schema:
$ref: '#/definitions/Greeting'
'500':
description: 'Internal Server Error'
schema:
$ref: '#/definitions/ResponseError'
… and two object definitions …
definitions:
ResponseError:
type: object
properties:
code:
type: string
example: 'E-1234'
description: 'Internal error code.'
required:
- code
Greeting:
type: object
properties:
text:
type: string
pattern: '[0-9a-z]'
maxLength: 100
example: 'Hello'
description: 'The greeting text.'
required:
- text
… using Maven with the OpenAPI plugin …
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.1.0</version>
<executions>
<execution>
<id>api-generation</id>
<goals><goal>generate</goal></goals>
<configuration>
<inputSpec>
${project.basedir}/src/main/openapi/spec.yaml
</inputSpec>
<output>${project.basedir}/gensrc</output>
<generatorName>spring</generatorName>
<modelPackage>api.example.model</modelPackage>
<apiPackage>api.example.resource</apiPackage>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>java8</dateLibrary>
<useTags>true</useTags>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
… generated an interface definition …
/**
* PUT /hello : Set the greeting.
*
* @param greeting The new greeting definition. (required)
* @return OK: The greeting was stored. (status code 200)
* or Internal Server Error: something has gone wrong. (status code 500)
*/
@ApiOperation(value = "Set the greeting.", nickname = "putHelloWorld", notes = "", response =
Greeting.class, tags={ "helloWorld", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK: The greeting was stored.", response = Greeting.class),
@ApiResponse(code = 500, message = "Internal Server Error: something has gone wrong.", response =
ResponseError.class) })
@PutMapping(
value = "/hello",
produces = { "application/json" },
consumes = { "application/json" }
)
default ResponseEntity<Greeting> putHelloWorld(@ApiParam(value = "The new greeting definition."
,required=true ) @Valid @RequestBody Greeting greeting) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
… with objects that can be validated.
public class Greeting {
@JsonProperty("text")
private String text;
public Greeting text(String text) {
this.text = text;
return this;
}
/**
* The greeting text.
* @return text
*/
@ApiModelProperty(example = "Hello", required = true, value = "The greeting text.")
@NotNull
@Pattern(regexp="[0-9a-z]") @Size(max=100)
public String getText() { return text; }
public void setText(String text) { this.text = text; }
}
Flipping it
around
Photo by Persnickety Prints on Unsplash
Flipping it around
• Requires a prototype-first
approach.
• Implies evolving the prototype!
• The specification slides to the
background.
20 Photo by Mark Konig on Unsplash
Flipping it around
• It is easier to use validations, data
structures or types that can’t be
represented in the specification.
• Focus shifts easily to the
implementation instead of the
API.
• API discussions may turn into
coding arguments.
21
Photo by Huey Images on Unsplash
Flipping it around
• It is easier to forget to add
annotations to the code.
• Details become absent from the
specification.
• The specification loses value.
22 Photo by Peter Pryharski on Unsplash
Now what?
Photo by Tom Ramalho on Unsplash
Key takeaways
24
Build
Build the OpenAPI file first
• Place all possible validations in the
OpenAPI file.
Generate
Generate code second
• API model DTOs are generated.
• Controller interface(s) are generated.
• Validations are translated into bean
validations.
• Default implementation ready with an
HTTP 501 response.
Extend
Extend the interface(s) with
the real controller(s).
Thank you!
Photo by Camylla Battani on Unsplash
linkedin.com/in/vascoveloso
@vveloso

Contenu connexe

Tendances

What is an API Gateway?
What is an API Gateway?What is an API Gateway?
What is an API Gateway?LunchBadger
 
API Business Models
API Business ModelsAPI Business Models
API Business ModelsJohn Musser
 
Building APIs with the OpenApi Spec
Building APIs with the OpenApi SpecBuilding APIs with the OpenApi Spec
Building APIs with the OpenApi SpecPedro J. Molina
 
Deep dive: Monetize your API Programs
Deep dive: Monetize your API ProgramsDeep dive: Monetize your API Programs
Deep dive: Monetize your API ProgramsApigee | Google Cloud
 
How to Execute a Successful API Strategy
How to Execute a Successful API StrategyHow to Execute a Successful API Strategy
How to Execute a Successful API StrategyMatt McLarty
 
Azure API Management
Azure API ManagementAzure API Management
Azure API ManagementDaniel Toomey
 
API Management architect presentation
API Management architect presentationAPI Management architect presentation
API Management architect presentationsflynn073
 
Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecAdam Paxton
 
Building Business Platforms Using an API Driven Marketplace
Building Business Platforms Using an  API Driven MarketplaceBuilding Business Platforms Using an  API Driven Marketplace
Building Business Platforms Using an API Driven MarketplaceWSO2
 
AWS Elastic Beanstalk - Running Microservices and Docker
AWS Elastic Beanstalk - Running Microservices and DockerAWS Elastic Beanstalk - Running Microservices and Docker
AWS Elastic Beanstalk - Running Microservices and DockerAmazon Web Services
 
Introduction to API
Introduction to APIIntroduction to API
Introduction to APIrajnishjha29
 
API Monetization – It Does Not Mean What You Think It Means. It Is Far More
API Monetization – It Does Not Mean What You Think It Means. It Is Far MoreAPI Monetization – It Does Not Mean What You Think It Means. It Is Far More
API Monetization – It Does Not Mean What You Think It Means. It Is Far MoreNordic APIs
 
API Integration For Building Software Applications Powerpoint Presentation Sl...
API Integration For Building Software Applications Powerpoint Presentation Sl...API Integration For Building Software Applications Powerpoint Presentation Sl...
API Integration For Building Software Applications Powerpoint Presentation Sl...SlideTeam
 
API Management in Digital Transformation
API Management in Digital TransformationAPI Management in Digital Transformation
API Management in Digital TransformationAditya Thatte
 
API Management Solution Powerpoint Presentation Slides
API Management Solution Powerpoint Presentation SlidesAPI Management Solution Powerpoint Presentation Slides
API Management Solution Powerpoint Presentation SlidesSlideTeam
 

Tendances (20)

Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
What is an API Gateway?
What is an API Gateway?What is an API Gateway?
What is an API Gateway?
 
API Business Models
API Business ModelsAPI Business Models
API Business Models
 
Building APIs with the OpenApi Spec
Building APIs with the OpenApi SpecBuilding APIs with the OpenApi Spec
Building APIs with the OpenApi Spec
 
API Governance
API Governance API Governance
API Governance
 
Deep dive: Monetize your API Programs
Deep dive: Monetize your API ProgramsDeep dive: Monetize your API Programs
Deep dive: Monetize your API Programs
 
Api types
Api typesApi types
Api types
 
How to Execute a Successful API Strategy
How to Execute a Successful API StrategyHow to Execute a Successful API Strategy
How to Execute a Successful API Strategy
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Azure API Management
Azure API ManagementAzure API Management
Azure API Management
 
API Management architect presentation
API Management architect presentationAPI Management architect presentation
API Management architect presentation
 
Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI Spec
 
Building Business Platforms Using an API Driven Marketplace
Building Business Platforms Using an  API Driven MarketplaceBuilding Business Platforms Using an  API Driven Marketplace
Building Business Platforms Using an API Driven Marketplace
 
AWS Elastic Beanstalk - Running Microservices and Docker
AWS Elastic Beanstalk - Running Microservices and DockerAWS Elastic Beanstalk - Running Microservices and Docker
AWS Elastic Beanstalk - Running Microservices and Docker
 
Introduction to API
Introduction to APIIntroduction to API
Introduction to API
 
API Monetization – It Does Not Mean What You Think It Means. It Is Far More
API Monetization – It Does Not Mean What You Think It Means. It Is Far MoreAPI Monetization – It Does Not Mean What You Think It Means. It Is Far More
API Monetization – It Does Not Mean What You Think It Means. It Is Far More
 
What's an api
What's an apiWhat's an api
What's an api
 
API Integration For Building Software Applications Powerpoint Presentation Sl...
API Integration For Building Software Applications Powerpoint Presentation Sl...API Integration For Building Software Applications Powerpoint Presentation Sl...
API Integration For Building Software Applications Powerpoint Presentation Sl...
 
API Management in Digital Transformation
API Management in Digital TransformationAPI Management in Digital Transformation
API Management in Digital Transformation
 
API Management Solution Powerpoint Presentation Slides
API Management Solution Powerpoint Presentation SlidesAPI Management Solution Powerpoint Presentation Slides
API Management Solution Powerpoint Presentation Slides
 

Similaire à API-first development

Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Fwdays
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
AngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesAngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesRainer Stropek
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developerscacois
 
Data models in Angular 1 & 2
Data models in Angular 1 & 2Data models in Angular 1 & 2
Data models in Angular 1 & 2Adam Klein
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP AnywayI Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP AnywayAll Things Open
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Adam Tomat
 
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP AnywayI Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP AnywayPOSSCON
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecturepostrational
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDmitry Vinnik
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Againjonknapp
 
Automating Performance Monitoring at Microsoft
Automating Performance Monitoring at MicrosoftAutomating Performance Monitoring at Microsoft
Automating Performance Monitoring at MicrosoftThousandEyes
 
Effectively Testing Services - Burlington Ruby Conf
Effectively Testing Services - Burlington Ruby ConfEffectively Testing Services - Burlington Ruby Conf
Effectively Testing Services - Burlington Ruby Confneal_kemp
 
JCD 2013 OCM Java Developer
JCD 2013 OCM Java DeveloperJCD 2013 OCM Java Developer
JCD 2013 OCM Java Developer益裕 張
 

Similaire à API-first development (20)

Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
 
Play framework
Play frameworkPlay framework
Play framework
 
REST API for your WP7 App
REST API for your WP7 AppREST API for your WP7 App
REST API for your WP7 App
 
Cqrs api v2
Cqrs api v2Cqrs api v2
Cqrs api v2
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
AngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesAngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile Services
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
Data models in Angular 1 & 2
Data models in Angular 1 & 2Data models in Angular 1 & 2
Data models in Angular 1 & 2
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP AnywayI Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019
 
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP AnywayI Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Again
 
Automating Performance Monitoring at Microsoft
Automating Performance Monitoring at MicrosoftAutomating Performance Monitoring at Microsoft
Automating Performance Monitoring at Microsoft
 
Effectively Testing Services - Burlington Ruby Conf
Effectively Testing Services - Burlington Ruby ConfEffectively Testing Services - Burlington Ruby Conf
Effectively Testing Services - Burlington Ruby Conf
 
JCD 2013 OCM Java Developer
JCD 2013 OCM Java DeveloperJCD 2013 OCM Java Developer
JCD 2013 OCM Java Developer
 

Dernier

notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 

Dernier (20)

notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 

API-first development

  • 1. API-First development From specification to code and back Photo by Edho Pratama on Unsplash
  • 2. Your host today • Vasco Veloso • Working in software development since 1996. • Currently interested in designing software systems and giving back to the community. • Author and speaker. • Portuguese living in the Netherlands. linkedin.com/in/vascoveloso @vveloso
  • 3. API-first design The interface specification comes first. • Dependencies are discovered. • Data flows become apparent. • Data needs can be challenged. • Great input for threat modelling sessions. 3 Photo by Med Badr Chemmaoui on Unsplash
  • 4. The problem… There are many different ways to capture interface designs... … that are not technical in nature … … and all require further translation before implementation! 4
  • 5. The problem… Many API specifications have little value • The interface is not complete. • Examples are missing. • Data formats or constraints are not defined. • The specification is outdated. • Code has changed but the specification did not. • There is little connection with the implementation. 5 Photo by Brett Jordan on Unsplash
  • 7. 7 API-first development The interface specification comes first. Share Control Review Stakeholders CI/CD
  • 8. 8 API-first development Capability enabler cf. 2019 Accelerate State of DevOps Report (DORA) ✅ ✅
  • 9. 9 API-first development Teams with quality documentation are… cf. 2020 Accelerate State of DevOps Report (DORA)
  • 10. API-first development The interface specification needs to be complete. • All inputs are present. • Data is properly described. • Descriptions and examples are included. Code needs to be generated from the specification. • Generate the server interface. • Generate client code. 10 Photo by Julia Joppien on Unsplash
  • 11. API-first development Advantages: • The API specification is the single source of truth. • Code and specification are always in sync. • Specification is good enough to generate code? • Then it’s good enough to be used for testing! • Automatic implementation validation becomes possible. 11 Photo by Glenn Carstens-Peters on Unsplash
  • 12.  OpenAPI plugin  Restler  Schemathesis 12 API-first development High-level workflow for developing the server: Design API Write OpenAPI specification Generate code Implement & test business rules Deploy Workflow Refinement Validate implementation
  • 13. Imagine a Java service using Spring… Photo by Scott Graham on Unsplash
  • 14. … with two operations … paths: '/hello': get: summary: 'Retrieve a greeting.' operationId: 'getHelloWorld' tags: - "helloWorld" responses: '200': description: 'OK: Returning a greeting.' schema: $ref: '#/definitions/Greeting' '500': description: 'Internal Server Error' schema: $ref: '#/definitions/ResponseError’ put: summary: 'Set the greeting.' operationId: 'putHelloWorld' parameters: - in: body name: greeting schema: $ref: '#/definitions/Greeting' required: true description: 'The new greeting definition.' tags: - "helloWorld" responses: '200': description: 'OK: The greeting was stored.' schema: $ref: '#/definitions/Greeting' '500': description: 'Internal Server Error' schema: $ref: '#/definitions/ResponseError'
  • 15. … and two object definitions … definitions: ResponseError: type: object properties: code: type: string example: 'E-1234' description: 'Internal error code.' required: - code Greeting: type: object properties: text: type: string pattern: '[0-9a-z]' maxLength: 100 example: 'Hello' description: 'The greeting text.' required: - text
  • 16. … using Maven with the OpenAPI plugin … <plugin> <groupId>org.openapitools</groupId> <artifactId>openapi-generator-maven-plugin</artifactId> <version>5.1.0</version> <executions> <execution> <id>api-generation</id> <goals><goal>generate</goal></goals> <configuration> <inputSpec> ${project.basedir}/src/main/openapi/spec.yaml </inputSpec> <output>${project.basedir}/gensrc</output> <generatorName>spring</generatorName> <modelPackage>api.example.model</modelPackage> <apiPackage>api.example.resource</apiPackage> <configOptions> <interfaceOnly>true</interfaceOnly> <dateLibrary>java8</dateLibrary> <useTags>true</useTags> </configOptions> </configuration> </execution> </executions> </plugin>
  • 17. … generated an interface definition … /** * PUT /hello : Set the greeting. * * @param greeting The new greeting definition. (required) * @return OK: The greeting was stored. (status code 200) * or Internal Server Error: something has gone wrong. (status code 500) */ @ApiOperation(value = "Set the greeting.", nickname = "putHelloWorld", notes = "", response = Greeting.class, tags={ "helloWorld", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK: The greeting was stored.", response = Greeting.class), @ApiResponse(code = 500, message = "Internal Server Error: something has gone wrong.", response = ResponseError.class) }) @PutMapping( value = "/hello", produces = { "application/json" }, consumes = { "application/json" } ) default ResponseEntity<Greeting> putHelloWorld(@ApiParam(value = "The new greeting definition." ,required=true ) @Valid @RequestBody Greeting greeting) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }
  • 18. … with objects that can be validated. public class Greeting { @JsonProperty("text") private String text; public Greeting text(String text) { this.text = text; return this; } /** * The greeting text. * @return text */ @ApiModelProperty(example = "Hello", required = true, value = "The greeting text.") @NotNull @Pattern(regexp="[0-9a-z]") @Size(max=100) public String getText() { return text; } public void setText(String text) { this.text = text; } }
  • 19. Flipping it around Photo by Persnickety Prints on Unsplash
  • 20. Flipping it around • Requires a prototype-first approach. • Implies evolving the prototype! • The specification slides to the background. 20 Photo by Mark Konig on Unsplash
  • 21. Flipping it around • It is easier to use validations, data structures or types that can’t be represented in the specification. • Focus shifts easily to the implementation instead of the API. • API discussions may turn into coding arguments. 21 Photo by Huey Images on Unsplash
  • 22. Flipping it around • It is easier to forget to add annotations to the code. • Details become absent from the specification. • The specification loses value. 22 Photo by Peter Pryharski on Unsplash
  • 23. Now what? Photo by Tom Ramalho on Unsplash
  • 24. Key takeaways 24 Build Build the OpenAPI file first • Place all possible validations in the OpenAPI file. Generate Generate code second • API model DTOs are generated. • Controller interface(s) are generated. • Validations are translated into bean validations. • Default implementation ready with an HTTP 501 response. Extend Extend the interface(s) with the real controller(s).
  • 25. Thank you! Photo by Camylla Battani on Unsplash linkedin.com/in/vascoveloso @vveloso