-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
DateOnly and TimeOnly are displayed as complex objects in open-api schemas rather simple string #37045
Comments
This may need a change in Swashbuckle and N-Swag for these new primitives. |
Looked into this briefly. Draft 07 of the JSON schema adds support for the |
Looks like this doesn't happen now in .NET 7, but it's still not perfect. It's now projected as a string (good!) but with the "date-time" format (bad!). Seems Swagger does actually support "date" as a format now so we should get Swashbuckle updated to map |
Workaround by adding a type mapping to Swashbuckle until they fix their defaults: builder.Services.AddSwaggerGen(
c.MapType<DateOnly>(() => new OpenApiSchema
{
Type = "string",
Format = "date"
});
); |
Thanks for contacting us. We're moving this issue to the |
@rafikiassumani-msft I think we should close this in favor of domaindrivendev/Swashbuckle.AspNetCore#2319. I already have a PR out to fix it at domaindrivendev/Swashbuckle.AspNetCore#2480 |
Describe the bug
DateOnly
andTimeOnly
are being displayed as complex objects in open api schemas for Minimal API endpoints rather than being treated as simple strings. It will make sense for open api to treat them asstring -$date-only
andstring -$time-only
app.MapGet("/events", (DateOnly dateOnly, TimeOnly timeonly) => $" date and time values ... ")
Exceptions (if any)
The text was updated successfully, but these errors were encountered: