Bruno Pedro

13 February 2014

BarcelonaJS

API Code Generation
http://www.flickr.com/photos/iprozac/3609806359/
Bruno Pedro
Web and Cloud Computing Technologist with
over ten years’ experience. CTO of GetApp.
Editor at APIUX.com.
http://brunopedro.com/
Summary
• Postman

• API Blueprint

• Code generation

• Questions
Postman
• Powerful HTTP client

• Chrome application

• Advanced request builder

• History, Collections, Authentication,
Documentation, …



http://www.getpostman.com/
Postman
Postman
Postman
Postman
Postman
Postman
Postman
API Blueprint
• Web API Language

• Markdown syntax

• Documentation + method description

• Powerful tooling




http://apiblueprint.org/
!
API Blueprint
• Testing with Dredd




• HTML docs with aglio




• Mock server with Contractor
API Blueprint
API Blueprint
Code Generation
Code Generation
• collection






• markdown






• functions
Code Generation
• collection






• markdown





nodeunit

• functions
postman2apiblueprint
• Reads Postman collection JSON

• API endpoints

• HTTP methods (GET, POST, etc)

• Headers

• Parameters

• Converts to API Blueprint
postman2apiblueprint
apiblueprint2nodejs
• Reads API Blueprint markdown

• Uses protagonist

• Converts markdown into JSON




• Generates nodejs code from JSON
!
apiblueprint2nodejs
Future work
• Explore Postman Collection runner

• Richer output to API Blueprint

• Better code generation

• Reverse operation?
Questions?
Thank you!

API Code Generation