Empathic API
Design
CORNEIL DU PLESSIS
About Me
● Programmer since 1985
● Smallest to very large systems.
● Cobol, Pascal, Algol, C/C++, Java, Scala, Groovy and other JVM
languages.
● Scientific instrumentation, Sports event management, Mining, Banking,
Treasury and Insurance.
● Software Architect (coding included)
Quote
The Opposite of Empathy is Contempt.
Anonymous
Introduction
● What is an API?
● Considerations in API Design
● Why Empathy in API Design?
● Documenting your API
What is an API?
Definition:
Application Programming Interface
Examples:
– C stdlib.h
– Java Standard Library
– Spring Framework
– Google Maps API
– Facebook Graph API
Considerations in API Design
Quote:
Everything should be made as simple as possible, but no simpler
Albert Einstein
Considerations in API Design
Joshua Bloch
Principal Software Engineer at Google
How to Design a Good API and Why it Matters
– Easy to learn
– Easy to use, even without documentation
– Hard to misuse
– Easy to read and maintain code that uses it
– Sufficiently powerful to satisfy requirements
– Easy to extend
– Appropriate to audience
Considerations in API Design
● Simple
● Unambiguous
● Usage oriented
● Asset
● Discipline
Why Empathy in API Design?
● When your audience doesn’t have an alternative.
● When your audience is human.
● Because they depend on it.
● Because they gave you money.
Documenting your API
● Code is the document
● Tools
– Javadoc
– Doxygen
– Asciidoc
● Rest API
– RAML
– Swagger
– Spring Rest Docs
RAML
● RESTful API Modeling Language
● RAML 0.8
– YAML
– Like RFC
● RAML 1.0
– YAML 1.2
– Template URI
– Data types
– Annotations
– Security Schemes
RAML
#%RAML 1.0
title: Spring Data Rest Demo API
version: v1
protocols: [ HTTP ]
baseUri: http://localhost/api
mediaType: application/json
types:
RAML - Types
types:
User:
type: object
properties:
userId: string
emailAddress: string
fullName: string
dateOfBirth: date-only
hasImage: boolean
Group:
type: object
properties:
description: string
groupName: string
groupOwner: User
RAML – Operations
/users:
post:
body:
type: User
description: Create a User
responses:
200:
body:
type: User
RAML - Operations
/users/{id}:
get:
description: Get a User
responses:
200:
body:
type: User
404:
description: User doesn't exist
/users/search:
get:
queryParameters:
input:
description: Sub string to match
type: string
responses:
200:
body:
type: User[]
Swagger
● Swagger 2.0
● JSON / YAML
● JSON Schema
Swagger – Springfox
● Swagger from Annotations
● Spring MVC - Rest
● Swagger UI
Springfox - Configuration
@EnableSwagger2
@Configuration
public class SwaggerConfiguration {
@Bean
public Docket swaggerSpringMvcPlugin() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfo("Spring Data Rest Demo",
"Demonstrate Spring Data RestController",
"2",
"/",
new Contact("Corneil du Plessis", "",
"corneil.duplessis@gmail.com"),
"",
"");
}
}
Springfox - Configuration
@EnableWebMvc
@Configuration
public class WebApplicationConfiguration
extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
registry.addResourceHandler("/swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations(
"classpath:/META-INF/resources/webjars/");
}
}
Swagger - Springfox
@RequestMapping(path = "/users/{id}", method = RequestMethod.GET)
@ApiOperation(value = "Get User")
@ApiResponses({
@ApiResponse(code = 200, message = "Success", response =
User.class),
@ApiResponse(code = 404, message = "Entity Not Found")
})
public ResponseEntity<User> getUser(@PathVariable("id") Long id)
throws EntityNotFound {
User user = userRepository.findOne(id);
if (user == null) {
throw new EntityNotFound();
}
return ResponseEntity.ok(user);
}
Springfox - UI
Demo
Spring Rest Docs
● Documentation driven by Unit Tests
– Asciidoc
– Snippets
– Conventions
– Test Methods
– Feedback on completeness
Spring Rest Docs
Demo
Conclusion
Questions?
Resources
– https://github.com/corneil/spring-data-rest-angular-demo
– http://raml.org
– http://swagger.io
– http://springfox.github.io/springfox
– https://projects.spring.io/spring-restdocs

