Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 1.23 KB

README.md

File metadata and controls

41 lines (25 loc) · 1.23 KB

DateOnlyTimeOnly.AspNet

Adds support for receiving and returning DateOnly/TimeOnly as ISO 8601 string to ASP.NET Core API

Installation

Get it from NuGet

  • Base package: NuGet
  • Swashbuckle support: NuGet

Usage

Call AddDateOnlyTimeOnlyStringConverters on services:

builder.Services.AddDateOnlyTimeOnlyStringConverters();

After that:

  • For .NET 6: all DateOnly and TimeOnly action arguments will be received and returned as ISO 8601 string;
  • For .NET 7: adds support to use TimeOnly as Dictionary key (the rest is available out of the box).

Swagger support

NSwag

No additional action is needed.

Swashbuckle

v6.5.0 and after:

No additional action is needed.

Before v6.5.0:

Install DateOnlyTimeOnly.AspNet.Swashbuckle package, and add UseDateOnlyTimeOnlyStringConverters to your swagger configuration:

builder.Services.AddSwaggerGen(c => c.UseDateOnlyTimeOnlyStringConverters());