This repository was archived by the owner on Apr 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/NET6CustomLibrary/Extensions Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
- using System . Net . Mime ;
1
+ using System . ComponentModel ;
2
+ using System . Net . Mime ;
2
3
using Microsoft . AspNetCore . Builder ;
3
4
using Microsoft . AspNetCore . Diagnostics . HealthChecks ;
4
5
using Microsoft . AspNetCore . Http ;
9
10
using Microsoft . OpenApi . Models ;
10
11
using MySqlConnector ;
11
12
using NET6CustomLibrary . DateTime . Converters ;
13
+ using NET6CustomLibrary . DateTime . TypeConverters ;
12
14
using NET6CustomLibrary . Serilog . Services ;
13
15
using Serilog ;
14
16
using Swashbuckle . AspNetCore . SwaggerGen ;
@@ -87,6 +89,14 @@ public static IMvcBuilder AddDateTimeJsonOptions(this IMvcBuilder builder)
87
89
return builder ;
88
90
}
89
91
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
+
90
100
public static SwaggerGenOptions AddDateTimeSwaggerGenOptions ( this SwaggerGenOptions options )
91
101
{
92
102
options . MapType < DateOnly > ( ( ) => new OpenApiSchema
You can’t perform that action at this time.
0 commit comments