Install-Package Swashbuckle -Pre

1.Startup

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc(); //******************* swagger start ***********************
services.AddSwaggerGen(c =>
{
c.SingleApiVersion(new Info
{
Version = "v1", // 这个属性必须要填,否则会引发一个异常
Title = "Feature List",
Description = "特征"
});
}); services.ConfigureSwaggerGen(c =>
{
// 配置生成的 xml 注释文档路径
c.IncludeXmlComments(GetXmlCommentsPath());
}); //******************* swagger end ***********************
} private string GetXmlCommentsPath()
{
var app = PlatformServices.Default.Application;
return Path.Combine(app.ApplicationBasePath, Path.ChangeExtension(app.ApplicationName, "xml"));
} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug(); app.UseMvc(); //******************* swagger start ***********************
app.UseSwagger();
app.UseSwaggerUi("swagger/ui/index");
//******************* swagger end ***********************
}

如上:

//******************* swagger start ***********************

//******************* swagger end ***********************

2.launchSettings.json

{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40675/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger/ui/index",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"SigmalHex.WebApi": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger/ui/index",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:40676"
}
}
}

如:

"launchUrl": "swagger/ui/index",

.net core 安装Swagger的更多相关文章

  1. asp.net core 使用 swagger 生成接口文档

    参考地址:http://www.cnblogs.com/daxnet/p/6181366.html http://www.jianshu.com/p/fa5a9b76f3ed 微软参考文档:https ...

  2. .NET Core和Swagger 生成 Api 文档

    测试/生产环境的BUG 这里更新一下在本地调试正常,在INT/PROD上抛错,错误信息为: */**/*.xml(Swagger json file) 文件找不到,在startup 里builder ...

  3. .NET Core和Swagger 生成 Api 文档转

    阅读目录 1.引用 2.打开startup.cs文件 3.设置XML注释 4.运行结果 5.主要问题的解决办法 6.可以自定义UI 前言 最近写了好多Web api, 老大说太乱了,要整理一下,使用S ...

  4. C#中缓存的使用 ajax请求基于restFul的WebApi(post、get、delete、put) 让 .NET 更方便的导入导出 Excel .net core api +swagger(一个简单的入门demo 使用codefirst+mysql) C# 位运算详解 c# 交错数组 c# 数组协变 C# 添加Excel表单控件(Form Controls) C#串口通信程序

    C#中缓存的使用   缓存的概念及优缺点在这里就不多做介绍,主要介绍一下使用的方法. 1.在ASP.NET中页面缓存的使用方法简单,只需要在aspx页的顶部加上一句声明即可:  <%@ Outp ...

  5. .net core 使用swagger生成API文档

    [1]安装Swashbuckle.AspNetCore包 [2]在Startup.cs中注册swagger //注册Swagger生成器,定义一个和多个Swagger 文档 services.AddS ...

  6. .net core 使用 swagger 生成接口文档

    微软参考文档:https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs= ...

  7. asp.net core 集成swagger ui

    什么是Swagger? 说swagger 之前,我们先说一下OpenApi 规范. OpenApi 是一种和语言无关的用于描述RESTAPIs 接口功能的一种规范,对RESTAPIs 接口的描述包括: ...

  8. .net core的Swagger接口文档使用教程(二):NSwag

    上一篇介绍了Swashbuckle ,地址:.net core的Swagger接口文档使用教程(一):Swashbuckle 讲的东西还挺多,怎奈微软还推荐了一个NSwag,那就继续写吧! 但是和Sw ...

  9. .net core 安装失败 的问题彻底解决

    解决方法: 已经整理好包:   https://pan.baidu.com/s/1dFuU80p 下载解压运行: DotNetCore.1.0.1-VS2015Tools.Preview2.0.2.e ...

随机推荐

  1. JS中Document节点总结

    document对象是documentHTML的一个实例,也是window对象的一个属性,因此可以将document对象作为一个全局对象来访问. Document节点的子节点可以是DocumentTy ...

  2. PSP1123

    PSP时间图: 类型 任务 开始时间 结束时间 净时间 中断时间 日期 开会 开会 16:17 16:50 33 0 20171027 开会 开会 17:00 17:22 22 0 20171028 ...

  3. html中图片自适应浏览器和屏幕,宽度高度自适应

    1.(宽度自适应):在网页代码的头部,加入一行viewport元标签. <meta name="viewport" content="width=device-wi ...

  4. Python的7种性能测试工具:timeit、profile、cProfile、line_profiler、memory_profiler、PyCharm图形化性能测试工具、objgraph

    1.timeit: >>> import timeit >>> def fun(): ): a = i * i >>> timeit.timeit ...

  5. c运行时库,c标准库,Windows系统api的关系

    原文地址:http://blog.csdn.net/seastars_sh/article/details/8233324 C运行库和C标准库的关系 C标准库,顾名思义既然是标准,就是由标准组织制定的 ...

  6. 判断集合不为空Java

    list.size>0判断集合size是否大于0 list.isEmpty()判断集合是否为空,返回布尔值

  7. [计算机网络] TCP的拥塞控制

    引言 计算机网络中的带宽.交换结点中的缓存和处理机等,都是网络的资源.在某段时间,若对网络中某一资源的需求超过了该资源所能提供的可用部分,网络的性能就会变坏.这种情况就叫做拥塞. 拥塞控制就是防止过多 ...

  8. [C/C++] 友元函数和友元类

    A---友元函数: class Data{ public: ... friend int f(int &m);//友元函数 ... } 友元函数是可以直接访问类的私有成员的非成员函数.它是定义 ...

  9. Elasticsearch cat Apis

    1._cat列入所有有效命令 GET /_cat 返回:有个猫...所以不难想象为啥是cat api =^.^= /_cat/allocation /_cat/shards /_cat/shards/ ...

  10. MHA选择主库源码解析

    知数堂第5期MySQL实战班学员,第10期MySQL优化班学员,现任职助教. MHA在选择新的主库之前,会先把活着的slave分为几个数组,分别为latest(最靠前的slave数组),pref(优先 ...