@@ -18,22 +18,38 @@ public static class IServiceCollectionExtensions
1818 public static void AddJsonApi < TContext > ( this IServiceCollection services )
1919 where TContext : DbContext
2020 {
21- _addInternals < TContext > ( services , new JsonApiOptions ( ) ) ;
21+ var mvcBuilder = services . AddMvc ( ) ;
22+ AddInternals < TContext > ( services , new JsonApiOptions ( ) , mvcBuilder ) ;
2223 }
2324
2425 public static void AddJsonApi < TContext > ( this IServiceCollection services , Action < JsonApiOptions > options )
2526 where TContext : DbContext
2627 {
2728 var config = new JsonApiOptions ( ) ;
29+
2830 options ( config ) ;
29- _addInternals < TContext > ( services , config ) ;
31+
32+ var mvcBuilder = services . AddMvc ( ) ;
33+ AddInternals < TContext > ( services , config , mvcBuilder ) ;
3034 }
3135
32- private static void _addInternals < TContext > ( IServiceCollection services , JsonApiOptions jsonApiOptions )
33- where TContext : DbContext
36+ public static void AddJsonApi < TContext > ( this IServiceCollection services ,
37+ Action < JsonApiOptions > options ,
38+ IMvcBuilder mvcBuilder ) where TContext : DbContext
39+ {
40+ var config = new JsonApiOptions ( ) ;
41+
42+ options ( config ) ;
43+
44+ AddInternals < TContext > ( services , config , mvcBuilder ) ;
45+ }
46+
47+ private static void AddInternals < TContext > ( IServiceCollection services ,
48+ JsonApiOptions jsonApiOptions ,
49+ IMvcBuilder mvcBuilder ) where TContext : DbContext
3450 {
3551 services . AddJsonApiInternals < TContext > ( jsonApiOptions ) ;
36- services . AddMvc ( )
52+ mvcBuilder
3753 . AddMvcOptions ( opt => {
3854 opt . Filters . Add ( typeof ( JsonApiExceptionFilter ) ) ;
3955 opt . SerializeAsJsonApi ( jsonApiOptions ) ;
0 commit comments