More Related Content

PPTX
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
PPTX
What is Swagger?
PDF
API Docs Made Right / RAML - Swagger rant
PPTX
Introduction To C#
PDF
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
PPTX
Mule raml
PPTX
Another API-Blueprint, RAML and Swagger Comparison
PPTX
New Things in C# 6.0
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
What is Swagger?
API Docs Made Right / RAML - Swagger rant
Introduction To C#
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
Mule raml
Another API-Blueprint, RAML and Swagger Comparison
New Things in C# 6.0

What's hot (20)

PPTX
C# language
PDF
apidays LIVE London 2021 - Designing APIs: Less Data is More by Damir Svrtan,...
PDF
Kotlin multiplataforma
PDF
Why companies like Google, Alibaba and UOL choose Flutter
PPTX
Level 3 REST Makes Your API Browsable
PDF
Ashok_Vardhan_Cheemakurthy
PPT
Go Programming Language - Learning The Go Lang way
PDF
API Documentation Meetup 2016, London
PPTX
Entity Framework Today (May 2012)
PDF
YutianLi_resume
PPTX
RAML - APIs By Design
PDF
To SDK or not to SDK?
PDF
API Description Languages
PDF
排隊 Paiduei App, | React Native | iOS | Android
PDF
apidays LIVE Hong Kong 2021 - Less Data is More by Damir Svrtan, Netflix
PPTX
What is Kotlin Multiplaform? Why & How?
PPTX
.Net language support
PDF
API Description Languages: Which Is The Right One For Me?
DOCX
Inna Manni newest resume
PPTX
API Athens Meetup - API standards 25-6-2014
C# language
apidays LIVE London 2021 - Designing APIs: Less Data is More by Damir Svrtan,...
Kotlin multiplataforma
Why companies like Google, Alibaba and UOL choose Flutter
Level 3 REST Makes Your API Browsable
Ashok_Vardhan_Cheemakurthy
Go Programming Language - Learning The Go Lang way
API Documentation Meetup 2016, London
Entity Framework Today (May 2012)
YutianLi_resume
RAML - APIs By Design
To SDK or not to SDK?
API Description Languages
排隊 Paiduei App, | React Native | iOS | Android
apidays LIVE Hong Kong 2021 - Less Data is More by Damir Svrtan, Netflix
What is Kotlin Multiplaform? Why & How?
.Net language support
API Description Languages: Which Is The Right One For Me?
Inna Manni newest resume
API Athens Meetup - API standards 25-6-2014
Ad

Similar to Empathic API-Design (20)

PDF
Documenting RESTful APIs with Spring REST Docs
PDF
Test-Driven Documentation for your REST(ful) service
PPTX
API workshop: Introduction to APIs (TC Camp)
PDF
API Description Languages
PDF
"Design First" APIs with Swagger
PPTX
API Athens Meetup - API standards 25-6-2014
PPTX
Building a REST API for Longevity
PDF
Chris Mathias Presents Advanced API Design Considerations at LA CTO Forum
PPTX
API Description Languages: Which is the Right One for Me?
PPTX
API Description Languages: Which is the Right One for Me?
PPTX
Swagger for startups
PDF
Swagger: Restful documentation that won't put you to sleep
PPTX
Spring Test Framework
PDF
Swagger for-your-api
PPTX
Reaching 1 Million APIs and what to do when we get there
PPTX
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
PDF
Let your REST API talk @java2days
PDF
PyCon PL 2014 executable api
PDF
building-rest-api-with-spring-boot-in28minutes-presentation.pdf
PPTX
Mule soft meetup_4_mty_online_oct_2020
Documenting RESTful APIs with Spring REST Docs
Test-Driven Documentation for your REST(ful) service
API workshop: Introduction to APIs (TC Camp)
API Description Languages
"Design First" APIs with Swagger
API Athens Meetup - API standards 25-6-2014
Building a REST API for Longevity
Chris Mathias Presents Advanced API Design Considerations at LA CTO Forum
API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?
Swagger for startups
Swagger: Restful documentation that won't put you to sleep
Spring Test Framework
Swagger for-your-api
Reaching 1 Million APIs and what to do when we get there
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Let your REST API talk @java2days
PyCon PL 2014 executable api
building-rest-api-with-spring-boot-in28minutes-presentation.pdf
Mule soft meetup_4_mty_online_oct_2020
Ad

