API Code Generation

5,888 views
5,474 views

Published on

How to generate nodejs API consumer code from a Postman collections, with the help of the API Blueprint.

Published in: Technology

API Code Generation

  1. 1. Bruno Pedro 13 February 2014 BarcelonaJS API Code Generation http://www.flickr.com/photos/iprozac/3609806359/
  2. 2. Bruno Pedro Web and Cloud Computing Technologist with over ten years’ experience. CTO of GetApp. Editor at APIUX.com. http://brunopedro.com/
  3. 3. Summary • Postman • API Blueprint • Code generation • Questions
  4. 4. Postman • Powerful HTTP client • Chrome application • Advanced request builder • History, Collections, Authentication, Documentation, …
 
 http://www.getpostman.com/
  5. 5. Postman
  6. 6. Postman
  7. 7. Postman
  8. 8. Postman
  9. 9. Postman
  10. 10. Postman
  11. 11. Postman
  12. 12. API Blueprint • Web API Language • Markdown syntax • Documentation + method description • Powerful tooling
 
 http://apiblueprint.org/ !
  13. 13. API Blueprint • Testing with Dredd
 
 • HTML docs with aglio
 
 • Mock server with Contractor
  14. 14. API Blueprint
  15. 15. API Blueprint
  16. 16. Code Generation
  17. 17. Code Generation • collection
 
 
 • markdown
 
 
 • functions
  18. 18. Code Generation • collection
 
 
 • markdown
 
 
 nodeunit • functions
  19. 19. postman2apiblueprint • Reads Postman collection JSON • API endpoints • HTTP methods (GET, POST, etc) • Headers • Parameters
 • Converts to API Blueprint
  20. 20. postman2apiblueprint
  21. 21. apiblueprint2nodejs • Reads API Blueprint markdown • Uses protagonist • Converts markdown into JSON
 
 • Generates nodejs code from JSON !
  22. 22. apiblueprint2nodejs
  23. 23. Future work • Explore Postman Collection runner • Richer output to API Blueprint • Better code generation • Reverse operation?
  24. 24. Questions? Thank you!

×