鍓嶈█锛氬井杞簬鍓嶅ぉ鍙戝竷.net core 3.1姝e紡鐗�,骞跺皢闀挎湡鏀寔3.1銆傛墍浠ユ垜鍚埌杩欎釜娑堟伅鍚庡氨鎬ュ繖涓嬭浇.net core 3.1鐨凷DK鍜孯untime,搴旇鏄叕鍙告渶鍏堢敤3.1鐨勬敾鍩庣嫯浜嗮煒勩��
OK锛佸簾璇濆皯璇达紝浠婂ぉ鐨勭洰鐨勬槸鍩轰簬.net core 3.1寤轰竴涓獁eb api鐨勯」鐩�
鍏堜笅杞�.net core 3.1鐨凷DK(寮�鍙�.net core椤圭洰鏃朵細鐢ㄥ埌)鍜孯untime(鐢ㄦ潵杩愯.net core鐨勫簲鐢ㄧ▼搴�)
鍦板潃锛�https://dotnet.microsoft.com/download/visual-studio-sdks?utm_source=getdotnetsdk&utm_medium=referral
鍒涘缓ASP.NET Core web椤圭洰 ps:涓嶈閫夐敊浜嗮煒�
杩欓噷璇翠竴涓嬮」鐩洰褰曚笅鐨勫悇涓枃浠剁殑浣滅敤
寮曞叆Swashbuckle.AspNetCore绋嬪簭鍖�
鎵ц浠ヤ笅鍛戒护
Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc4
娣诲姞 骞堕厤缃甋wagger涓棿浠�
services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" }); });
app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); });
鐜板湪娣诲姞涓�涓帶鍒跺櫒,鍐欎竴涓帴鍙g湅鐪嬭兘涓嶈兘鍑烘潵
鍦板潃鏍忔敼涓�涓�
swagger/index.html
濡傛灉瀵规帴鍙e仛浜唜ml娉ㄩ噴锛岃鍦⊿tartup娣诲姞濡備笅浠g爜,鎵嶅彲浠ユ樉绀哄嚭鏉�
鍏堝紩鍏uGet鍖�:Microsoft.Extensions.PlatformAbstractions
鐒跺悗鍙抽敭灞炴��
鍐嶅湪Startup涓坊鍔犱笅闈㈢殑浠g爜
var basePath = PlatformServices.Default.Application.ApplicationBasePath; //Core.Admin.webapi.xml鏄垜鐨勯」鐩敓鎴怷ML鏂囨。鐨勫悗缂�鍚�,鍏蜂綋鐨勪互浣犻」鐩负涓� var xmlPath = Path.Combine(basePath, "Core.Admin.webapi.xml"); c.IncludeXmlComments(xmlPath);
杩愯椤圭洰锛屾敞閲婂凡缁忓嚭鏉ヤ簡
鍦╨aunchSettings.json涓洿鏀逛竴涓媗aunchUrl杩欎釜鐜鍙橀噺锛岃繖鏍峰氨涓嶇敤姣忔閮芥敼鍦板潃鏍忎簡
鏈�鍚庨檮涓婂井杞畼鏂规暀绋嬪湴鍧�
https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1&tabs=visual-studio