• Stars
    star
    119
  • Rank 297,930 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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());