Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rjperes opened this issue Feb 7, 2025 · 2 comments
Open

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

rjperes opened this issue Feb 7, 2025 · 2 comments

Comments

@rjperes
Copy link

rjperes commented Feb 7, 2025

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!

@rjperes
Copy link
Author

rjperes commented Feb 7, 2025

OK, it works with OpenAPI V2.

@ibakirov
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants