SlideShare a Scribd company logo
1 of 106
Download to read offline
Type-safe Web APIs with
Protocol Buffers in Swift
1 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Hi, I'm Yusuke
@kitasuke
2 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
I'm going to talk about...
→ What Protocol Buffers are
3 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
I'm going to talk about...
→ What Protocol Buffers are
→ Pros and Cons
4 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
I'm going to talk about...
→ What Protocol Buffers are
→ Pros and Cons
→ Where to start
5 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Web APIs
6 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
JSON7 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Request
JSON ➡ Data
8 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
let json = ["id": 1]
let data = try? JSONSerialization.data(withJSONObject: json,
options: .prettyPrinted)
var request = URLRequest(url: url)
request.httpBody = data
9 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Response
Data ➡ JSON
10 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
// {"user": {"name": "Yusuke"}}
URLSession.shared.dataTask(with: request) { (data, _, _) in
let json = (try? JSONSerialization.jsonObject(with: data!,
options: .allowFragments)) as? [AnyHashable: Any]
let user = json?["user"] as? [AnyHashable: Any]
let name = user?["name"] as? String
}
11 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
{"isTyped": false,
"status": "disappointed"}
12 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
[AnyHashable: Any]
13 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Any?
14 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
!
15 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Protocol
Buffersa.k.a protobuf
16 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Protocol buffers are Google's language-neutral,
platform-neutral, extensible mechanism for
serializing structured data – think XML, but smaller,
faster, and simpler.
— Google
17 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Serialization format
- think JSON, but
smaller, faster and safer
— Yusuke
18 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Serialization
Format
19 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Why are Protocol Buffers
a big deal?
20 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Request
JSON ➡ Data
21 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
let json = ["id": 1]
let data = try? JSONSerialization.data(withJSONObject: json,
options: .prettyPrinted)
var request = URLRequest(url: url)
request.httpBody = data
22 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Request
JSON ➡ Data
23 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Request
UserRequest ➡ Data
24 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
// custom type
let userRequest = UserRequest.with {
$0.id = 1
}
let body = try? body.serializedData()
var request = URLRequest(url: url)
request.httpBody = body
25 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Response
Data ➡ JSON
26 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
// {"user": {"name": "Yusuke"}}
URLSession.shared.dataTask(with: request) { (data, _, _) in
let json = (try? JSONSerialization.jsonObject(with: data!,
options: .allowFragments)) as? [AnyHashable: Any]
let user = json?["user"] as? [AnyHashable: Any]
let name = user?["name"] as? String
}
27 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Response
Data ➡ JSON
28 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Response
Data ➡ UserResponse
29 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
// UserResponse(user: User(name: "Yusuke"))
URLSession.shared.dataTask(with: request) { (data, _, _) in
// custom type
guard let response: UserResponse = try? UserResponse(serializedData: data!) else {
// error
return
}
let user = response.user
let name = user.name
}
30 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Protobuf(
isTyped: true,
status: .satisfied
)
31 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
!
32 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
But how do
they work?
33 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
protobuf for Swift
apple/swift-protobuf
34 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
"But we still use
Objective-C !"
35 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
protobuf
google/protobuf
36 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
1. Define message types
2. Generate code
3. Serialize/Deserialize
37 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
1. Define message types
2. Generate code
3. Serialize/Deserialize
38 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Message types define
data structures
in .proto files
39 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Message types have key-
value pairs
40 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
41 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
user.proto
syntax = "proto3"; // protoc version
message User {
int32 id = 1; // field number
string name = 2;
string introduction = 3;
string photoUrl = 4;
ParticipantType participantType = 5;
enum ParticipantType {
Speaker = 0;
Attendee = 1;
}
}
42 — Type-safe Web APIs with Protocol Buffers in Swift,
Yusuke Kita (@kitasuke), iOSCon 2017
talk.proto
syntax = "proto3";
import "user.proto";
message Talk {
int32 id = 1;
string title = 2;
string desc = 3;
User speaker = 4;
repeated string tags = 5; // Array
}
43 — Type-safe Web APIs with Protocol Buffers in Swift,
Yusuke Kita (@kitasuke), iOSCon 2017
1. Define message types
2. Generate code
3. Serialize/Deserialize
44 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
protobuf compiler
generates code
from .proto file
45 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Basic types
Int32, UInt32, Int64, UInt64, Bool, Float, Double, String,
Array, Dictionary, Data
46 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Supported languages
C, C++, C#, Erlang, Go, Haskell, Java, Javascript,
Objective-C, Perl, PHP, Python, Ruby, Rust, Scala,
Swift etc.
47 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Swift features
→ struct, not class
→ enum RawValue is Int
→ Default value is set
48 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
49 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
user.proto
syntax = "proto3"; // protoc version
message User {
int32 id = 1; // field number
string name = 2;
string introduction = 3;
string photoUrl = 4;
ParticipantType participantType = 5;
enum ParticipantType {
Speaker = 0;
Attendee = 1;
}
}
50 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
user.pb.swift
// struct
struct User: SwiftProtobuf.Message, ... {
init() {}
enum Type: SwiftProtobuf.Enum {
typealias RawValue = Int // always Int
case speaker // = 0
case participant // = 1
case UNRECOGNIZED(Int)
}
// property has default value
var id: Int32 = 0
var name: String = ""
var introduction: String = ""
var photoURL: String = ""
var participantType: User.ParticipantType = .speaker
}
51 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
talk.proto
syntax = "proto3";
import "user.proto";
message Talk {
int32 id = 1;
string title = 2;
string desc = 3;
User speaker = 4;
repeated string tags = 5; // Array
}
52 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
talk.pb.swift
struct Talk: SwiftProtobuf.Message, ... {
init() {}
var id: Int32 = 0
var title: String = ""
var speaker: User = User()
var desc: String = ""
var tags: [String] = []
}
53 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
54 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
User.java
public static final class User extends Message<User, User.Builder> {
public final Integer id;
public final String name;
public final String introduction;
public final String photoUrl;
public final ParticipantType participantType;
}
55 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Talk.java
public final class Talk extends Message<Talk, Talk.Builder> {
public final Integer id;
public final String title;
public final User speaker;
public final String summary;
public final List<String> tags;
}
56 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
57 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
user.pb.go
type User_Type int32
const (
User_Speaker User_ParticipantType = 0
User_Attendee User_ParticipantType = 1
)
type User struct {
ID int32 ˆprotobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"ˆ
Name string ˆprotobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"ˆ
Introduction string ˆprotobuf:"bytes,3,opt,name=introduction,proto3" json:"introduction,omitempty"ˆ
PhotoURL string ˆprotobuf:"bytes,4,opt,name=photoUrl,proto3" json:"photoUrl,omitempty"ˆ
Type User_Type ˆprotobuf:"varint,5,opt,name=type,proto3,enum=api.User_Type" json:"type,omitempty"ˆ
}
58 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
talk.pb.go
type Talk struct {
ID int32 ˆprotobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"ˆ
Title string ˆprotobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"ˆ
Speaker *User ˆprotobuf:"bytes,3,opt,name=speaker" json:"speaker,omitempty"ˆ
Summary string ˆprotobuf:"bytes,4,opt,name=summary,proto3" json:"summary,omitempty"ˆ
Tags []string ˆprotobuf:"bytes,5,rep,name=tags" json:"tags,omitempty"ˆ
}
59 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
One message type
⬇
Multiple languages code
60 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Less communication,
More collaboration
with other platforms
61 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
1. Define message types
2. Generate source files
3. Serialize/Deserialize
62 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Serialization
public func serializedData(partial: Bool = default) throws -> Data
public func jsonString() throws -> String
public func textFormatString() throws -> String
63 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
let user = User.with {
$0.id = 1
$0.type = .speaker
$0.name = "kitasuke"
}
let talk = Talk.with {
$0.id = 1
$0.title = "Type-safe Web APIs with Protocol Buffers in Swift"
$0.speaker = user
$0.tags = ["swift", "iOS", "protocol-buffers", "ioscon", "type-safe"]
}
let data = try? talk.serializedData()
64 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Deserialization
public convenience init(serializedData data: Data,
extensions: SwiftProtobuf.ExtensionSet? = default,
partial: Bool = default) throws
public convenience init(jsonString: String) throws
public convenience init(textFormatString: String,
extensions: SwiftProtobuf.ExtensionSet? = default) throws
65 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
let talk = try? Talk(serializedData: data)
let title = talk?.title
let speaker = talk?.speaker
let tags = talk?.tags
66 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
How serialization works
67 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Binary
Encoding
68 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Key factor
1. Field number
2. Wire type
69 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Field number
message Talk {
int32 id = 1; ← // Field number
string title = 2;
string desc = 3;
User speaker = 4;
repeated string tags = 5;
}
70 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Wire type
Type Meaning Used For
0 Varint int32, int64, uint32, uint64,
sint32, sint64, bool, enum
1 64-bit fixed64, sfixed64, double
2 Length-delimited string, bytes, embedded
messages, packed
repeated fields
3 (deprecated)
4 (deprecated)
5 32-bit fixed32, sfix3d32, float
71 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
// message type
message Test1 {
int32 a = 1;
}
test1.a = 300
// encoded message
08 96 01
08 // field number and wire type
96 01 // value which is 300
72 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
So small and numeric
73 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
High network
performance
74 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Demo
kitasuke/SwiftProtobufSample
75 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Quick Recap
76 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Quick Recap
→ Type-safety
77 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Quick Recap
→ Type-safety
→ Shared data model
78 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Quick Recap
→ Type-safety
→ Shared data model
→ High performance
79 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
You might have concerns
about...
80 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Versioning
81 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Backward compatibility
→ Unknown field is ignored
→ Default value for missing field
82 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Backward compatibility
→ Unknown field is ignored
→ Default value for missing field
as long as you don't change existing field number or wire type
83 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Coexistence of
protobuf & JSON
84 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Absolutely you can!
85 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Accept & Content-Type
→ application/protobuf - protobuf
→ application/json - JSON
86 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Request
var request = URLRequest(url: url)
if protobuf {
request.setValue("application/protobuf", forHTTPHeaderField: "Content-Type")
request.setValue("application/protobuf", forHTTPHeaderField: "Accept")
} else if json {
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("application/json", forHTTPHeaderField: "Accept")
}
87 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
HTTP Response
URLSession.shared.dataTask(with: request) { (data, urlResponse, _) in
let httpURLResponse = urlResponse as? HTTPURLResponse
let contentType = httpURLResponse?.allHeaderFields["Content-Type"] as? String
if contentType == "application/protobuf" {
let response = try? Response(serializedData: data!)
} else if contentType == "application/json" {
let response = try? Response(jsonString: data!)
}
}
88 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Sounds good
so far !
89 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
So, what are
Cons?
90 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Not human-readable
→ Binary data is not understandable
91 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Time investment
→ Time consuming at the beginning
→ Involvement from other platforms
92 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Swift version
→ Watch Swift version of protobuf plugin
→ Specify tag version if you use older version
93 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Stability
→ Still pre-release version only for Swift
→ Contribute if you find a bug !
94 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Where should
we start?
95 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Internal service
→ Easy to adapt
→ Small start
96 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Data store
→ Database
→ NSKeyedArchiver
→ NSCache
97 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Parsing library
→ JSON parser
→ Server side Swift
98 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Conclusion
99 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Conclusion
→ Swifty
100 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Conclusion
→ Swifty
→ Consistent in Cross-platform
101 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Conclusion
→ Swifty
→ Consistent in Cross-platform
→ Extensible
102 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
It's definitely
worth it !
103 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Partially in Production
70M Downloads
!"#
104 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Credits
Protocol Buffers
swift-protobuf
Kitura
Protocol Buffers in your Kitura Apps
105 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
Thank you!
GitHub: https://github.com/kitasuke
Demo: SwiftProtobufSample
Twitter: @kitasuke
Email: yusuke2759@gmail.com
106 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017

