0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[.NET 9] Minimal API で Swagger UIが「Unable to render this definition」になったら

Last updated at Posted at 2025-06-01

.NET Minimal API のプロジェクトにて、Swagger UIが正常に表示されない事象が発生しました。

image.png

Middlewareの設定や、/swagger/v1/swagger.json の内容を確認しても特に異常はなく、
openapi: 3.0.4 のバージョン表記がきちんとなされている状態。

しかしながら、Microsoft.AspNetCre.OpenApi 9.0.5 が出力する Open API 3.0.4 の記法の一部について、Swagger UIと互換性がない場合があるようです。

以下の指定により、OpenAPI 2.0にバージョンを強制的に下げることでエラーを回避できました。

app.UseSwagger(c =>
{
    c.OpenApiVersion = Microsoft.OpenApi.OpenApiSpecVersion.OpenApi2_0;
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?