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
ASP.NET Core の OpenAPIサポート
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Toshimasa Hashiguchi
January 14, 2025
Programming
0
410
ASP.NET Core の OpenAPIサポート
.NET Conf 2024 Fukuoka x Osaka にてお話させていただいた内容になります。
https://fukuten.connpass.com/event/333954/
Toshimasa Hashiguchi
January 14, 2025
Tweet
Share
More Decks by Toshimasa Hashiguchi
See All by Toshimasa Hashiguchi
PostmanでAPIの動作確認が楽になった話
h455h1
0
620
Other Decks in Programming
See All in Programming
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
320
CSC307 Lecture 13
javiergs
PRO
0
310
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
110
メタプログラミングで実現する「コードを仕様にする」仕組み/nikkei-tech-talk43
nikkei_engineer_recruiting
0
160
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
3.4k
Raku Raku Notion 20260128
hareyakayuruyaka
0
430
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
530
手戻りゼロ? Spec Driven Developmentとは@KAG AI week
tmhirai
1
160
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
200
Fundamentals of Software Engineering In the Age of AI
therealdanvega
0
140
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
210
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
120
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
340
58k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
240
Darren the Foodie - Storyboard
khoart
PRO
3
2.7k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Skip the Path - Find Your Career Trail
mkilby
1
72
Un-Boring Meetings
codingconduct
0
220
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.7k
Unsuck your backbone
ammeep
672
58k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Navigating Team Friction
lara
192
16k
30 Presentation Tips
portentint
PRO
1
250
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Transcript
ASP.NET Core の OpenAPIサポート 2025/1/11 .NET Conf 2024 Fukuoka x
Osaka
None
Toshimasa Hashiguchi Alterbooth.inc Webアプリケーション開発 Technology: C#、.NET、Azure、GitHub、XR Community: Fukuoka.NET、福岡XR部 X:@h455h1
OpenAPIの概要 - HTTP API の定義に使用される標準的なフォーマット - API のエンドポイント、リクエスト、レスポンスなどの情報を一貫して記述可能 - 機械にも人間にも優しい
- さまざまな開発者やAPIベンダー、ツールがOpenAPIを使用して連携可能
ASP.NET Core 9.0のOpenAPIサポート - ASP.NET Coreでは、OpenAPIのサポートが組み込まれている - ASP.NET Coreアプリでは、Microsoft.AspNetCore.OpenApiパッケージを使用し て、アプリ内のエンドポイントに関する情報を生成
- 生成されたOpenAPIドキュメントは、エンドポイントまたはシリアル化されたファイル を通して公開
ASP.NET Core 9.0 Web API テンプレート(MinimalAPI) エンドポイントを アプリケーションに追加 DIコンテナーに登録 Microsoft.AspNetCore.OpenApiパッ
ケージを介して提供
ASP.NET Core 9.0 Web API テンプレート(MinimalAPI) エンドポイントを アプリケーションに追加 DIコンテナーに登録 /openapi/v1.json
ASP.NET Core 9.0 Web API テンプレート(MinimalAPI) エンドポイントを アプリケーションに追加 DIコンテナーに登録
ASP.NET Core 8.0 Web API テンプレート との比較 Swaggerジェネレータを サービスコレクションに追加 APIドキュメントと
Swagger UI を提 供するミドルウェアを有効化
なぜSwagger(Swashbuckle )取り除かれたのか? Swaggerジェネレータを サービスコレクションに追加 APIドキュメントと Swagger UI を提 供するミドルウェアを有効化 https://dev.to/eminvergil/an-alternative-to-swagger-in-dotnet-9-2jd6
1. メンテナンスの問題 2. ASP.NET Coreの進化 3. OpenAPIへのフォーカス 4. 代替ツールの提供 5. コミュニティ主導のイノベーションの促進
Swagger(Swashbuckle)を使用する https://learn.microsoft.com/ja-jp/aspnet/core/fundamentals/openapi/using-openapi-documents?view =aspnetcore-9.0&WT.mc_id=%3Fwt.mc_id%3DDT-MVP-5004827#use-swagger-ui-for-local-ad-hoc -testing
ASP.NET Core アプリに OpenAPI メタデータを含める Minimal API Controller Base WebAPI
ビルド時に OpenAPI ドキュメントを生成する - Microsoft.Extensions.ApiDescription.Serverパッケージをインストール - プロジェクトファイルで出力されるAPIドキュメントの場所を指定 - dotnet build
ビルド時に OpenAPI ドキュメントを生成する
CIパイプラインでごにょごにょできるってコト?
GitHub Actionsを使用してWikiのAPIドキュメントを自動更新する APIの更新 ビルド Wiki Push OpenAPI Document Markdown GitHub
Actions
GitHub Actionsを使用してWikiのAPIドキュメントを自動更新する widdershins - OpenAPI仕様からMarkdownへの変換 - https://github.com/Mermade/widdershins
GitHub Actionsを使用してWikiのAPIドキュメントを自動更新する https://github.com/t0ottio13/sample-openapi-document-sync/actions
Demo
まとめ - ASP.NET Coreでは、Microsoft.AspNetCore.OpenApiパッケージと Microsoft.Extensions.ApiDescription.Serverパッケージを使用して、OpenAPIド キュメントの生成がサポートされている - ASP.NET Core Web
API テンプレートからSwashbuckleが削除された - CIパイプラインと組み合わせるとAPIドキュメントの自動生成ができる
おまけ1:.httpファイル https://youtu.be/uKm1ho881gk?si=wsEPfTLOzlitHOI2
おまけ:.httpファイル https://youtu.be/uKm1ho881gk?si=wsEPfTLOzlitHOI2 @name を使用するとリクエスト結果を変数に格納できる
おまけ:.httpファイル @nameで定義した変数へのアクセス方法 The expression should adhere to the following pattern:
{{requestName.(response|request).(body|headers).(*|JSONPath|XPath|Header Name)}}. https://youtu.be/uKm1ho881gk?si=wsEPfTLOzlitHOI2
ご清聴ありがとうございました。
References - https://learn.microsoft.com/ja-jp/aspnet/core/release-notes/aspnetcore-9.0?vie w=aspnetcore-9.0#openapi - https://learn.microsoft.com/ja-jp/aspnet/core/tutorials/getting-started-with-swa shbuckle?view=aspnetcore-7.0&tabs=visual-studio - https://devblogs.microsoft.com/dotnet/dotnet9-openapi/ -
https://dev.to/eminvergil/an-alternative-to-swagger-in-dotnet-9-2jd6 - https://youtu.be/ooP0vkST3X8?si=vuotRdxOGkMx5X4T - https://learn.microsoft.com/ja-jp/aspnet/core/fundamentals/openapi/using-ope napi-documents?view=aspnetcore-9.0&WT.mc_id=%3Fwt.mc_id%3DDT-MV P-5004827#use-swagger-ui-for-local-ad-hoc-testing