Skip to content

Arch/ApiHelp

Repository files navigation

Microsoft.AspNetCore.ApiHelp

A toolchain for ASP.NET Core to automatically generating API documentation.

Features

  • Read XML comments at run time (so the deployment need to include yourAssembly.xml file).

  • Get Enum raw constant value and XML comments.

    public enum Gender {
        /// <summary>
        /// 未知.
        /// </summary>
        Unknown,
        /// <summary>
        /// 男性.
        /// </summary>
        Male,
        /// <summary>
        /// 女性.
        /// </summary>
        Female,
    }
    {
      "0": "未知", 
      "1": "男性", 
      "2": "女性"
    }
  • Generate API documentation for ASP.NET Core.

  • JsonOutputFormatter use camel case or not determined by the API (Because it's API).

  • More...

Running from demo

To integrate ApiHelp to your project, download this repo and see Host source code, running and open link api/help/ui in your browser to view the result.

Packages

How to use

Install package.

PM> Install-Package Microsoft.AspNetCore.ApiHelp

Configure Startup.cs.

public void ConfigureServices(IServiceCollection services) {
    services.AddMvc()
        .AddApiHelp(options => {
            options.IgnoreObsoleteApi = true;
            options.GenerateStrategy = DocumentGenerateStrategy.Eager;
            options.IncludeSupportedMediaType = false;
        });
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));

    app.UseApiHelp(new ApiHelpUIOptions {
        Title = "API toolchain for ASP.NET Core",
        UI = ApiHelpUI.Swagger,
    });

    app.UseMvc();
}