9
9
using Newtonsoft . Json . Converters ;
10
10
using Newtonsoft . Json . Serialization ;
11
11
using System . Text ;
12
- using CheckDrive . Api . Filters ;
13
12
14
13
namespace CheckDrive . Api . Extensions ;
15
14
@@ -21,6 +20,10 @@ public static IServiceCollection ConfigureServices(this IServiceCollection servi
21
20
services . RegisterInfrastructure ( configuration ) ;
22
21
23
22
services . AddSingleton < FileExtensionContentTypeProvider > ( ) ;
23
+ services . AddSignalR ( options =>
24
+ {
25
+ options . EnableDetailedErrors = true ;
26
+ } ) ;
24
27
25
28
AddControllers ( services ) ;
26
29
AddSwagger ( services ) ;
@@ -56,15 +59,19 @@ private static void AddSwagger(IServiceCollection services)
56
59
. AddSwaggerGen ( setup =>
57
60
{
58
61
setup . SwaggerDoc ( "v1" , new OpenApiInfo { Title = "Check-Drive API" , Version = "v1" } ) ;
59
-
60
- setup . SchemaFilter < EnumSchemaFilter > ( ) ;
61
- } ) ;
62
+ } )
63
+ . AddSwaggerGenNewtonsoftSupport ( ) ;
62
64
}
63
65
64
66
private static void AddAuthentication ( IServiceCollection services , IConfiguration configuration )
65
67
{
66
68
var jwtOptions = configuration . GetSection ( nameof ( JwtOptions ) ) . Get < JwtOptions > ( ) ;
67
69
70
+ if ( jwtOptions is null )
71
+ {
72
+ throw new InvalidOperationException ( "Could not load JWT configurations." ) ;
73
+ }
74
+
68
75
services
69
76
. AddAuthentication ( options =>
70
77
{
@@ -84,7 +91,7 @@ private static void AddAuthentication(IServiceCollection services, IConfiguratio
84
91
ValidateLifetime = true ,
85
92
ValidateIssuerSigningKey = true ,
86
93
IssuerSigningKey = new SymmetricSecurityKey (
87
- Encoding . UTF8 . GetBytes ( jwtOptions ! . SecretKey ) )
94
+ Encoding . UTF8 . GetBytes ( jwtOptions . SecretKey ) )
88
95
} ;
89
96
90
97
options . Events = new JwtBearerEvents
0 commit comments