More Related Content

What's hot

Introduction to Python - Code Heroku
Introduction to Python - Code HerokuIntroduction to Python - Code Heroku
Introduction to Python - Code Herokucodeheroku
 
Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...
Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...
Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...Takayuki Shimizukawa
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on pythonShubham Yadav
 
Seminar report On Python
Seminar report On PythonSeminar report On Python
Seminar report On PythonShivam Gupta
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialQA TrainingHub
 
How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015hirokiky
 
Python: the Project, the Language and the Style
Python: the Project, the Language and the StylePython: the Project, the Language and the Style
Python: the Project, the Language and the StyleJuan-Manuel Gimeno
 
A great clash of symbols
A great clash of symbolsA great clash of symbols
A great clash of symbolsGreg Sohl
 
Seminar report on python 3 course
Seminar report on python 3 courseSeminar report on python 3 course
Seminar report on python 3 courseHimanshuPanwar38
 
Python, the Language of Science and Engineering for Engineers
Python, the Language of Science and Engineering for EngineersPython, the Language of Science and Engineering for Engineers
Python, the Language of Science and Engineering for EngineersBoey Pak Cheong
 
Intro to Perfect - LA presentation
Intro to Perfect - LA presentationIntro to Perfect - LA presentation
Intro to Perfect - LA presentationTim Taplin
 
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | EdurekaPython Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | EdurekaEdureka!
 
