银盘万花筒第二季,88.7,yy直播出事视频下载
开发webapi时通常需要为调用我们api的客户端提供说明文档。swagger便是为此而存在的,能够提供在线调用、调试的功能和api文档界面。
环境介绍:asp.net core webapi + swagger。
swashbuckle.aspnetcore 中分为3个组件。
package | description |
---|---|
swashbuckle.aspnetcore.swagger | exposes swaggerdocument objects as a json api. it expects an implementation of iswaggerprovider to be registered which it queries to retrieve swagger document(s) before returning as serialized json |
swashbuckle.aspnetcore.swaggergen | injects an implementation of iswaggerprovider that can be used by the above component. this particular implementation automatically generates swaggerdocument(s) from your routes, controllers and models |
swashbuckle.aspnetcore.swaggerui |
exposes an embedded version of the swagger-ui. you specify the api endpoints where it can obtain swagger json and it uses them to power interactive docs for your api、 |
安装swashbuckle.aspnetcore,在nuget中搜索或是包管理器下输入命令都可,找到这个包,安装,其中有三个小弟是三个不同的组件,在第一个中都集成了。
加入swagger中间件
1 public void configure(iapplicationbuilder app, ihostingenvironment env) 2 { 3 if (env.isdevelopment()) 4 { 5 app.usedeveloperexceptionpage(); 6 } 7 8 app.useswagger(); 9 app.useswaggerui(c => 10 { 11 c.swaggerendpoint("/swagger/v1/swagger.json", "my api v1"); 12 }); 13 14 app.usemvc(); 15 }
加入swagger服务
1 public void configureservices(iservicecollection services) 2 { 3 services.addmvc().setcompatibilityversion(compatibilityversion.version_2_1); 4 5 services.addswaggergen(options => 6 { 7 options.swaggerdoc("v1", new info { title = "my webapi document", version = "v1" }); 8 }); 9 }
2018-08-18,望技术有成后能回来看见自己的脚步
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论