title: Cannot replace default JSON contract resolver in ASP.Core 3
body: <p>After creating basic Web API project based on .NET Core 3.0 framework, all API responses were coming in camel case. I installed SwashBuckle Swagger + built-in JSON serializer from System.Text.Json, specifically, to display enums as strings, everything worked as before. Then, I decided to switch to NSwag + NewtonSoftJson, because of some limitations of built-in serializer with dynamic and expando objects. Now, all API responses are displayed in PascalCase and I cannot change neither naming policy, nor even create custom contract resolver. </p>
  
  <p><strong>Example</strong></p>
  
  <p><a href="https://forums.asp.net/t/2138758.aspx?Configure+SerializerSettings+ContractResolver" rel="nofollow noreferrer">https://forums.asp.net/t/2138758.aspx?Configure+SerializerSettings+ContractResolver</a></p>
  
  <p><strong>Question</strong> </p>
  
  <p>I suspect that maybe some package overrides contract resolver behind the scene. How to make sure that API service uses ONLY custom contract resolver that I assign at startup and ignores all other similar settings? </p>
  
  <p><strong>Custom JSON contract resolver</strong></p>
  
  <pre><code>public class CustomContractResolver : IContractResolver
  {
    private readonly IHttpContextAccessor _context;
    private readonly IContractResolver _contract;
    private readonly IContractResolver _camelCaseContract;
  
    public CustomContractResolver(IHttpContextAccessor context)
    {
      _context = context;
      _contract = new DefaultContractResolver();
      _camelCaseContract = new CamelCasePropertyNamesContractResolver();
    }
  
    // When API endpoint is hit, this method is NOT triggered
  
    public JsonContract ResolveContract(Type value)
    {
      return _camelCaseContract.ResolveContract(value);
    }
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>[ApiController]
  public class RecordsController : ControllerBase
  {
    [HttpGet]
    [Route("services/records")]
    [ProducesResponseType(typeof(ResponseModel&lt;RecordEntity&gt;), 200)]
    public async Task&lt;IActionResult&gt; Records([FromQuery] QueryModel queryModel)
    {
      var response = new ResponseModel&lt;RecordEntity&gt;();
  
      return Content(JsonConvert.SerializeObject(response), "application/json"); // NewtonSoft serializer
    }
  }
  </code></pre>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
    services
      .AddCors(o =&gt; o.AddDefaultPolicy(builder =&gt; builder
        .AllowAnyOrigin()
        .AllowAnyHeader()
        .AllowAnyMethod()));
  
    services
      .AddControllers(o =&gt; o.RespectBrowserAcceptHeader = true)
      /*
      .AddJsonOptions(o =&gt;
      {
        o.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
        o.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
        o.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
      })
      */
      .AddNewtonsoftJson(o =&gt;
      {
        o.UseCamelCasing(true);
        o.SerializerSettings.Converters.Add(new StringEnumConverter());
        //o.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver { NamingStrategy = new CamelCaseNamingStrategy() };
        o.SerializerSettings.ContractResolver = new CustomContractResolver(new HttpContextAccessor());
      });
  
    services.AddOpenApiDocument(o =&gt;   // NSwag
    {
      o.PostProcess = document =&gt;
      {
        document.Info.Version = "v1";
        document.Info.Title = "Demo API";
      };
    });
  
    DataConnection.DefaultSettings = new ConnectionManager(DatabaseOptionManager.Instance); // LINQ to DB
  }
  
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
    if (env.IsDevelopment())
    {
      app.UseDeveloperExceptionPage();
    }
  
    app.UseCors(o =&gt; o.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
    app.UseRouting();
    app.UseAuthorization();
    app.UseEndpoints(o =&gt; o.MapControllers());
  
    app.UseOpenApi();                                // NSwag
    app.UseSwaggerUi3(o =&gt; o.Path = "/v2/docs");
    app.UseReDoc(o =&gt; o.Path = "/v1/docs");
  }
  </code></pre>