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
820
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.4k
claude_code.pdf
matsu7874
5
7.7k
Marpを使って登壇資料を作る
matsu7874
0
2.4k
ざっと理解するRust 2024 Edition
matsu7874
0
1.9k
プリントデバッグを失敗させないテクニック
matsu7874
1
500
社外を巻き込んだ勉強会を定期開催するコツ
matsu7874
0
260
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
スマートフォンでモールス信号を送受信する 〜スマートフォンのLEDとカメラで作る光通信の設計と実装〜
atsuki_seo
0
210
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
150
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
330
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
450
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
1
110
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
450
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
130
すこし踏み込む CancellationToken
htkym
2
1.5k
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
410
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
3.1k
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1.2k
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Ethics towards AI in product and experience design
skipperchong
2
400
Un-Boring Meetings
codingconduct
0
430
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
290
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
How to train your dragon (web standard)
notwaldorf
97
6.8k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
730
Six Lessons from altMBA
skipperchong
29
4.5k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
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