Skip to content

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

Notifications You must be signed in to change notification settings

SteveDunn/DateOnlyTimeOnly.AspNet

 
 

Repository files navigation

DateOnlyTimeOnly.AspNet

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

Installation

Get it from NuGet

  • Base package: NuGet
  • Swashbuckle support: NuGet

Usage

Call UseDateOnlyTimeOnlyStringConverters on options for AddControllers and AddJsonOptions:

builder.Services
    .AddControllers(options => options.UseDateOnlyTimeOnlyStringConverters())
    .AddJsonOptions(options => options.UseDateOnlyTimeOnlyStringConverters());

After that all DateOnly and TimeOnly action arguments will be received and returned as ISO 8601 string.

Swagger support

NSwag

No additional action is needed.

Swashbuckle

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

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%