Closed mattjohnsonpint closed 5 months ago
Also experiancing this with Controllers, when I tried upgrading to Swashbuckle.AspNetCore 6.5.0 to fix DateOnly serialisation fixed in https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/2319 but the Swagger.json broke with missing elements so I had to revert back to Swashbuckle.AspNetCore 6.4.0.
Test
dotnet --version
8.0.200
We should probably make a copy of WeatherForecast and add it to our integration tests, as it seems to come up often as the repro for issues 😄
Looks like this will be resolved by #2799.
TimeOnly also not for me. The config.MapType<TimeOnly>(() => new OpenApiSchema { Type = "string", Format = "time" });
also won't fix this in AddSwaggerGen.
I expect "14:32:55.348".
It would be nice to have a default value that works out of the box, similar to System.DateTime 🙂
@johanvaneck Swashbuckle could in theory set an example value for all DateOnly fields. But it doesn't do it for DateTime fields either, that default value is created by Swagger UI. Therefore I think you should create an issue for that (or vote on an existing one) in the https://github.com/swagger-api/swagger-ui repository.
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:
dotnet new webapi
dotnet run
http://localhost:5261/swagger
Notice
DateOnly
andDayOfWeek
have been broken out into properties as if custom types, rather than being adate
.Apply the workaround:
Then it works:
This shouldn't be necessary though, right?