1212using JsonApiDotNetCore . Services . Operations . Processors ;
1313using Microsoft . AspNetCore . Http ;
1414using Microsoft . AspNetCore . Mvc ;
15+ using Microsoft . AspNetCore . Mvc . Filters ;
1516using Microsoft . EntityFrameworkCore ;
1617using Microsoft . Extensions . DependencyInjection ;
1718
@@ -44,12 +45,7 @@ public static IServiceCollection AddJsonApi<TContext>(this IServiceCollection se
4445
4546 config . BuildContextGraph ( builder => builder . AddDbContext < TContext > ( ) ) ;
4647
47- mvcBuilder
48- . AddMvcOptions ( opt =>
49- {
50- opt . Filters . Add ( typeof ( JsonApiExceptionFilter ) ) ;
51- opt . SerializeAsJsonApi ( config ) ;
52- } ) ;
48+ mvcBuilder . AddMvcOptions ( opt => AddMvcOptions ( opt , config ) ) ;
5349
5450 AddJsonApiInternals < TContext > ( services , config ) ;
5551 return services ;
@@ -63,17 +59,19 @@ public static IServiceCollection AddJsonApi(this IServiceCollection services,
6359
6460 options ( config ) ;
6561
66- mvcBuilder
67- . AddMvcOptions ( opt =>
68- {
69- opt . Filters . Add ( typeof ( JsonApiExceptionFilter ) ) ;
70- opt . SerializeAsJsonApi ( config ) ;
71- } ) ;
62+ mvcBuilder . AddMvcOptions ( opt => AddMvcOptions ( opt , config ) ) ;
7263
7364 AddJsonApiInternals ( services , config ) ;
7465 return services ;
7566 }
7667
68+ private static void AddMvcOptions ( MvcOptions options , JsonApiOptions config )
69+ {
70+ options . Filters . Add ( typeof ( JsonApiExceptionFilter ) ) ;
71+ options . Filters . Add ( typeof ( TypeMatchFilter ) ) ;
72+ options . SerializeAsJsonApi ( config ) ;
73+ }
74+
7775 public static void AddJsonApiInternals < TContext > (
7876 this IServiceCollection services ,
7977 JsonApiOptions jsonApiOptions ) where TContext : DbContext
@@ -141,6 +139,8 @@ public static void AddJsonApiInternals(
141139 services . AddScoped < IQueryParser , QueryParser > ( ) ;
142140 services . AddScoped < IControllerContext , Services . ControllerContext > ( ) ;
143141 services . AddScoped < IDocumentBuilderOptionsProvider , DocumentBuilderOptionsProvider > ( ) ;
142+
143+ // services.AddScoped<IActionFilter, TypeMatchFilter>();
144144 }
145145
146146 private static void AddOperationServices ( IServiceCollection services )
0 commit comments