Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
QUICK RECIPE:
HOW TO END MANUAL REST-API
CLIENT CODING
@johannes_fiala
Calling APIs manually
$.getJSON(backend_url ???, data ???, function(response) {
response.???
}
Calling APIs
using a generated SDK
Ingredients
 Swagger API docs
 need to be supplied by the API provider
 can be provided automatically using e.g. Spring...
Sample REST model using Spring
Boot + Springfox
Swagger API example
Model definition
Steps to generate
Javascript client code
 Prepare
 Checkout Swagger-Codegen
 Generate
 Generate JS client stubs
 Code...
JS Mustache templates for
Swagger-Codegen
Generate client code using
Swagger-Codegen
 java -i http://localhost:8080/v2/api-docs
-l javascript -o c:/myproject
Generated Javascript Model:
Code completion for User
Code completion in HTML
Code completion
for all API operations
Current state of
Javascript support
 API support
 Jsdoc comments + type hints
 Model support
 Jsdoc comments + type hi...
It‘s not yet perfect …
 Support forTypescript
 data types, inheritance, interfaces, enumerations
 More annotations / de...
It‘s up to you …
Thank you for your
attention!
 Swagger-Codegen:
 https://github.com/swagger-api/swagger-codegen
(master / scheduled for ...
Resources
 Swagger
http://swagger.io/
 Swagger-Codegen
https://github.com/swagger-api/swagger-codegen
 Spring Boot
http...
Upcoming SlideShare
Loading in …5
×

Rest api code completion for javascript - dotjs 2015

1,880 views

Published on

Get REST API code completion for Javascript using Swagger-Codegen
@dotjs 2015

Published in: Technology
  • Be the first to comment

Rest api code completion for javascript - dotjs 2015

  1. 1. QUICK RECIPE: HOW TO END MANUAL REST-API CLIENT CODING @johannes_fiala
  2. 2. Calling APIs manually $.getJSON(backend_url ???, data ???, function(response) { response.??? }
  3. 3. Calling APIs using a generated SDK
  4. 4. Ingredients  Swagger API docs  need to be supplied by the API provider  can be provided automatically using e.g. Spring Boot + Swagger-Springfox  see Swagger.io –Tools & Integrations  You can also do “API first“ using Swagger-Editor  Swagger-Codegen  generate client code in 20+ languages  Static Javascript support requested in 2013  … added during dotjs 2015  … available since 2015-12-07 05:00
  5. 5. Sample REST model using Spring Boot + Springfox
  6. 6. Swagger API example Model definition
  7. 7. Steps to generate Javascript client code  Prepare  Checkout Swagger-Codegen  Generate  Generate JS client stubs  Code  Enjoy code completion for the REST API in Javascript & HTML
  8. 8. JS Mustache templates for Swagger-Codegen
  9. 9. Generate client code using Swagger-Codegen  java -i http://localhost:8080/v2/api-docs -l javascript -o c:/myproject
  10. 10. Generated Javascript Model:
  11. 11. Code completion for User
  12. 12. Code completion in HTML
  13. 13. Code completion for all API operations
  14. 14. Current state of Javascript support  API support  Jsdoc comments + type hints  Model support  Jsdoc comments + type hints  Enumeration support  Getter/Setter support  Constructor for required properties  Print using toJson()  Plain JS + AMD usage supported
  15. 15. It‘s not yet perfect …  Support forTypescript  data types, inheritance, interfaces, enumerations  More annotations / decorator support  See Java BeanValidationAPI: @NotNull, @Size, @Min, @Max, …  ???
  16. 16. It‘s up to you …
  17. 17. Thank you for your attention!  Swagger-Codegen:  https://github.com/swagger-api/swagger-codegen (master / scheduled for release 2.1.5)  Full demo for Spring Boot: Devoxx 2015 @Youtube  Questions? Contact: @johannes_fiala
  18. 18. Resources  Swagger http://swagger.io/  Swagger-Codegen https://github.com/swagger-api/swagger-codegen  Spring Boot http://projects.spring.io/spring-boot/  Swagger-Springfox https://github.com/springfox/springfox  Swagger-UI https://github.com/swagger-api/swagger-ui

×