• 创建API项目
  • 修改原工程文件,该行为是为了避免和引入第三方API工程文件冲突
  • 修改发布设置
  • 引入需要生成文档的相关文件,将第三方API依赖的相关文件(XML文件非常重要,是注释显示的关键),复制到文档工程的bin目录下,为避免引用依赖出错,尽可能全拷贝,宁多勿少
  • 修改XML文件读取逻辑,可读取多个XML文件(原有工程中只能读取单个XML文件),添加类MultiXmlDocumentationProvider,代码如下:
 

public class MultiXmlDocumentationProvider : IDocumentationProvider, IModelDocumentationProvider

{
/*********

** Properties

*********/

/// <summary>The internal documentation providers for specific files.</summary>

private readonly XmlDocumentationProvider[] Providers;

/*********

** Public methods

*********/

/// <summary>Construct an instance.</summary>

/// <param name="paths">The physical paths to the XML documents.</param>

public MultiXmlDocumentationProvider(params string[] paths)

{

this.Providers = paths.Select(p => new XmlDocumentationProvider(p)).ToArray();

}

/// <summary>Gets the documentation for a subject.</summary>

/// <param name="subject">The subject to document.</param>

public string GetDocumentation(MemberInfo subject)

{

return this.GetFirstMatch(p => p.GetDocumentation(subject));

}

/// <summary>Gets the documentation for a subject.</summary>

/// <param name="subject">The subject to document.</param>

public string GetDocumentation(Type subject)

{

return this.GetFirstMatch(p => p.GetDocumentation(subject));

}

/// <summary>Gets the documentation for a subject.</summary>

/// <param name="subject">The subject to document.</param>

public string GetDocumentation(HttpControllerDescriptor subject)

{

return this.GetFirstMatch(p => p.GetDocumentation(subject));

}

/// <summary>Gets the documentation for a subject.</summary>

/// <param name="subject">The subject to document.</param>

public string GetDocumentation(HttpActionDescriptor subject)

{

return this.GetFirstMatch(p => p.GetDocumentation(subject));

}

/// <summary>Gets the documentation for a subject.</summary>

/// <param name="subject">The subject to document.</param>

public string GetDocumentation(HttpParameterDescriptor subject)

{

return this.GetFirstMatch(p => p.GetDocumentation(subject));

}

/// <summary>Gets the documentation for a subject.</summary>

/// <param name="subject">The subject to document.</param>

public string GetResponseDocumentation(HttpActionDescriptor subject)

{

return this.GetFirstMatch(p => p.GetDocumentation(subject));

}

/*********

** Private methods

*********/

/// <summary>Get the first valid result from the collection of XML documentation providers.</summary>

/// <param name="expr">The method to invoke.</param>

private string GetFirstMatch(Func<XmlDocumentationProvider, string> expr)

{

return this.Providers

.Select(expr)

.FirstOrDefault(p => !String.IsNullOrWhiteSpace(p));

}

}

修改HelpPageConfig.cs文件中的调用:

 
  • 错误:【A model description could not be created. Duplicate model name '{0}' was found for types '{1}' and '{2}'. Use the [ModelName] attribute to change the model name for at least one of the types so that it has a unique name.】处理
修改ModelNameHelper.cs文件
  • 生成后的API文档,Description中的No documentation available.是因为API在编写的时候没有添加三行注释造成的,编写代码的时候规范必不可少
  • 过滤不需要生成文档的控制器,需要在控制器上添加过滤标签[ApiExplorerSettings(IgnoreApi = true)]
 
自此生成第三方API文档搭建完成,感谢项目组内小何对页面也进行了美化,效果如下:
 
 

ASP.NET API Helper Page 创建并生成相关帮助文档的更多相关文章

  1. elasticsearch _create api创建一个不存在的文档

    https://www.elastic.co/guide/cn/elasticsearch/guide/current/create-doc.html当我们索引一个文档, 怎么确认我们正在创建一个完全 ...

  2. 使用FastReport报表工具生成报表PDF文档

    在我们开发某个系统的时候,客户总会提出一些特定的报表需求,固定的报表格式符合他们的业务处理需要,也贴合他们的工作场景,因此我们尽可能做出符合他们实际需要的报表,这样我们的系统会得到更好的认同感.本篇随 ...

  3. 基于springboot的freemarker创建指定格式的word文档

    在web或其他应用中,经常我们需要导出或者预览word文档,比较实际的例子有招聘网站上预览或者导出个人简历,使用POI导出excel会非常的方便,但是如果想导出word,由于其格式控制非常复杂,故而使 ...

  4. 使用docx4j编程式地创建复杂的Word(.docx)文档

    原文链接:Create complex Word (.docx) documents programatically with docx4j 原文作者:jos.dirksen 发表日期:2012年2月 ...

  5. 创建 VuePress + GithubPages + TravisCI 在线文档

    目录 最终效果 思路 总体 过程 用到的东西 相关 创建Github仓库 创建Github仓库 SSH密钥链接Github 生成SSH密钥 Github添加SSH密钥 测试SSH密钥 配置VuePre ...

  6. 使用 Sandcastle 生成代码帮助文档

    使用 Sandcastle可以生成MSDN风格的帮助文档,生成的帮助文档既可以是chm文档,也可以是MS Help 2.x帮助文档. 1 下载并安装Sandcastle Sandcastle下载地址为 ...

  7. Swagger+Spring mvc生成Restful接口文档

    简介 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...

  8. 使用FastReport报表工具生成标签打印文档

    在我们实际开发报表的时候,我们需要按一定的业务规则组织好报表的模板设计,让报表尽可能的贴近实际的需求,在之前的随笔中<使用FastReport报表工具生成报表PDF文档>介绍了FastRe ...

  9. 生成iOS-Xcode技术文档

    从源码中抽取注释生成文档的专用工具: [doxygen](http://www.stack.nl/~dimitri/doxygen/index.html):适于生成html文档与pdf文档. 支持的语 ...

随机推荐

  1. Reinforcement Learning: An Introduction读书笔记(2)--多臂机

     > 目  录 <  k-armed bandit problem Incremental Implementation Tracking a Nonstationary Problem ...

  2. Java 控制类的引用类型,合理使用内存

    Java提供了 java.lang.ref包,该包下的类均与垃圾回收机制相关 先介绍Java对象的集中引用类型 1.强引用 强引用是最常见的,创建对象就是强引用,如 String a = new St ...

  3. for循环与forEach性能思考

    今日看到一句话: 基于循环的迭代比基于函数的迭代法快8倍,因此有了该篇验证博客. 验证代码如图: 验证结果:在数量比较少的时候,无明显差别,当数量级达到10的4次方时候,for循环的效率优势明显:如图 ...

  4. hihoCoder编程练习赛52

    题目1 : 字符串排序 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 一般我们在对字符串排序时,都会按照字典序排序.当字符串只包含小写字母时,相当于按字母表" ...

  5. js 随机点名

    1.对象构造函数 设置节点与人名 constructor({ printElement, startElement, stopElement , person }) { this.list = per ...

  6. K8S Calico

    NetworkPolicy是kubernetes对pod的隔离手段,是宿主机上的一系列iptables规则. Egress 表示出站流量,就是pod作为客户端访问外部服务,pod地址作为源地址.策略可 ...

  7. Django的URL路由系统

    一. URL配置 URL配置就像Django所支撑网站的目录.它的本质是URL与要为该URL调用的视图之间的映射表.你就是以这种方式告诉Django,对于哪个URL调用的这段代码. 基本格式 from ...

  8. 【机器学习】Google机器学习工程的43条最佳实践

    https://blog.csdn.net/ChenVast/article/details/81449509 本文档旨在帮助那些掌握机器学习基础知识的人从Google机器学习的最佳实践中获益.它提供 ...

  9. 如何用ABP框架快速完成项目(9) - 用ABP一个人快速完成项目(5) - 不要执着于设计模式和DDD理论,避免原教旨主义

    为什么要写这节文章呢?   首先主动看我这系列文章和参加活动课程的同学, 肯定是积极好学的. 所以很大概率是学过设计模式和DDD理论的. 很大概率不是走一点都不懂设计模式和DDD理论这个极端, 而是走 ...

  10. Android为TV端助力 自定义通知栏

    package com.example.mvp; import cn.ljuns.temperature.view.TemperatureView;import presenter.ILoginPre ...