Created
April 24, 2016 02:47
-
-
Save seangwright/b37d3512f0eb3bf366c8f4ad5c906308 to your computer and use it in GitHub Desktop.
SwashbuckleConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Swashbuckle.Application; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Http; | |
namespace WiredViews.WIR03.Web.Api.Configuration | |
{ | |
/// <summary> | |
/// Configures swashbuckle (swagger docs / UI) for web api documentation. | |
/// </summary> | |
public static class SwashbuckleConfiguration | |
{ | |
private const string _generatedXMLPath = "~/Bin/WiredViews.WIR03.Web.Api.XML"; | |
private const string _APIVersion = "v1_0_0"; | |
private const string _APIName = "WiredViews.WIR03.Web.Api"; | |
/// <summary> | |
/// Initializes swagger on the Http Server | |
/// </summary> | |
/// <param name="config"></param> | |
public static void Configure(HttpConfiguration config) | |
{ | |
#if DEBUG | |
config.EnableSwagger(c => ConfigureSwagger(c)) | |
.EnableSwaggerUi(c => ConfigureSwaggerUI(c)); | |
#endif | |
} | |
/// <summary> | |
/// Configures Swashbuckle (swagger) and how it integrates into the Http Server | |
/// </summary> | |
/// <param name="config"></param> | |
private static void ConfigureSwagger(SwaggerDocsConfig config) | |
{ | |
config.SingleApiVersion(_APIVersion, _APIName); | |
config.IncludeXmlComments(System.Web.Hosting.HostingEnvironment.MapPath(_generatedXMLPath)); | |
} | |
/// <summary> | |
/// Configures the UI elements / front end functionality of swagger | |
/// </summary> | |
/// <param name="config"></param> | |
private static void ConfigureSwaggerUI(SwaggerUiConfig config) | |
{ | |
config.DocExpansion(DocExpansion.None); | |
config.DisableValidator(); | |
config.EnableDiscoveryUrlSelector(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment