Swashbuckle SwaggerGen 不尊重注入的自定义 Json 序列化器

Amr*_*eda 6 .net-core swashbuckle asp.net-core-webapi

我使用JsonApiSerializer来遵守 Json API 规范,如下所示:

 services.AddMvc(options =>
        {
            var jsonApiFormatter = new JsonOutputFormatter(new JsonApiSerializerSettings(), ArrayPool<char>.Shared);
            options.OutputFormatters.RemoveType<JsonOutputFormatter>();
            options.OutputFormatters.Insert(0, jsonApiFormatter);
        });
Run Code Online (Sandbox Code Playgroud)

但 SwaggerGen 忽略它,仍然使用默认的 Json Serializer (Json.NET)

我如何强制它适应新的序列化器。