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
Generate a rust client code by OpenAPI Generator
Search
Kentaro Matsumoto
August 16, 2024
Programming
800
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Generate a rust client code by OpenAPI Generator
Kentaro Matsumoto
August 16, 2024
More Decks by Kentaro Matsumoto
See All by Kentaro Matsumoto
AIで仕事のやり方を変える
matsu7874
3
1.1k
claude_code.pdf
matsu7874
5
7.7k
Marpを使って登壇資料を作る
matsu7874
0
2.4k
ざっと理解するRust 2024 Edition
matsu7874
0
1.9k
プリントデバッグを失敗させないテクニック
matsu7874
1
500
社外を巻き込んだ勉強会を定期開催するコツ
matsu7874
0
250
actix-webを使った開発のハマリポイントを避けたい
matsu7874
0
1.3k
our test strategy on actix-web app
matsu7874
0
1.8k
roadmap to rust 2024
matsu7874
0
2.2k
Other Decks in Programming
See All in Programming
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
1.9k
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
530
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
140
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
1.1k
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
270
新卒PdEのリアル
ryu1013
1
490
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
190
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
650
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
450
typoなんかねぇよ
raspython3
0
690
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
520
KATA
mclloyd
PRO
35
15k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
[SF Ruby Conf 2025] Rails X
palkan
2
1.4k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.3k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
380
HDC tutorial
michielstock
2
860
Docker and Python
trallard
47
4.2k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
730
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
230
Transcript
OpenAPIからのRustクライアントコード生成 2024-07-24 Rust、何もわからない…#13 @matsu7874 #Rust何もわからない
matsu7874 株式会社estieでソフトウェアエンジニアをしています。 RustでWebアプリケーションを開発しています。 自己紹介 © 2024 estie, Inc. 1
OpenAPI Generatorを使おう これで必要なブロックが揃います。 npm install @openapitools/openapi-generator-cli -g openapi-generator-cli generate -i
api.yaml -g rust -o generated-client 結論 © 2024 estie, Inc. 2
1. 今回は使う側の話 2. OpenAPI周りのツール群 3. OpenAPI Generator 目次 © 2024
estie, Inc. 3
1. 今回は使う側の話
schema first VS code first の話ではない Rustでバックエンドを書く部分では code first なcrateを使っている async_graphql
paperclip 1. 今回は使う側の話 © 2024 estie, Inc. 5
他の言語で開発されたAPIをRustから使いたい 基盤チームが開発してくれているAPIをプロダクトから使いたい OpenAPI 3.1.0形式でAPI仕様を共有している 今後も基盤の開発が続きそうで、API仕様が変わるかもしれない 1. 今回は使う側の話 © 2024 estie,
Inc. 6
2. OpenAPI周りのツール群
今回の用途に適したものがない utoipa Rust->OpenAPIの変換ツール paperclip OpenAPI 3.1.0形式に対応していない Progenitor OpenAPI 3.1.0形式に対応していない Swagger
Codegen jarファイルが必要?未検証 2. OpenAPI周りのツール群 © 2024 estie, Inc. 8
3. OpenAPI Generator
Webエンジニアにとってインストールが簡単 npm install @openapitools/openapi-generator-cli -g 3. OpenAPI Generator © 2024
estie, Inc. 10
コード生成も簡単 openapi-generator-cli generate -i api.yaml -g rust -o generated-client 3.
OpenAPI Generator © 2024 estie, Inc. 11
生成されたファイル群 generated-client ├── Cargo.toml ├── README.md ├── docs │ └──
モデルに対応するドキュメント.md ├── git_push.sh └── src ├── apis │ ├── configuration.rs │ ├── default_api.rs │ └── mod.rs ├── lib.rs └── models ├── mod.rs └── モデルごとの.rs 3. OpenAPI Generator © 2024 estie, Inc. 12
生成されたコードの使い方 use chat::{apis, models}; #[tokio::main] async fn main() { let
mut config = apis::configuration::Configuration::new(); let request = models::Chat::new(vec![ models::ChatRequestMessagesInner::ChatMessageParam(Box::new( "接続成功してくれ!!!!!!!".to_string(), )), ]); let result = apis::default_api::chat_api_post( &config, request, ).await; } 3. OpenAPI Generator © 2024 estie, Inc. 13
OpenAPI Generatorの弱点 Rust向けに対応していない項目もある anyOf 未対応 oneOf は対応済み https://openapi-generator.tech/docs/generators/rust/ 3. OpenAPI
Generator © 2024 estie, Inc. 14
まとめ
OpenAPI Generatorを使おう RustでOpenAPIを使う際にはOpenAPI Generatorを使うのが簡単 一部対応していない項目はあるが 生成されたコードを使ってAPI呼び出し部分を実装しよう まとめ © 2024 estie,
Inc. 16