Python 3.5: An agile, general-purpose development language.
Python 3.5: An agile, general-purpose development language.Python 3.5: An agile, general-purpose development language.
Python 3.5: An agile, general-purpose development language.Carlos Miguel Ferreira
 
Concept of compiler,ide, run, debug
Concept of compiler,ide, run, debugConcept of compiler,ide, run, debug
Concept of compiler,ide, run, debugAbdullahALHabib4
 
Python Summer Internship
Python Summer InternshipPython Summer Internship
Python Summer InternshipAtul Kumar
 

What's hot (18)

Introduction to python
 Introduction to python Introduction to python
Introduction to python
 
Introduction to Python - Code Heroku
Introduction to Python - Code HerokuIntroduction to Python - Code Heroku
Introduction to Python - Code Heroku
 
Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...
Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...
Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...
 
Python
PythonPython
Python
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
Seminar report On Python
Seminar report On PythonSeminar report On Python
Seminar report On Python
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python Tutorial
 
How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015
 
Python: the Project, the Language and the Style
Python: the Project, the Language and the StylePython: the Project, the Language and the Style
Python: the Project, the Language and the Style
 
A great clash of symbols
A great clash of symbolsA great clash of symbols
A great clash of symbols
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Seminar report on python 3 course
Seminar report on python 3 courseSeminar report on python 3 course
Seminar report on python 3 course
 
Python, the Language of Science and Engineering for Engineers
Python, the Language of Science and Engineering for EngineersPython, the Language of Science and Engineering for Engineers
Python, the Language of Science and Engineering for Engineers
 
Intro to Perfect - LA presentation
Intro to Perfect - LA presentationIntro to Perfect - LA presentation
Intro to Perfect - LA presentation
 
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | EdurekaPython Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
 
Python 3.5: An agile, general-purpose development language.
Python 3.5: An agile, general-purpose development language.Python 3.5: An agile, general-purpose development language.
Python 3.5: An agile, general-purpose development language.
 
Concept of compiler,ide, run, debug
Concept of compiler,ide, run, debugConcept of compiler,ide, run, debug
Concept of compiler,ide, run, debug
 
Python Summer Internship
Python Summer InternshipPython Summer Internship
Python Summer Internship
 

Similar to Type-safe Web APIs with Protocol Buffers in Swift at iOSCon

Type-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConfType-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConfYusuke Kita
 
2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open StandardsAPIsecure_ Official
 
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
REST Coder: Auto Generating Client Stubs and Documentation for REST APIsREST Coder: Auto Generating Client Stubs and Documentation for REST APIs
REST Coder: Auto Generating Client Stubs and Documentation for REST APIsHiranya Jayathilaka
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCTim Burks
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!Alex Borysov
 
18 facets of the OpenAPI specification - Cisco Live US 2023
18 facets of the OpenAPI specification - Cisco Live US 202318 facets of the OpenAPI specification - Cisco Live US 2023
18 facets of the OpenAPI specification - Cisco Live US 2023Cisco DevNet
 
Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017
Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017
Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017Codemotion
 
A tour through Swift attributes
A tour through Swift attributesA tour through Swift attributes
A tour through Swift attributesMarco Eidinger
 
IRJET- Hosting NLP based Chatbot on AWS Cloud using Docker
IRJET-  	  Hosting NLP based Chatbot on AWS Cloud using DockerIRJET-  	  Hosting NLP based Chatbot on AWS Cloud using Docker
IRJET- Hosting NLP based Chatbot on AWS Cloud using DockerIRJET Journal
 
Building Beautiful REST APIs with ASP.NET Core
Building Beautiful REST APIs with ASP.NET CoreBuilding Beautiful REST APIs with ASP.NET Core
Building Beautiful REST APIs with ASP.NET CoreStormpath
 
FrenchKit: End to End Application Development with Swift
FrenchKit: End to End Application Development with SwiftFrenchKit: End to End Application Development with Swift
FrenchKit: End to End Application Development with SwiftChris Bailey
 
Serverless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhiskServerless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhiskDaniel Krook
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptxKaviya452563
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Pythongturnquist
 
RESTful API Development using Go
RESTful API Development using GoRESTful API Development using Go
RESTful API Development using GoBaiju Muthukadan
 
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 editionAlex Borysov
 
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...apidays
 

Similar to Type-safe Web APIs with Protocol Buffers in Swift at iOSCon (20)

Type-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConfType-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConf
 
2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards
 
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
REST Coder: Auto Generating Client Stubs and Documentation for REST APIsREST Coder: Auto Generating Client Stubs and Documentation for REST APIs
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
 
Designing & Building Secure Web APIs
Designing & Building Secure Web APIsDesigning & Building Secure Web APIs
Designing & Building Secure Web APIs
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!
 
18 facets of the OpenAPI specification - Cisco Live US 2023
18 facets of the OpenAPI specification - Cisco Live US 202318 facets of the OpenAPI specification - Cisco Live US 2023
18 facets of the OpenAPI specification - Cisco Live US 2023
 
Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017
Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017
Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017
 
A tour through Swift attributes
A tour through Swift attributesA tour through Swift attributes
A tour through Swift attributes
 
Watch os 2.0
Watch os 2.0Watch os 2.0
Watch os 2.0
 
IRJET- Hosting NLP based Chatbot on AWS Cloud using Docker
IRJET-  	  Hosting NLP based Chatbot on AWS Cloud using DockerIRJET-  	  Hosting NLP based Chatbot on AWS Cloud using Docker
IRJET- Hosting NLP based Chatbot on AWS Cloud using Docker
 
Building Beautiful REST APIs with ASP.NET Core
Building Beautiful REST APIs with ASP.NET CoreBuilding Beautiful REST APIs with ASP.NET Core
Building Beautiful REST APIs with ASP.NET Core
 
FrenchKit: End to End Application Development with Swift
FrenchKit: End to End Application Development with SwiftFrenchKit: End to End Application Development with Swift
FrenchKit: End to End Application Development with Swift
 
Serverless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhiskServerless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhisk
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptx
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
RESTful API Development using Go
RESTful API Development using GoRESTful API Development using Go
RESTful API Development using Go
 
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
 
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
apidays Paris 2022 - The 12 Facets of the OpenAPI Specification, Steve Sfartz...
 

More from Yusuke Kita

Integrating libSyntax into the compiler pipeline
Integrating libSyntax into the compiler pipelineIntegrating libSyntax into the compiler pipeline
Integrating libSyntax into the compiler pipelineYusuke Kita
 
Making your own tool using SwiftSyntax
Making your own tool using SwiftSyntaxMaking your own tool using SwiftSyntax
Making your own tool using SwiftSyntaxYusuke Kita
 
