-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
I think this may be a regression of #2319, but in investigating this stackoverflow question, I found that DateOnly
fields are still not showing correctly in the Swagger UI in ASP.NET 8 latest.
To reproduce:
- Download and install .NET 8 SDK 8.0.2 (SDK 8.0.201)
dotnet new webapi
dotnet run
- Browse to Swagger endpoint, i.e.
http://localhost:5261/swagger
Notice DateOnly
and DayOfWeek
have been broken out into properties as if custom types, rather than being a date
.

Apply the workaround:
builder.Services.AddSwaggerGen(options => {
options.MapType<DateOnly>(() => new OpenApiSchema {
Type = "string",
Format = "date" });
});
This shouldn't be necessary though, right?