Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Generate a rust client code by OpenAPI Generator
Search
Kentaro Matsumoto
August 16, 2024
Programming
740
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
claude_code.pdf
matsu7874
5
7.6k
Marpを使って登壇資料を作る
matsu7874
0
2.3k
ざっと理解するRust 2024 Edition
matsu7874
0
1.9k
プリントデバッグを失敗させないテクニック
matsu7874
1
480
社外を巻き込んだ勉強会を定期開催するコツ
matsu7874
0
240
actix-webを使った開発のハマリポイントを避けたい
matsu7874
0
1.2k
our test strategy on actix-web app
matsu7874
0
1.7k
roadmap to rust 2024
matsu7874
0
2.2k
Rust tutorial for Pythonista
matsu7874
2
1.5k
Other Decks in Programming
See All in Programming
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
790
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.3k
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
180
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
150
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
290
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
13k
Webフレームワークの ベンチマークについて
yusukebe
0
170
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
140
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
250
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.7k
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
3
420
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
140
WCS-LA-2024
lcolladotor
0
650
A Tale of Four Properties
chriscoyier
163
24k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
270
We Are The Robots
honzajavorek
0
250
Building an army of robots
kneath
306
46k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
350
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
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