diff --git a/NuGet.Config b/NuGet.Config
index 7b24038..0707da0 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -6,5 +6,6 @@
+
diff --git a/src/MyHealth.MobileApp/MyHealth.MobileApp.csproj b/src/MyHealth.MobileApp/MyHealth.MobileApp.csproj
index efb3b82..f273d78 100644
--- a/src/MyHealth.MobileApp/MyHealth.MobileApp.csproj
+++ b/src/MyHealth.MobileApp/MyHealth.MobileApp.csproj
@@ -163,6 +163,10 @@
..\..\packages\RazorEngine.3.7.0\lib\net45\RazorEngine.dll
True
+
+ ..\..\packages\Swashbuckle.Core.5.2.2\lib\net40\Swashbuckle.Core.dll
+ True
+
..\..\packages\System.IdentityModel.Tokens.Jwt.4.0.2.205111437\lib\net45\System.IdentityModel.Tokens.Jwt.dll
True
diff --git a/src/MyHealth.MobileApp/Startup.cs b/src/MyHealth.MobileApp/Startup.cs
index fbdb7ee..51368f9 100644
--- a/src/MyHealth.MobileApp/Startup.cs
+++ b/src/MyHealth.MobileApp/Startup.cs
@@ -3,8 +3,19 @@
using Owin;
using System.Web.Http;
-[assembly: OwinStartup(typeof(MyHealth.MobileApp.Startup))]
+//HTTP Description needed for Swagger
+using System.Web.Http.Description;
+
+//Needed for Swashbuckle Filters
+using System.Globalization;
+using System.Linq;
+
+//Has the HttpConfiguration extension methods with .EnableSwagger and .EnableSwaggerUi
+using Swashbuckle.Application;
+using Swashbuckle.Swagger;
+using Newtonsoft.Json.Serialization;
+[assembly: OwinStartup(typeof(MyHealth.MobileApp.Startup))]
namespace MyHealth.MobileApp
{
public class Startup
@@ -13,6 +24,26 @@ public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
+ config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
+
+ //See info about OWIN in https://github.com/domaindrivendev/Swashbuckle
+ //Manually enable the Swagger docs and, optionally, the swagger-ui by invoking the
+ //extension methods (in namespace Swashbuckle.Application) on an instance of HttpConfiguration in Startup.cs
+ config
+ .EnableSwagger(c =>
+ {
+ c.SingleApiVersion("v1", "MyHealth.MobileApp");
+ // Set filter to eliminate duplicate operation ids from being generated
+ // when there are multiple operations with the same verb in the API.
+ c.OperationFilter();
+
+ // Set another filter to eliminate duplciation operation ids from being generated
+ // when there are multiple Web API routes, like /tables and /api
+ c.OperationFilter();
+ }
+ )
+ .EnableSwaggerUi();
+
new MobileAppConfiguration()
.UseDefaultConfiguration()
.ApplyTo(config);
@@ -20,4 +51,43 @@ public void Configuration(IAppBuilder app)
app.UseWebApi(config);
}
}
+
+ internal class IncludeParameterNamesInOperationIdFilter : IOperationFilter
+ {
+ public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
+ {
+ if (operation.parameters != null)
+ {
+ // Select the capitalized parameter names
+ var parameters = operation.parameters.Select(
+ p => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(p.name));
+
+ // Set the operation id to match the format "OperationByParam1AndParam2"
+ operation.operationId = string.Format(
+ "{0}By{1}",
+ operation.operationId,
+ string.Join("And", parameters));
+ }
+ }
+ }
+
+ internal class IncludeRouteNameInOperationIdFilter : IOperationFilter
+ {
+ public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
+ {
+
+ //Find current Route name
+ string routeTemplate = apiDescription.Route.RouteTemplate;
+ string BaseRouteName = routeTemplate.Substring(0, routeTemplate.IndexOf('/'));
+ string postfix = "_" + BaseRouteName + "_Route";
+
+ // Set the operation id to match the format "OperationThroughRouteName"
+ operation.operationId = string.Format(
+ "{0}_Through{1}",
+ operation.operationId,
+ postfix);
+
+ }
+ }
+
}
diff --git a/src/MyHealth.MobileApp/packages.config b/src/MyHealth.MobileApp/packages.config
index b076596..ecdf1e0 100644
--- a/src/MyHealth.MobileApp/packages.config
+++ b/src/MyHealth.MobileApp/packages.config
@@ -37,6 +37,7 @@
+
\ No newline at end of file