-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
What are you wanting to achieve?
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.
Thanks!
What code or approach do you have so far?
builder.Services.AddOpenApi(static options =>
{
options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_0;
});
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.UseSwaggerUI(static options =>
{
options.SwaggerEndpoint("/openapi/v1.json", "My API V1");
});
}
Additional context
No response