Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Protocol Buffers で Web APIのスキーマ駆動開発がしたい
Search
t0yohei
November 09, 2019
Technology
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Protocol Buffers で Web APIのスキーマ駆動開発がしたい
t0yohei
November 09, 2019
More Decks by t0yohei
See All by t0yohei
Vue の Input における State は親で持つべきか子で持つべきか
t0yohei
0
99
Vue.js を使って Grid System を実装した話
t0yohei
2
7.9k
負債が溜まったレガシーフロントエンド画面を Vue.js でリプレイスした話
t0yohei
0
2.3k
プログラミング入門に失敗した話
t0yohei
0
240
【ITエンジニアが怪我で労災!?】 仕事中に足の小指が骨折したら起きること
t0yohei
0
470
Ruby と JavaScript の違い( Function 編)
t0yohei
1
370
副業のノウハウ
t0yohei
0
220
ちょっとしたRubyの話
t0yohei
1
540
自作キーボード入門してみた
t0yohei
0
200
Other Decks in Technology
See All in Technology
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
140
Bet AI Day 2026丨バクラク Autopilot、業務システムの再設計
layerx
PRO
2
1.7k
Oracle Cloud Infrastructure IaaS 新機能アップデート 2026/6 - 2026/8
oracle4engineer
PRO
0
130
AI時代に、プロダクトの数だけ積み上がる所有コストをどうエンジニアリングするか / Engineering the Cost of Ownership
kzkmaeda
1
1.1k
Screen Lens - 今見てる画面を翻訳する
komagata
0
180
アリアドネの糸と、20年ごとの建て替え ── 長尾真『電子図書館』を、伊勢で読み直す / Rereading Makoto Nagao’s "Electronic Library" in Ise
ykiyota
0
120
GoにおけるFFIのこれまでとこれから
goccy
4
1.5k
20260912_スクフェス三河
kgnkhkr
0
120
日経電子版を支えていく Kasane Design System/fec_fukuoka
nikkei_engineer_recruiting
0
310
プロダクト思考 × 基盤思考を AIで実現する Compound Engineering
tkc66buzz
1
300
生成AIのテナント制御とシャドーMCP対策 | AIを"止めずに"、情報を守る
yukun
0
140
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
340
Featured
See All Featured
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
270
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
520
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Optimizing for Happiness
mojombo
378
71k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.3k
Tell your own story through comics
letsgokoyo
1
1.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
930
Transcript
Protocol Buffers で Web APIの スキーマ駆動開発がしたい (若手)エンジニアもくもく会 vol.19 @ビザスク authored
by t0yohei
Web API って • HTTP(S) のインターフェースで提供される API • SSKDs(Small Set
of Known Developers) ◦ Google Map の Geo API など • LSKDs(Large Set of Unknown Developers) ◦ サービス内でフロントエンドサーバーとバックエンドサーバーがやり取 りするための API など • REST, SOAP, gRPC, GraphQL などがある
スキーマ駆動開発って?
Web API の振る舞いの詳細を先に 決めて、 開発を進めていく手法のこと
こんなことありませんか? • フロントエンドの開発を進めたいけど、サーバーサイドからどんな json が 返ってくるかわからない • あるいは、予想してたのと違う json が返ってきた
解決方法: スキーマ駆動で開発する • APIを作る人・使う人が一緒にどういう API を作るのかを一緒に決めておく • フォーマットとしては、 Swagger(OpenAPI) など
• https://editor.swagger.io/
問題 • API の実装に変更があった時、ドキュメントがそれに合わせてメンテされる ことが保証できない • その結果、ドキュメントが正しいかわからなくなる • Swagger あんまり見やすくない(解釈)
我々が欲しいものは? • 定義したスキーマを元に、クライアント・サーバーで使用するコードを自動 生成してくれるもの • 可読性が高いもの
Protocol Buffers(protobuf)
Protocol Buffers(protobuf) って? • Google が開発してオープンソース化したスキーマ定義言語 • gRPCでよく使われている • proto
ファイルに実装した定義を元に、コードの自動生成が可能 • 読みやすい • 今さらProtocol Buffersと、手に馴染む道具の話 • Web API に秩序を与える Protocol Buffers / Protocol Buffers for Web API
protobuf を使うとどうなるのか • API の振る舞いを proto ファイルに定義 • サーバーサイド・フロントエンドの実装で基盤となるコードを自動生成 •
詳細な実装を追加 • 実装を変更する場合は proto ファイルを修正 • proto ファイルが仕様書になる
ちゃんと実装しました(まだ途中だけ ど)
作成したもの TODO リスト スキーマ定義: protobuf バックエンド: rails フロントエンド : nuxt.js
with TypeScript
直接コードを見てみる https://github.com/t0yohei/rails-nuxt-protobuf-todo
何が嬉しいか • スキーマ駆動で開発することができる • APIの修正時にドキュメント修正がいらない(実装が仕様になるので) • 静的言語だと、通信で受け取ったデータを parse した瞬間に型付けされる