Skip to content

How to make Swagger UI work with .NET 9's OpenAPI #10278

@rjperes

Description

@rjperes

I am trying to setup Swagger UI so as to use the OpenAPI included in the .NET 9 project templates.
I essentially added this:

app.UseSwaggerUI(static options => { options.SwaggerEndpoint("/openapi/v1.json", "My API V1"); });

The /openapi/v1.json file is accessible, however, Swagger UI always complaints about a missing version attribute:

Unable to render this definition
The provided definition does not specify a valid version field.

Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.x.y (for example, openapi: 3.1.0).

However, inspecting the JSON document, I can see it's there:

{ "openapi": "3.0.4", "info": { "title": "WebApi | v1", "version": "1.0.0" },

What am I missing? Using the latest versions of all of the packages.
I understand this may be related to #10247. Is there any way to fix this before this issue gets merged?
Thanks!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions