aspnet zero的Swagger默認沒有Authorize 按鈕,這樣測試起來很不方便,通過一番操做,終於成功解決了。web
其實比較簡單,只要在web.Host項目裏的startup.cs裏的代碼添加一些代碼就能夠了:api
原來的代碼:測試
services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Title = "FlightProxyFee API", Version = "v1" }); options.DocInclusionPredicate((docName, description) => true); }
新增長代碼:blog
services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Title = "FlightProxyFee API", Version = "v1" }); options.DocInclusionPredicate((docName, description) => true); //新增長代碼 options.AddSecurityDefinition("Bearer", new ApiKeyScheme { Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", Name = "Authorization", In = "header", Type = "apiKey" }); });