More from Corneil du Plessis (15)

PPTX
Sweet Streams (Are made of this)
PPTX
Cloud Native Applications for Cloud Foundry using Spring Cloud : A Workshop
PPTX
QueryDSL - Lightning Talk
PPTX
Enhancements in Java 9 Streams
PPTX
Reactive Spring 5
ODP
Performance Comparison JVM Languages
ODP
Microservices Patterns and Anti-Patterns
ODP
Consume Spring Data Rest with Angularjs
ODP
The Evolution of Java
ODP
Gradle: The Build System you have been waiting for!
ODP
Polyglot persistence with Spring Data
ODP
Data repositories
PPT
Gradle: The Build system you have been waiting for
ODP
Dependency Injection in Spring in 10min
ODP
Spring Data in 10 minutes
Sweet Streams (Are made of this)
Cloud Native Applications for Cloud Foundry using Spring Cloud : A Workshop
QueryDSL - Lightning Talk
Enhancements in Java 9 Streams
Reactive Spring 5
Performance Comparison JVM Languages
Microservices Patterns and Anti-Patterns
Consume Spring Data Rest with Angularjs
The Evolution of Java
Gradle: The Build System you have been waiting for!
Polyglot persistence with Spring Data
Data repositories
Gradle: The Build system you have been waiting for
Dependency Injection in Spring in 10min
Spring Data in 10 minutes

Recently uploaded (20)

PPTX
Viber For Windows 25.7.1 Crack + Serial Keygen
PDF
Guide to Food Delivery App Development.pdf
PDF
Microsoft Office 365 Crack Download Free
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PDF
CapCut PRO for PC Crack New Download (Fully Activated 2025)
PDF
Website Design & Development_ Professional Web Design Services.pdf
PPTX
Presentation by Samna Perveen And Subhan Afzal.pptx
PPTX
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
PDF
E-Commerce Website Development Companyin india
PDF
BoxLang Dynamic AWS Lambda - Japan Edition
PDF
AI Guide for Business Growth - Arna Softech
PDF
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
PDF
What Makes a Great Data Visualization Consulting Service.pdf
PPTX
Computer Software - Technology and Livelihood Education
PDF
AI-Powered Fuzz Testing: The Future of QA
PDF
Internet Download Manager IDM Crack powerful download accelerator New Version...
PPTX
ROI Analysis for Newspaper Industry with Odoo ERP
PPTX
Download Adobe Photoshop Crack 2025 Free
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PPTX
Python is a high-level, interpreted programming language
Viber For Windows 25.7.1 Crack + Serial Keygen
Guide to Food Delivery App Development.pdf
Microsoft Office 365 Crack Download Free
ROI from Efficient Content & Campaign Management in the Digital Media Industry
CapCut PRO for PC Crack New Download (Fully Activated 2025)
Website Design & Development_ Professional Web Design Services.pdf
Presentation by Samna Perveen And Subhan Afzal.pptx
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
E-Commerce Website Development Companyin india
BoxLang Dynamic AWS Lambda - Japan Edition
AI Guide for Business Growth - Arna Softech
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
What Makes a Great Data Visualization Consulting Service.pdf
Computer Software - Technology and Livelihood Education
AI-Powered Fuzz Testing: The Future of QA
Internet Download Manager IDM Crack powerful download accelerator New Version...
ROI Analysis for Newspaper Industry with Odoo ERP
Download Adobe Photoshop Crack 2025 Free
CCleaner 6.39.11548 Crack 2025 License Key
Python is a high-level, interpreted programming language

