我想用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 }
);
}
{"招摇":" 2.0""信息" {"版本":" V1" "标题":" REST""描述":空," termsOfService":空,"接触&#34 ;:空,"许可证":空," vendorExtensions":{}},"主机":"本地主机:58144""基本路径":空,"方案":[" HTTP&#34],"消耗":空,"产生":空,& #34;路径" {" / API /用户和#34; {" $ REF":空,"获得" {"标记&# 34;:["用户和#34;]"总结":空,"描述":空," externalDocs":空,&#34 ; operationId":" Users_GetUsers""消耗":[],"产生":["应用/ JSON"&# 34;文本/ JSON""应用/ XML""文本/ XML&#34],"参数":空,"响应&#34 ;:{" 200" {"描述":" OK""模式" {" $ REF" :空,"格式":空,"标题":空,"描述":空,"默认":空,&#34 ; MULT ipleOf":空,"最大":空," exclusiveMaximum":空,"最小":空," exclusiveMinimum":空"最大长度":空,"的minLength":空,"模式":空," maxItems":空," minItems& #34;:空," uniqueItems":空," maxProperties":空," minProperties":空,"需":空, "枚举":空,"类型":"阵列""项目":