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
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
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
240
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
100
Vue.js を使って Grid System を実装した話
t0yohei
2
8k
負債が溜まったレガシーフロントエンド画面を Vue.js でリプレイスした話
t0yohei
0
2.3k
プログラミング入門に失敗した話
t0yohei
0
250
【ITエンジニアが怪我で労災!?】 仕事中に足の小指が骨折したら起きること
t0yohei
0
470
Ruby と JavaScript の違い( Function 編)
t0yohei
1
370
副業のノウハウ
t0yohei
0
220
ちょっとしたRubyの話
t0yohei
1
540
自作キーボード入門してみた
t0yohei
0
210
Other Decks in Technology
See All in Technology
AI駆動で「他アプリの音を加工できる」アプリを作った
satomasahiro2005
0
170
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
170
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
740
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
3
1.1k
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
140
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
900
Refining Active Record
shugo
0
170
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
200
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
140
初海外で注意すべきこと12選!!!安全快適なre:invent生活にするために
yuuuuuuu168
1
180
1つのリクエストを追って理解する - llm-dのP/D分離
akhino
1
170
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
180
Featured
See All Featured
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
800
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
Making Projects Easy
brettharned
120
6.8k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Abbi's Birthday
coloredviolet
4
10k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
How to train your dragon (web standard)
notwaldorf
96
6.9k
The Pragmatic Product Professional
lauravandoore
37
7.5k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
320
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 した瞬間に型付けされる