[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipelineYusuke Kita
 
Creating your own Bitrise step
Creating your own Bitrise stepCreating your own Bitrise step
Creating your own Bitrise stepYusuke Kita
 
Introducing swift-format
Introducing swift-formatIntroducing swift-format
Introducing swift-formatYusuke Kita
 
Unidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIUnidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIYusuke Kita
 
Open Source Swift Workshop
Open Source Swift WorkshopOpen Source Swift Workshop
Open Source Swift WorkshopYusuke Kita
 
Contributing to Swift Compiler
Contributing to Swift CompilerContributing to Swift Compiler
Contributing to Swift CompilerYusuke Kita
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in goYusuke Kita
 
Writing an interpreter in swift
Writing an interpreter in swiftWriting an interpreter in swift
Writing an interpreter in swiftYusuke Kita
 
SIL Optimizations - AllocBoxToStack
SIL Optimizations - AllocBoxToStackSIL Optimizations - AllocBoxToStack
SIL Optimizations - AllocBoxToStackYusuke Kita
 
SIL for First Time Learners
SIL for First Time LearnersSIL for First Time Learners
SIL for First Time LearnersYusuke Kita
 
SIL for First Time Leaners LT
SIL for First Time Leaners LTSIL for First Time Leaners LT
SIL for First Time Leaners LTYusuke Kita
 
How to try! Swift
How to try! SwiftHow to try! Swift
How to try! SwiftYusuke Kita
 
SIL for the first time
SIL for the first timeSIL for the first time
SIL for the first timeYusuke Kita
 
SwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみたSwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみたYusuke Kita
 
Search APIs & Universal Links
Search APIs & Universal LinksSearch APIs & Universal Links
Search APIs & Universal LinksYusuke Kita
 
Introducing Cardio
Introducing CardioIntroducing Cardio
Introducing CardioYusuke Kita
 

More from Yusuke Kita (20)

Integrating libSyntax into the compiler pipeline
Integrating libSyntax into the compiler pipelineIntegrating libSyntax into the compiler pipeline
Integrating libSyntax into the compiler pipeline
 
Making your own tool using SwiftSyntax
Making your own tool using SwiftSyntaxMaking your own tool using SwiftSyntax
Making your own tool using SwiftSyntax
 
[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline
 
Creating your own Bitrise step
Creating your own Bitrise stepCreating your own Bitrise step
Creating your own Bitrise step
 
Introducing swift-format
Introducing swift-formatIntroducing swift-format
Introducing swift-format
 
Unidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIUnidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUI
 
Open Source Swift Workshop
Open Source Swift WorkshopOpen Source Swift Workshop
Open Source Swift Workshop
 
Contributing to Swift Compiler
Contributing to Swift CompilerContributing to Swift Compiler
Contributing to Swift Compiler
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
 
Writing an interpreter in swift
Writing an interpreter in swiftWriting an interpreter in swift
Writing an interpreter in swift
 
SIL Optimizations - AllocBoxToStack
SIL Optimizations - AllocBoxToStackSIL Optimizations - AllocBoxToStack
SIL Optimizations - AllocBoxToStack
 
SIL for First Time Learners
SIL for First Time LearnersSIL for First Time Learners
SIL for First Time Learners
 
var, let in SIL
var, let in SILvar, let in SIL
var, let in SIL
 
SIL for First Time Leaners LT
SIL for First Time Leaners LTSIL for First Time Leaners LT
SIL for First Time Leaners LT
 
How to try! Swift
How to try! SwiftHow to try! Swift
How to try! Swift
 
SIL for the first time
SIL for the first timeSIL for the first time
SIL for the first time
 
Swift core
Swift coreSwift core
Swift core
 
SwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみたSwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみた
 
Search APIs & Universal Links
Search APIs & Universal LinksSearch APIs & Universal Links
Search APIs & Universal Links
 
Introducing Cardio
Introducing CardioIntroducing Cardio
Introducing Cardio
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

Type-safe Web APIs with Protocol Buffers in Swift at iOSCon

  • 1. Type-safe Web APIs with Protocol Buffers in Swift 1 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 2. Hi, I'm Yusuke @kitasuke 2 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 3. I'm going to talk about... → What Protocol Buffers are 3 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 4. I'm going to talk about... → What Protocol Buffers are → Pros and Cons 4 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 5. I'm going to talk about... → What Protocol Buffers are → Pros and Cons → Where to start 5 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 6. Web APIs 6 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 7. JSON7 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 8. HTTP Request JSON ➡ Data 8 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 9. let json = ["id": 1] let data = try? JSONSerialization.data(withJSONObject: json, options: .prettyPrinted) var request = URLRequest(url: url) request.httpBody = data 9 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 10. HTTP Response Data ➡ JSON 10 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 11. // {"user": {"name": "Yusuke"}} URLSession.shared.dataTask(with: request) { (data, _, _) in let json = (try? JSONSerialization.jsonObject(with: data!, options: .allowFragments)) as? [AnyHashable: Any] let user = json?["user"] as? [AnyHashable: Any] let name = user?["name"] as? String } 11 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 12. {"isTyped": false, "status": "disappointed"} 12 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 13. [AnyHashable: Any] 13 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 14. Any? 14 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 15. ! 15 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 16. Protocol Buffersa.k.a protobuf 16 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 17. Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. — Google 17 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 18. Serialization format - think JSON, but smaller, faster and safer — Yusuke 18 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 19. Serialization Format 19 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 20. Why are Protocol Buffers a big deal? 20 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 21. HTTP Request JSON ➡ Data 21 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 22. let json = ["id": 1] let data = try? JSONSerialization.data(withJSONObject: json, options: .prettyPrinted) var request = URLRequest(url: url) request.httpBody = data 22 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 23. HTTP Request JSON ➡ Data 23 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 24. HTTP Request UserRequest ➡ Data 24 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 25. // custom type let userRequest = UserRequest.with { $0.id = 1 } let body = try? body.serializedData() var request = URLRequest(url: url) request.httpBody = body 25 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 26. HTTP Response Data ➡ JSON 26 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 27. // {"user": {"name": "Yusuke"}} URLSession.shared.dataTask(with: request) { (data, _, _) in let json = (try? JSONSerialization.jsonObject(with: data!, options: .allowFragments)) as? [AnyHashable: Any] let user = json?["user"] as? [AnyHashable: Any] let name = user?["name"] as? String } 27 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 28. HTTP Response Data ➡ JSON 28 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 29. HTTP Response Data ➡ UserResponse 29 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 30. // UserResponse(user: User(name: "Yusuke")) URLSession.shared.dataTask(with: request) { (data, _, _) in // custom type guard let response: UserResponse = try? UserResponse(serializedData: data!) else { // error return } let user = response.user let name = user.name } 30 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 31. Protobuf( isTyped: true, status: .satisfied ) 31 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 32. ! 32 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 33. But how do they work? 33 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 34. protobuf for Swift apple/swift-protobuf 34 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 35. "But we still use Objective-C !" 35 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 36. protobuf google/protobuf 36 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 37. 1. Define message types 2. Generate code 3. Serialize/Deserialize 37 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 38. 1. Define message types 2. Generate code 3. Serialize/Deserialize 38 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 39. Message types define data structures in .proto files 39 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 40. Message types have key- value pairs 40 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 41. 41 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 42. user.proto syntax = "proto3"; // protoc version message User { int32 id = 1; // field number string name = 2; string introduction = 3; string photoUrl = 4; ParticipantType participantType = 5; enum ParticipantType { Speaker = 0; Attendee = 1; } } 42 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 43. talk.proto syntax = "proto3"; import "user.proto"; message Talk { int32 id = 1; string title = 2; string desc = 3; User speaker = 4; repeated string tags = 5; // Array } 43 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 44. 1. Define message types 2. Generate code 3. Serialize/Deserialize 44 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 45. protobuf compiler generates code from .proto file 45 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 46. Basic types Int32, UInt32, Int64, UInt64, Bool, Float, Double, String, Array, Dictionary, Data 46 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 47. Supported languages C, C++, C#, Erlang, Go, Haskell, Java, Javascript, Objective-C, Perl, PHP, Python, Ruby, Rust, Scala, Swift etc. 47 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 48. Swift features → struct, not class → enum RawValue is Int → Default value is set 48 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 49. 49 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 50. user.proto syntax = "proto3"; // protoc version message User { int32 id = 1; // field number string name = 2; string introduction = 3; string photoUrl = 4; ParticipantType participantType = 5; enum ParticipantType { Speaker = 0; Attendee = 1; } } 50 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 51. user.pb.swift // struct struct User: SwiftProtobuf.Message, ... { init() {} enum Type: SwiftProtobuf.Enum { typealias RawValue = Int // always Int case speaker // = 0 case participant // = 1 case UNRECOGNIZED(Int) } // property has default value var id: Int32 = 0 var name: String = "" var introduction: String = "" var photoURL: String = "" var participantType: User.ParticipantType = .speaker } 51 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 52. talk.proto syntax = "proto3"; import "user.proto"; message Talk { int32 id = 1; string title = 2; string desc = 3; User speaker = 4; repeated string tags = 5; // Array } 52 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 53. talk.pb.swift struct Talk: SwiftProtobuf.Message, ... { init() {} var id: Int32 = 0 var title: String = "" var speaker: User = User() var desc: String = "" var tags: [String] = [] } 53 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 54. 54 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 55. User.java public static final class User extends Message<User, User.Builder> { public final Integer id; public final String name; public final String introduction; public final String photoUrl; public final ParticipantType participantType; } 55 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 56. Talk.java public final class Talk extends Message<Talk, Talk.Builder> { public final Integer id; public final String title; public final User speaker; public final String summary; public final List<String> tags; } 56 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 57. 57 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 58. user.pb.go type User_Type int32 const ( User_Speaker User_ParticipantType = 0 User_Attendee User_ParticipantType = 1 ) type User struct { ID int32 ˆprotobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"ˆ Name string ˆprotobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"ˆ Introduction string ˆprotobuf:"bytes,3,opt,name=introduction,proto3" json:"introduction,omitempty"ˆ PhotoURL string ˆprotobuf:"bytes,4,opt,name=photoUrl,proto3" json:"photoUrl,omitempty"ˆ Type User_Type ˆprotobuf:"varint,5,opt,name=type,proto3,enum=api.User_Type" json:"type,omitempty"ˆ } 58 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 59. talk.pb.go type Talk struct { ID int32 ˆprotobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"ˆ Title string ˆprotobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"ˆ Speaker *User ˆprotobuf:"bytes,3,opt,name=speaker" json:"speaker,omitempty"ˆ Summary string ˆprotobuf:"bytes,4,opt,name=summary,proto3" json:"summary,omitempty"ˆ Tags []string ˆprotobuf:"bytes,5,rep,name=tags" json:"tags,omitempty"ˆ } 59 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 60. One message type ⬇ Multiple languages code 60 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 61. Less communication, More collaboration with other platforms 61 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 62. 1. Define message types 2. Generate source files 3. Serialize/Deserialize 62 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 63. Serialization public func serializedData(partial: Bool = default) throws -> Data public func jsonString() throws -> String public func textFormatString() throws -> String 63 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 64. let user = User.with { $0.id = 1 $0.type = .speaker $0.name = "kitasuke" } let talk = Talk.with { $0.id = 1 $0.title = "Type-safe Web APIs with Protocol Buffers in Swift" $0.speaker = user $0.tags = ["swift", "iOS", "protocol-buffers", "ioscon", "type-safe"] } let data = try? talk.serializedData() 64 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 65. Deserialization public convenience init(serializedData data: Data, extensions: SwiftProtobuf.ExtensionSet? = default, partial: Bool = default) throws public convenience init(jsonString: String) throws public convenience init(textFormatString: String, extensions: SwiftProtobuf.ExtensionSet? = default) throws 65 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 66. let talk = try? Talk(serializedData: data) let title = talk?.title let speaker = talk?.speaker let tags = talk?.tags 66 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 67. How serialization works 67 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 68. Binary Encoding 68 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 69. Key factor 1. Field number 2. Wire type 69 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 70. Field number message Talk { int32 id = 1; ← // Field number string title = 2; string desc = 3; User speaker = 4; repeated string tags = 5; } 70 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 71. Wire type Type Meaning Used For 0 Varint int32, int64, uint32, uint64, sint32, sint64, bool, enum 1 64-bit fixed64, sfixed64, double 2 Length-delimited string, bytes, embedded messages, packed repeated fields 3 (deprecated) 4 (deprecated) 5 32-bit fixed32, sfix3d32, float 71 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 72. // message type message Test1 { int32 a = 1; } test1.a = 300 // encoded message 08 96 01 08 // field number and wire type 96 01 // value which is 300 72 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 73. So small and numeric 73 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 74. High network performance 74 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 75. Demo kitasuke/SwiftProtobufSample 75 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 76. Quick Recap 76 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 77. Quick Recap → Type-safety 77 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 78. Quick Recap → Type-safety → Shared data model 78 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 79. Quick Recap → Type-safety → Shared data model → High performance 79 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 80. You might have concerns about... 80 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 81. Versioning 81 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 82. Backward compatibility → Unknown field is ignored → Default value for missing field 82 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 83. Backward compatibility → Unknown field is ignored → Default value for missing field as long as you don't change existing field number or wire type 83 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 84. Coexistence of protobuf & JSON 84 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 85. Absolutely you can! 85 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 86. Accept & Content-Type → application/protobuf - protobuf → application/json - JSON 86 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 87. HTTP Request var request = URLRequest(url: url) if protobuf { request.setValue("application/protobuf", forHTTPHeaderField: "Content-Type") request.setValue("application/protobuf", forHTTPHeaderField: "Accept") } else if json { request.setValue("application/json", forHTTPHeaderField: "Content-Type") request.setValue("application/json", forHTTPHeaderField: "Accept") } 87 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 88. HTTP Response URLSession.shared.dataTask(with: request) { (data, urlResponse, _) in let httpURLResponse = urlResponse as? HTTPURLResponse let contentType = httpURLResponse?.allHeaderFields["Content-Type"] as? String if contentType == "application/protobuf" { let response = try? Response(serializedData: data!) } else if contentType == "application/json" { let response = try? Response(jsonString: data!) } } 88 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 89. Sounds good so far ! 89 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 90. So, what are Cons? 90 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 91. Not human-readable → Binary data is not understandable 91 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 92. Time investment → Time consuming at the beginning → Involvement from other platforms 92 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 93. Swift version → Watch Swift version of protobuf plugin → Specify tag version if you use older version 93 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 94. Stability → Still pre-release version only for Swift → Contribute if you find a bug ! 94 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 95. Where should we start? 95 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 96. Internal service → Easy to adapt → Small start 96 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 97. Data store → Database → NSKeyedArchiver → NSCache 97 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 98. Parsing library → JSON parser → Server side Swift 98 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 99. Conclusion 99 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 100. Conclusion → Swifty 100 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 101. Conclusion → Swifty → Consistent in Cross-platform 101 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 102. Conclusion → Swifty → Consistent in Cross-platform → Extensible 102 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 103. It's definitely worth it ! 103 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 104. Partially in Production 70M Downloads !"# 104 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 105. Credits Protocol Buffers swift-protobuf Kitura Protocol Buffers in your Kitura Apps 105 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017
  • 106. Thank you! GitHub: https://github.com/kitasuke Demo: SwiftProtobufSample Twitter: @kitasuke Email: yusuke2759@gmail.com 106 — Type-safe Web APIs with Protocol Buffers in Swift, Yusuke Kita (@kitasuke), iOSCon 2017