Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit ae56dca

Browse files
committed
Fix
1 parent 46d1515 commit ae56dca

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/NET6CustomLibrary/Extensions/DependencyInjection.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Net.Mime;
1+
using System.ComponentModel;
2+
using System.Net.Mime;
23
using Microsoft.AspNetCore.Builder;
34
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
45
using Microsoft.AspNetCore.Http;
@@ -9,6 +10,7 @@
910
using Microsoft.OpenApi.Models;
1011
using MySqlConnector;
1112
using NET6CustomLibrary.DateTime.Converters;
13+
using NET6CustomLibrary.DateTime.TypeConverters;
1214
using NET6CustomLibrary.Serilog.Services;
1315
using Serilog;
1416
using Swashbuckle.AspNetCore.SwaggerGen;
@@ -87,6 +89,14 @@ public static IMvcBuilder AddDateTimeJsonOptions(this IMvcBuilder builder)
8789
return builder;
8890
}
8991

92+
public static IServiceCollection AddDateTimeOnlyAttributes(this IServiceCollection services)
93+
{
94+
TypeDescriptor.AddAttributes(typeof(DateOnly), new TypeConverterAttribute(typeof(DateOnlyTypeConverter)));
95+
TypeDescriptor.AddAttributes(typeof(TimeOnly), new TypeConverterAttribute(typeof(TimeOnlyTypeConverter)));
96+
97+
return services;
98+
}
99+
90100
public static SwaggerGenOptions AddDateTimeSwaggerGenOptions(this SwaggerGenOptions options)
91101
{
92102
options.MapType<DateOnly>(() => new OpenApiSchema

0 commit comments

Comments
 (0)