Empathic API-Design

  • 2. About Me ● Programmer since 1985 ● Smallest to very large systems. ● Cobol, Pascal, Algol, C/C++, Java, Scala, Groovy and other JVM languages. ● Scientific instrumentation, Sports event management, Mining, Banking, Treasury and Insurance. ● Software Architect (coding included)
  • 3. Quote The Opposite of Empathy is Contempt. Anonymous
  • 4. Introduction ● What is an API? ● Considerations in API Design ● Why Empathy in API Design? ● Documenting your API
  • 5. What is an API? Definition: Application Programming Interface Examples: – C stdlib.h – Java Standard Library – Spring Framework – Google Maps API – Facebook Graph API
  • 6. Considerations in API Design Quote: Everything should be made as simple as possible, but no simpler Albert Einstein
  • 7. Considerations in API Design Joshua Bloch Principal Software Engineer at Google How to Design a Good API and Why it Matters – Easy to learn – Easy to use, even without documentation – Hard to misuse – Easy to read and maintain code that uses it – Sufficiently powerful to satisfy requirements – Easy to extend – Appropriate to audience
  • 8. Considerations in API Design ● Simple ● Unambiguous ● Usage oriented ● Asset ● Discipline
  • 9. Why Empathy in API Design? ● When your audience doesn’t have an alternative. ● When your audience is human. ● Because they depend on it. ● Because they gave you money.
  • 10. Documenting your API ● Code is the document ● Tools – Javadoc – Doxygen – Asciidoc ● Rest API – RAML – Swagger – Spring Rest Docs
  • 11. RAML ● RESTful API Modeling Language ● RAML 0.8 – YAML – Like RFC ● RAML 1.0 – YAML 1.2 – Template URI – Data types – Annotations – Security Schemes
  • 12. RAML #%RAML 1.0 title: Spring Data Rest Demo API version: v1 protocols: [ HTTP ] baseUri: http://localhost/api mediaType: application/json types:
  • 13. RAML - Types types: User: type: object properties: userId: string emailAddress: string fullName: string dateOfBirth: date-only hasImage: boolean Group: type: object properties: description: string groupName: string groupOwner: User
  • 14. RAML – Operations /users: post: body: type: User description: Create a User responses: 200: body: type: User
  • 15. RAML - Operations /users/{id}: get: description: Get a User responses: 200: body: type: User 404: description: User doesn't exist /users/search: get: queryParameters: input: description: Sub string to match type: string responses: 200: body: type: User[]
  • 16. Swagger ● Swagger 2.0 ● JSON / YAML ● JSON Schema
  • 17. Swagger – Springfox ● Swagger from Annotations ● Spring MVC - Rest ● Swagger UI
  • 18. Springfox - Configuration @EnableSwagger2 @Configuration public class SwaggerConfiguration { @Bean public Docket swaggerSpringMvcPlugin() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()); } private ApiInfo apiInfo() { return new ApiInfo("Spring Data Rest Demo", "Demonstrate Spring Data RestController", "2", "/", new Contact("Corneil du Plessis", "", "[email protected]"), "", ""); } }
  • 19. Springfox - Configuration @EnableWebMvc @Configuration public class WebApplicationConfiguration extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/swagger-ui.html") .addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**") .addResourceLocations( "classpath:/META-INF/resources/webjars/"); } }
  • 20. Swagger - Springfox @RequestMapping(path = "/users/{id}", method = RequestMethod.GET) @ApiOperation(value = "Get User") @ApiResponses({ @ApiResponse(code = 200, message = "Success", response = User.class), @ApiResponse(code = 404, message = "Entity Not Found") }) public ResponseEntity<User> getUser(@PathVariable("id") Long id) throws EntityNotFound { User user = userRepository.findOne(id); if (user == null) { throw new EntityNotFound(); } return ResponseEntity.ok(user); }
  • 22. Spring Rest Docs ● Documentation driven by Unit Tests – Asciidoc – Snippets – Conventions – Test Methods – Feedback on completeness
  • 24. Conclusion Questions? Resources – https://github.com/corneil/spring-data-rest-angular-demo – http://raml.org – http://swagger.io – http://springfox.github.io/springfox – https://projects.spring.io/spring-restdocs

Editor's Notes