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 ;
23using Microsoft . AspNetCore . Builder ;
34using Microsoft . AspNetCore . Diagnostics . HealthChecks ;
45using Microsoft . AspNetCore . Http ;
910using Microsoft . OpenApi . Models ;
1011using MySqlConnector ;
1112using NET6CustomLibrary . DateTime . Converters ;
13+ using NET6CustomLibrary . DateTime . TypeConverters ;
1214using NET6CustomLibrary . Serilog . Services ;
1315using Serilog ;
1416using 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
You can’t perform that action at this time.
0 commit comments