fastest to mobile with scalatra + swagger
DESCRIPTION
Presentation by Tony Tam on using the Scalatra micro web framework with native support for Swagger. This gives the fastest possible server-to-mobile integration with ScalaTRANSCRIPT
![Page 1: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/1.jpg)
Fastest to Mobile!With Scalatra + Swagger!
!@fehguy!
![Page 2: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/2.jpg)
Swagger Philosophy!
![Page 3: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/3.jpg)
Swagger Philosophy!
Service documentation sucks!!
typically(
![Page 4: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/4.jpg)
Swagger Philosophy!• Communicating is too much work!– Users don’t want to write YOUR SDK!– If you’re good at Ruby, you suck at GO!
• Consumers need a contract!– Service logic doesn’t belong in the SDK!
• Services are plumbing!– We shouldn’t all be plumbers!– Business logic is your business!
![Page 5: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/5.jpg)
Swagger Philosophy!• Solved by machine-readable, discoverable
API contract!• Should speed up, not slow down
development process!• External services/proxies not required!
![Page 6: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/6.jpg)
What is Swagger?!• An interface to your service!– Described in JSON!
• It is a contract to your service!• Enables “bigotry-free” restful design with
emphasis on getting things done!– Many ways to delete a Pet!
![Page 7: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/7.jpg)
How does it work?!• Discoverable at runtime, not compile-time!• It’s just JSON!• No server integration required!– You can describe an API that’s not even yours!– Deploy anywhere! Put it on github!!– Swagger is JUST a way to describe an API!
![Page 8: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/8.jpg)
But Why?!• Machine-readable contract!– Description of *everything* the server
can do!– Server-controlled documentation!– Server/language/platform/deployment
agnostic!• Documentation, code generation,
client generation!– Like Headers for C, Interfaces for Java!
![Page 9: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/9.jpg)
How do you add Swagger?!• Static Files!– Manually crafted JSON!
• Heuristics!– Traffic inspection!
• Code inspection!– Code comments, static annotations!
• Runtime generation!It’s just JSON!!
![Page 10: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/10.jpg)
Swagger + Scalatra!• Scalatra is a Lightweight, High-
performance Micro web framework!• Extremely clean DSL!• First-class swagger support!• http://www.scalatra.org!
![Page 11: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/11.jpg)
Scalatra as a REST API!
![Page 12: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/12.jpg)
Scalatra as a REST API!
Content&Type&Nego,a,on&via&
json4s&
![Page 13: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/13.jpg)
Scalatra as a REST API!
Content&Type&Nego,a,on&via&
json4s&Simple&Rou,ng&
![Page 14: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/14.jpg)
Scalatra as a REST API!
Content&Type&Nego,a,on&via&
json4s&Simple&Rou,ng&
Param&Extrac,on&
![Page 15: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/15.jpg)
Scalatra as a REST API!
![Page 16: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/16.jpg)
Swagger + Scalatra!• Without Swagger Support!
• With Swagger Support!
![Page 17: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/17.jpg)
Swagger + Scalatra!• Auto-
generation of swagger JSON!!
![Page 18: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/18.jpg)
Swagger + Scalatra!• No ugly Java annotations!!
![Page 19: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/19.jpg)
Swagger + Scalatra!• Model descriptions!
![Page 20: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/20.jpg)
Swagger + Scalatra!• Model descriptions!
Type&safety&has&its&
benefits!&
![Page 21: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/21.jpg)
Swagger UI for “free”!
![Page 22: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/22.jpg)
Swagger UI for “free”!
Your&Boss&can&try&your&
API!&
![Page 23: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/23.jpg)
Going Moble!• If you are good at scala, you probably
suck at Objective C!
![Page 24: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/24.jpg)
Swagger + Mustache!• Typesafe conversion between swagger to
Objective C!
![Page 25: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/25.jpg)
Swagger + Mustache!• Typesafe conversion between swagger to
Objective C!
Templates&you&can&Tweak!&
![Page 26: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/26.jpg)
Mustache Templates!
![Page 27: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/27.jpg)
Mustache Templates!
![Page 28: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/28.jpg)
Sharing Libraries with Love!
![Page 29: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/29.jpg)
Other Mobile SDKs!• Android + Java!
![Page 30: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/30.jpg)
Other Mobile SDKs!• Android + Java!
![Page 31: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/31.jpg)
Other Mobile SDKs!• Javascript!
![Page 32: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/32.jpg)
Scalatra + Swagger!• Simplest DSL for REST APIs in Scala!• Minimal dependencies!• Tested at scale!• Not “hello world”!• Apache 2.0 everything!
![Page 33: Fastest to Mobile with Scalatra + Swagger](https://reader033.vdocuments.net/reader033/viewer/2022052505/554f9086b4c905d25b8b51a0/html5/thumbnails/33.jpg)
https://helloreverb.com/swagger/!!
Questions?!