我想用swagger文档创建ASP.NET WEB API,但我有一个奇怪的问题 . 当我使用自己的JSON格式化器实现设置api格式时,禁用了swagger文档 . 在控制台中,我可以看到JavaScript Exception正在抛出 .

public static void Register(HttpConfiguration config)
    {
        // Web API configuration and services
        var jsonFormatter = new JsonMediaTypeFormatter();
        config.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator(jsonFormatter));
        // Web API routes
        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    }

enter image description here

enter image description here

{“swagger”:“2.0”,“info”:{“version”:“v1”,“title”:“REST”,“description”:null,“termsOfService”:null,“contact”:null,“许可证 “:NULL,” vendorExtensions “:{}},” 宿主 “:” 本地主机:58144" , “基本路径”:NULL, “方案”:[ “HTTP”], “消耗”:NULL, “ 生产环境 ”:空“路径”:{ “/ API /用户”:{ “$ REF”:NULL, “获得”:{ “标签”:[ “用户”], “摘要”:空, “说明”:NULL,“externalDocs “:NULL,” operationId “:” Users_GetUsers “ ”消耗“:[], ” 生产环境 “:[ ”应用/ JSON“, ”文本/ JSON“, ”应用/ XML“, ”文本/ XML“],”参数 “:空,” 回应 “:{” 200 “:{” 说明 “:” OK”, “纲目”:{ “$ REF”:空, “格式”:空, “ Headers ”:空, “说明” :空, “默认”:空, “multipleOf”:空, “最大”:空, “exclusiveMaximum”:空, “最低”:空, “exclusiveMinimum”:空, “最大长度”:空 “的minLength”:空“图案”:NULL, “maxItems”:NULL, “minItems”:NULL, “uniqueItems”:NULL, “maxProperties”:NULL, “minProperties”:空, “必需的”:NULL, “枚举”:NULL,”输入“:”阵列”,‘项目’: