Design-Driven
API Development
Sokichi Fujita
Generation of
API Description Languages
Swagger
RAML
API-Blueprint
API Description Languages
• XML
• WADL, RADL, WSDL2
• JSON
• Swagger, I/O Docs
• YAML
• Swagger, RAML
• Markdown
• API-Blu...
Why
Server
Code
API
Document
SDKs
Specification
Document
as a reference
Manually developed resources
Server
Code
API
Document
SDKs
Specification
Document
Samples
Mock Server
API Console
Test code
Manually developed resources...
Server
Code
API
Document
SDKs
Samples
Mock Server
API Console
Test code
Manually developed resources
incorrect
or
doesn’t ...
To avoid publishing un-updatable APIs
• API changing is not so difficult,
• if you can ignore lots of resources.
• e.g. SDK...
Design-Driven
Development
Server
Code
API
Document
SDKs
API
Schema
generate/validate
SamplesAPI ConsoleMock Server
Non-manually developed resources
...
Demo
Demo
• Hacker News API
• Swagger-Node
• Hacker News Client
• React, Swagger-js, Electron
Swagger-nodeElectron
*.yaml
Swagger
Editor
Express
express-swagger
controller
React
Swagger-js
- component
DidMount etc.
s...
Server : Swagger-Node
swagger project create [project name]
swagger project edit
1. Generate a template for express | hapi...
filename of the controllers
name of the controller
Client : Swagger-js
var swagger = new SwaggerClient({
url: "http://localhost:8080/swagger.yaml",
success: function() {
swa...
Client : Swagger-js with React
var self = this;
var swagger = new SwaggerClient({
url: "http://localhost:8080/swagger.yaml...
Design Driven API Development
Upcoming SlideShare
Loading in...5
×

Design Driven API Development

231

Published on

Slide for API Meetup #9

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
231
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Design Driven API Development

  1. 1. Design-Driven API Development Sokichi Fujita
  2. 2. Generation of API Description Languages
  3. 3. Swagger
  4. 4. RAML
  5. 5. API-Blueprint
  6. 6. API Description Languages • XML • WADL, RADL, WSDL2 • JSON • Swagger, I/O Docs • YAML • Swagger, RAML • Markdown • API-Blueprint Popular in GitHub, NPM, …
  7. 7. Why
  8. 8. Server Code API Document SDKs Specification Document as a reference Manually developed resources
  9. 9. Server Code API Document SDKs Specification Document Samples Mock Server API Console Test code Manually developed resources as a reference
  10. 10. Server Code API Document SDKs Samples Mock Server API Console Test code Manually developed resources incorrect or doesn’t exist Sometimes…
  11. 11. To avoid publishing un-updatable APIs • API changing is not so difficult, • if you can ignore lots of resources. • e.g. SDKs, Documents, Tests, Clients, …
  12. 12. Design-Driven Development
  13. 13. Server Code API Document SDKs API Schema generate/validate SamplesAPI ConsoleMock Server Non-manually developed resources codegenswagger-UIswagger-node swagger-spec swagger-editor swagger-js
  14. 14. Demo
  15. 15. Demo • Hacker News API • Swagger-Node • Hacker News Client • React, Swagger-js, Electron
  16. 16. Swagger-nodeElectron *.yaml Swagger Editor Express express-swagger controller React Swagger-js - component DidMount etc. state render (Dynamically JS SDK) Cheerio https://news.ycombinator.com
  17. 17. Server : Swagger-Node swagger project create [project name] swagger project edit 1. Generate a template for express | hapi | restify | sails 2. Write API specs vim api/controller/[controller file name].js 3. Write controllers that meet the API specs
  18. 18. filename of the controllers name of the controller
  19. 19. Client : Swagger-js var swagger = new SwaggerClient({ url: "http://localhost:8080/swagger.yaml", success: function() { swagger.apis.hackernews.fetch( {page:api}, {responseContentType: 'application/ json'}, function(res) { : }); } }); Dynamically Swagger SDK for JavaScript
  20. 20. Client : Swagger-js with React var self = this; var swagger = new SwaggerClient({ url: "http://localhost:8080/swagger.yaml", success: function() { swagger.apis.hackernews.fetch( {page:api}, {responseContentType: 'application/json'}, function(res) { self.setState({data:res.obj}); }); } }); at componentDidMount
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×