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
Open API + Railsでテストをいい感じにした話
Search
syumai
July 18, 2019
210
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Open API + Railsでテストをいい感じにした話
WIPです
syumai
July 18, 2019
More Decks by syumai
See All by syumai
Workers Cache を知る
syumai
0
360
自分的「カンファレンスの楽しみ方」
syumai
0
220
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.6k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
2.1k
Oxlintのカスタムルールの現況
syumai
6
2.1k
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
1.6k
『[入門] Cloudflare Workers』本はなぜ誕生したのか
syumai
0
650
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
9
3.4k
知られているようで知られていない JavaScriptの仕様 4選
syumai
3
1.3k
Featured
See All Featured
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
570
Un-Boring Meetings
codingconduct
0
450
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
360
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
The untapped power of vector embeddings
frankvandijk
2
1.9k
Deep Space Network (abreviated)
tonyrice
0
370
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Transcript
Open API + Railsでテストをいい感じにした 話 平成.rb 2019/7/18 @__syumai
自己紹介 syumai 平成4年生まれ 前職: 株式会社maricuruにてRailsを使ったAPI開発、React / Vue を使ったフロントエンド開発等を行っていました 現職: 決済系の会社でGoのマイクロサービスを開発しています
はじめに
めっちゃWIPです!
本日のテーマ Open API
Open API or Swagger使ってますか?
Open APIとは? YAML / JSONでAPI Specを書ける Swagger 3.0がそのままOpen API 3.0と呼ばれています
書いたAPI Specから色々生成出来る
生成できるものその1 HTMLのいい感じのドキュメント フォームの送信とかも試せる! (Postman的なやつ)
生成できるものその2 サーバー / クライアントの生成 サーバーのinterfaceや、クライアントライブラリ (言語めっちゃ ある) を自動生成出来る 多言語のクライアントを生成したい時にめちゃくちゃ便利
クライアント生成できる言語 https://github.com/OpenAPITools/openapi-generator Ruby / Node.js / TypeScript / Javaなど色々あります
Open APIのSpecのサンプル
Open APIのドキュメントのサンプル
Open APIを使っている人からよく聞く課題 APIの実装とドキュメントがズレてくる ドキュメントがズレてるから、誰もメンテしなくなる 実装とドキュメントがズレると、自動生成したクライアントが使えなく なる
ドキュメントがズレる理由 APIの実装を行う作業と、ドキュメントを書く作業が分離してしまって いるため これを統合できたら解決するはず!
どう解決したか? テストでRailsのAPIを起動する テストに Open APIで生成したClient を使う
このやり方の良い点 同じSpecから生成したClientをJSで使うとして、 Testさえ通っていれば、Client側から使えるのが保証される!
具体的なやり方 Makefileでテスト起動周りをいい感じに書いていく Railsサーバーの起動 Rspecの実行
デモします!!
ポイント テスト用のRailsサーバーと、Rspecで使うDBを共通にする
つらみ エラーが出た箇所のログ追うのがつらい
ご清聴ありがとうございました!!