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
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
110
Vue の Input における State は親で持つべきか子で持つべきか
t0yohei
0
110
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
Other Decks in Technology
See All in Technology
自律的なチームを作るためにTechPMがやらないこと
ny7760
0
100
AWS Continuum for Penetration Testing に Deep Dive してみる
asanoharuki
2
1.4k
AI時代の開発はウォーターフォールに回帰する? / development-with-ai-back-to-wf
okamototakuyasr2
0
150
「作れる」と「リリースできる」の間にあったもの── PdMを外して見えた、PdMがやるべき仕事/Buildable ≠ Shippable: What Removing the PM Taught Me About the PM’s Job
yappli_developers
0
370
バイブコーディングの特徴と「コケて直す」ループ
happysamurai294
0
120
生き様としてのSRE
hokkai7go
0
130
AIコーディングエージェント開発_全体像
happysamurai294
0
120
Oracle Database Security 詳細解説
oracle4engineer
PRO
1
120
デザインレビューは自動化できるのか?─ Flutter × Figma で UI 品質保証を考える
techiro
2
560
視野はAIに、視座は人に / ai-for-breadth-humans-for-perspective
nkzn
3
1.6k
Microsoft のサポート ライフサイクルを理解する
murachiakira
PRO
0
230
AIで選択肢が広がった組織設計の理想と現実
konifar
15
6.8k
Featured
See All Featured
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
Paper Plane
katiecoart
PRO
5
54k
Utilizing Notion as your number one productivity tool
mfonobong
4
630
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
340
Why Our Code Smells
bkeepers
PRO
340
58k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
New Earth Scene 8
popppiees
4
2.7k
Google's AI Overviews - The New Search
badams
0
1.6k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
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 した瞬間に型付けされる