├── WebApiStarter ├── Documents │ └── HowToFindTemplate.png ├── WebApiStarter.Template │ ├── __TemplateIcon.ico │ ├── WebApiStarter.ruleset │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Startup.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── App_Start │ │ ├── ApiExceptionHandler.cs │ │ ├── ApiExceptionLogger.cs │ │ └── ApiConfig.cs │ ├── packages.config │ ├── MyTemplate.vstemplate │ ├── WebApiStarter.Template.csproj │ ├── Web.config │ ├── Controllers │ │ └── FooController.cs │ └── WebApiStarter.csproj ├── WebApiStarter.Template.Vsix │ ├── __TemplateIcon.ico │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── source.extension.vsixmanifest │ └── WebApiStarter.Template.Vsix.csproj ├── WebApiStarter │ ├── WebApiStarter.ruleset │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Startup.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── App_Start │ │ ├── ApiExceptionHandler.cs │ │ ├── ApiExceptionLogger.cs │ │ └── ApiConfig.cs │ ├── packages.config │ ├── Web.config │ ├── Controllers │ │ └── FooController.cs │ └── WebApiStarter.csproj └── WebApiStarter.sln ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── release-notes.md ├── README.md ├── .gitattributes └── .gitignore /WebApiStarter/Documents/HowToFindTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MirzaMerdovic/WebApiStartTemplate/HEAD/WebApiStarter/Documents/HowToFindTemplate.png -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/__TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MirzaMerdovic/WebApiStartTemplate/HEAD/WebApiStarter/WebApiStarter.Template/__TemplateIcon.ico -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template.Vsix/__TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MirzaMerdovic/WebApiStartTemplate/HEAD/WebApiStarter/WebApiStarter.Template.Vsix/__TemplateIcon.ico -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/WebApiStarter.ruleset: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/WebApiStarter.ruleset: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("$safeprojectname$.Template")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("")] 9 | [assembly: AssemblyProduct("$safeprojectname$.Template")] 10 | [assembly: AssemblyCopyright("Copyright © 2016")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | [assembly: CLSCompliant(true)] 16 | 17 | // The following GUID is for the ID of the typelib if this project is exposed to COM 18 | [assembly: Guid("$guid1$")] 19 | 20 | [assembly: AssemblyVersion("1.3.0.0")] 21 | [assembly: AssemblyFileVersion("1.3.0.0")] -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("WebApiStarter.Template")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("")] 9 | [assembly: AssemblyProduct("WebApiStarter.Template")] 10 | [assembly: AssemblyCopyright("Copyright © 2016")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | [assembly: CLSCompliant(true)] 16 | 17 | // The following GUID is for the ID of the typelib if this project is exposed to COM 18 | [assembly: Guid("24df2024-41a1-49c9-b2d2-96f0819df41c")] 19 | 20 | [assembly: AssemblyVersion("1.3.0.0")] 21 | [assembly: AssemblyFileVersion("1.3.0.0")] -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /release-notes.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Development 4 | 5 | ## v1.1.1 - May 27th, 2018 6 | - Updated vsixmanifest information. 7 | - Added release-notes.md 8 | - Updated README.md 9 | - Added response type information for Swagger UI. 10 | 11 | ## v1.1.2 - May 31st, 2018 12 | - Added log for VSIX template. 13 | 14 | ## v1.2.0 - September 15th, 2018 15 | - Upgraded following packages: 16 | - Autofac.WebApi2 4.2.0 17 | - Microsoft.CodeDom.Providers.DotNetCompilerPlatform - 2.0.1 18 | - Microsoft.Net.Compilers 2.9.0 19 | - Swashbuckle 5.6.0 20 | - Swashbuckle.Core 5.6.0 21 | - Reinstalled nuget packages so that all target .Net 4.7.1 22 | - Implemented request/response predefined examples for Swagger using Swashbuckle.Examples 23 | - Setup XML documentation usage for Swagger. 24 | 25 | ## v1.3.0 - November 11th, 2018 26 | - Fixed the instal path for the template so not it's nested under: Web -> Previous Versions 27 | - Fixed the XML documentation path resolving 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![logo](WebApiStarter/WebApiStarter.Template.Vsix/__TemplateIcon.ico) 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/308y0cq7d25um8nq/branch/master?svg=true)](https://ci.appveyor.com/project/MirzaMerdovic/webapistarttemplate/branch/master) [![CodeFactor](https://www.codefactor.io/repository/github/mirzamerdovic/webapistarttemplate/badge)](https://www.codefactor.io/repository/github/mirzamerdovic/webapistarttemplate) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FMirzaMerdovic%2FWebApiStartTemplate.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FMirzaMerdovic%2FWebApiStartTemplate?ref=badge_shield) 4 | 5 | ## Web API Visual Studio Template. 6 | 7 | VS template for Web API with OWIN projects. 8 | Please refer to [Wiki](https://github.com/MirzaMerdovic/WebApiStartTemplate/wiki) page for more information. 9 | 10 | 11 | ## Suggestions/Issues 12 | Please submit an issue if you found out any kind of problems, or have an idea for an enchanment. 13 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/Startup.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | using System.Web.Http; 3 | using Microsoft.Owin; 4 | using Owin; 5 | using WebApiStarter.App_Start; 6 | 7 | [assembly: OwinStartup(typeof(WebApiStarter.Template.Startup))] 8 | namespace WebApiStarter.Template 9 | { 10 | /// 11 | /// Represents the entry point into an application. 12 | /// 13 | public class Startup 14 | { 15 | /// 16 | /// Specifies how the ASP.NET application will respond to individual HTTP request. 17 | /// 18 | /// Instance of . 19 | public void Configuration(IAppBuilder app) 20 | { 21 | new ApiConfig(app) 22 | .ConfigureCorsMiddleware(ConfigurationManager.AppSettings["cors"]) 23 | .ConfigureAufacMiddleware() 24 | .ConfigureFormatters() 25 | .ConfigureRoutes() 26 | .ConfigureExceptionHandling() 27 | .ConfigureSwagger() 28 | .UseWebApi(); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/Startup.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | using System.Web.Http; 3 | using Microsoft.Owin; 4 | using Owin; 5 | using $safeprojectname$.App_Start; 6 | 7 | [assembly: OwinStartup(typeof($safeprojectname$.Template.Startup))] 8 | namespace $safeprojectname$.Template 9 | { 10 | /// 11 | /// Represents the entry point into an application. 12 | /// 13 | public class Startup 14 | { 15 | /// 16 | /// Specifies how the ASP.NET application will respond to individual HTTP request. 17 | /// 18 | /// Instance of . 19 | public void Configuration(IAppBuilder app) 20 | { 21 | new ApiConfig(app) 22 | .ConfigureCorsMiddleware(ConfigurationManager.AppSettings["cors"]) 23 | .ConfigureAufacMiddleware() 24 | .ConfigureFormatters() 25 | .ConfigureRoutes() 26 | .ConfigureExceptionHandling() 27 | .ConfigureSwagger() 28 | .UseWebApi(); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template.Vsix/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("WebApiStarter.Template.Vsix")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WebApiStarter.Template.Vsix")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/App_Start/ApiExceptionHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Web.Http.ExceptionHandling; 6 | using System.Web.Http.Results; 7 | 8 | namespace WebApiStarter.App_Start 9 | { 10 | /// 11 | /// Represents implementation of . 12 | /// 13 | public class ApiExceptionHandler : ExceptionHandler 14 | { 15 | /// 16 | /// Overrides method with code that sets friendly error message to be shown in browser. 17 | /// 18 | /// Instance of . 19 | public override void Handle(ExceptionHandlerContext context) 20 | { 21 | context = context ?? throw new ArgumentNullException(nameof(context)); 22 | 23 | var correlationId = context.Request.Headers.GetValues("CorrelationId").First(); 24 | 25 | var metadata = new 26 | { 27 | Message = "An unexpected error occurred! Please use the Error ID to contact support", 28 | TimeStamp = DateTime.UtcNow, 29 | RequestUri = context.Request.RequestUri, 30 | ErrorId = correlationId 31 | }; 32 | 33 | var response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, metadata); 34 | response.Headers.Add("CorrelationId", correlationId); 35 | 36 | context.Result = new ResponseMessageResult(response); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/App_Start/ApiExceptionHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Web.Http.ExceptionHandling; 6 | using System.Web.Http.Results; 7 | 8 | namespace $safeprojectname$.App_Start 9 | { 10 | /// 11 | /// Represents implementation of . 12 | /// 13 | public class ApiExceptionHandler : ExceptionHandler 14 | { 15 | /// 16 | /// Overrides method with code that sets friendly error message to be shown in browser. 17 | /// 18 | /// Instance of . 19 | public override void Handle(ExceptionHandlerContext context) 20 | { 21 | context = context ?? throw new ArgumentNullException(nameof(context)); 22 | 23 | var correlationId = context.Request.Headers.GetValues("CorrelationId").First(); 24 | 25 | var metadata = new 26 | { 27 | Message = "An unexpected error occurred! Please use the Error ID to contact support", 28 | TimeStamp = DateTime.UtcNow, 29 | RequestUri = context.Request.RequestUri, 30 | ErrorId = correlationId 31 | }; 32 | 33 | var response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, metadata); 34 | response.Headers.Add("CorrelationId", correlationId); 35 | 36 | context.Result = new ResponseMessageResult(response); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template.Vsix/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WebApi Starter Template 6 | Visual Studio template that provides main functionality that many of us implement while creating new Web API using OWIN. 7 | https://github.com/MirzaMerdovic/WebApiStartTemplate 8 | https://github.com/MirzaMerdovic/WebApiStartTemplate/wiki 9 | https://github.com/MirzaMerdovic/WebApiStartTemplate/blob/master/release-notes.md 10 | __TemplateIcon.ico 11 | WebAPI, OWIN, Autofac, Swagger 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/MyTemplate.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | WebApiStarter Template 4 | Visual Studio template that provides main functionality that many of us implement while creating new Web API using OWIN. 5 | CSharp 6 | 7 | 8 | 1000 9 | true 10 | WebApiStarter 11 | true 12 | Enabled 13 | true 14 | __TemplateIcon.ico 15 | 16 | 17 | 18 | 19 | 20 | ApiConfig.cs 21 | ApiExceptionHandler.cs 22 | ApiExceptionLogger.cs 23 | 24 | 25 | FooController.cs 26 | 27 | packages.config 28 | 29 | AssemblyInfo.cs 30 | 31 | Startup.cs 32 | Web.config 33 | Web.Debug.config 34 | Web.Release.config 35 | WebApiStarter.ruleset 36 | 37 | 38 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.14 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiStarter", "WebApiStarter\WebApiStarter.csproj", "{24DF2024-41A1-49C9-B2D2-96F0819DF41C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiStarter.Template.Vsix", "WebApiStarter.Template.Vsix\WebApiStarter.Template.Vsix.csproj", "{0BDA7CE6-812F-4302-A218-8F046B4F08DF}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E5142345-C036-4992-9EE6-53C6021C93BC}" 11 | ProjectSection(SolutionItems) = preProject 12 | ..\README.md = ..\README.md 13 | ..\release-notes.md = ..\release-notes.md 14 | EndProjectSection 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documents", "Documents", "{EA1966CA-AEDF-4CB5-936C-60F997ECA70B}" 17 | ProjectSection(SolutionItems) = preProject 18 | Documents\HowToFindTemplate.png = Documents\HowToFindTemplate.png 19 | EndProjectSection 20 | EndProject 21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiStarter.Template", "WebApiStarter.Template\WebApiStarter.Template.csproj", "{0364047D-1E5C-4514-BFD4-360749EC32AA}" 22 | EndProject 23 | Global 24 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 25 | Debug|Any CPU = Debug|Any CPU 26 | Release|Any CPU = Release|Any CPU 27 | EndGlobalSection 28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 29 | {24DF2024-41A1-49C9-B2D2-96F0819DF41C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {24DF2024-41A1-49C9-B2D2-96F0819DF41C}.Debug|Any CPU.Build.0 = Debug|Any CPU 31 | {24DF2024-41A1-49C9-B2D2-96F0819DF41C}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {24DF2024-41A1-49C9-B2D2-96F0819DF41C}.Release|Any CPU.Build.0 = Release|Any CPU 33 | {0BDA7CE6-812F-4302-A218-8F046B4F08DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {0BDA7CE6-812F-4302-A218-8F046B4F08DF}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {0BDA7CE6-812F-4302-A218-8F046B4F08DF}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {0BDA7CE6-812F-4302-A218-8F046B4F08DF}.Release|Any CPU.Build.0 = Release|Any CPU 37 | {0364047D-1E5C-4514-BFD4-360749EC32AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 38 | {0364047D-1E5C-4514-BFD4-360749EC32AA}.Debug|Any CPU.Build.0 = Debug|Any CPU 39 | {0364047D-1E5C-4514-BFD4-360749EC32AA}.Release|Any CPU.ActiveCfg = Release|Any CPU 40 | {0364047D-1E5C-4514-BFD4-360749EC32AA}.Release|Any CPU.Build.0 = Release|Any CPU 41 | EndGlobalSection 42 | GlobalSection(SolutionProperties) = preSolution 43 | HideSolutionNode = FALSE 44 | EndGlobalSection 45 | GlobalSection(ExtensibilityGlobals) = postSolution 46 | SolutionGuid = {11B3EC78-DEB6-483D-89D7-C6F305C7D311} 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/App_Start/ApiExceptionLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net.Http; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using System.Web.Http.ExceptionHandling; 7 | 8 | namespace WebApiStarter.App_Start 9 | { 10 | /// 11 | /// Represents implementation of . 12 | /// 13 | public class ApiExceptionLogger : ExceptionLogger 14 | { 15 | private const string CorrelationIdHeaderName = "CorrelationId"; 16 | 17 | /// 18 | /// Overrides method with custom logger implementations. 19 | /// 20 | /// Instance of . 21 | /// Cancellation token. 22 | /// 23 | public override async Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken) 24 | { 25 | GetOrSetCorrelationId(context.Request); 26 | var request = await CreateRequest(context.Request); 27 | // Use a logger of your choice to log a request. 28 | 29 | void GetOrSetCorrelationId(HttpRequestMessage message) 30 | { 31 | var correlationId = Guid.NewGuid().ToString(); 32 | 33 | if (!message.Headers.TryGetValues(CorrelationIdHeaderName, out var correlations)) 34 | { 35 | message.Headers.Add(CorrelationIdHeaderName, correlationId); 36 | } 37 | else if (Guid.TryParse(correlations.First(), out var id)) 38 | { 39 | message.Headers.Add(CorrelationIdHeaderName, id.ToString()); 40 | } 41 | else 42 | { 43 | message.Headers.Add(CorrelationIdHeaderName, correlationId); 44 | } 45 | } 46 | } 47 | 48 | private static async Task CreateRequest(HttpRequestMessage message) 49 | { 50 | var request = new 51 | { 52 | CorrelationId = message.Headers.GetValues(CorrelationIdHeaderName).First(), 53 | Body = await ReadContent(message.Content).ConfigureAwait(false), 54 | Method = message.Method.Method, 55 | Scheme = message.RequestUri.Scheme, 56 | Host = message.RequestUri.Host, 57 | Protocol = string.Empty, 58 | PathBase = message.RequestUri.PathAndQuery, 59 | Path = message.RequestUri.AbsoluteUri, 60 | QueryString = message.RequestUri.Query 61 | }; 62 | 63 | return request; 64 | 65 | async Task ReadContent(HttpContent content) 66 | { 67 | using (content) 68 | { 69 | string body; 70 | try 71 | { 72 | body = await content.ReadAsStringAsync().ConfigureAwait(false); 73 | } 74 | catch (Exception e) 75 | { 76 | body = $"Failed to read body. Error: {e}"; 77 | } 78 | 79 | return body; 80 | } 81 | } 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/App_Start/ApiExceptionLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net.Http; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using System.Web.Http.ExceptionHandling; 7 | 8 | namespace $safeprojectname$.App_Start 9 | { 10 | /// 11 | /// Represents implementation of . 12 | /// 13 | public class ApiExceptionLogger : ExceptionLogger 14 | { 15 | private const string CorrelationIdHeaderName = "CorrelationId"; 16 | 17 | /// 18 | /// Overrides method with custom logger implementations. 19 | /// 20 | /// Instance of . 21 | /// Cancellation token. 22 | /// 23 | public override async Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken) 24 | { 25 | GetOrSetCorrelationId(context.Request); 26 | var request = await CreateRequest(context.Request); 27 | // Use a logger of your choice to log a request. 28 | 29 | void GetOrSetCorrelationId(HttpRequestMessage message) 30 | { 31 | var correlationId = Guid.NewGuid().ToString(); 32 | 33 | if (!message.Headers.TryGetValues(CorrelationIdHeaderName, out var correlations)) 34 | { 35 | message.Headers.Add(CorrelationIdHeaderName, correlationId); 36 | } 37 | else if (Guid.TryParse(correlations.First(), out var id)) 38 | { 39 | message.Headers.Add(CorrelationIdHeaderName, id.ToString()); 40 | } 41 | else 42 | { 43 | message.Headers.Add(CorrelationIdHeaderName, correlationId); 44 | } 45 | } 46 | } 47 | 48 | private static async Task CreateRequest(HttpRequestMessage message) 49 | { 50 | var request = new 51 | { 52 | CorrelationId = message.Headers.GetValues(CorrelationIdHeaderName).First(), 53 | Body = await ReadContent(message.Content).ConfigureAwait(false), 54 | Method = message.Method.Method, 55 | Scheme = message.RequestUri.Scheme, 56 | Host = message.RequestUri.Host, 57 | Protocol = string.Empty, 58 | PathBase = message.RequestUri.PathAndQuery, 59 | Path = message.RequestUri.AbsoluteUri, 60 | QueryString = message.RequestUri.Query 61 | }; 62 | 63 | return request; 64 | 65 | async Task ReadContent(HttpContent content) 66 | { 67 | using (content) 68 | { 69 | string body; 70 | try 71 | { 72 | body = await content.ReadAsStringAsync().ConfigureAwait(false); 73 | } 74 | catch (Exception e) 75 | { 76 | body = $"Failed to read body. Error: {e}"; 77 | } 78 | 79 | return body; 80 | } 81 | } 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template.Vsix/WebApiStarter.Template.Vsix.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 10 | Debug 11 | AnyCPU 12 | 2.0 13 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | {0BDA7CE6-812F-4302-A218-8F046B4F08DF} 15 | Library 16 | Properties 17 | WebApiStarter.Template.Vsix 18 | WebApiStarter.Template.Vsix 19 | v4.7.2 20 | false 21 | false 22 | false 23 | false 24 | false 25 | false 26 | Program 27 | $(DevEnvDir)devenv.exe 28 | /rootsuffix Exp 29 | 30 | 31 | true 32 | full 33 | false 34 | bin\Debug\ 35 | DEBUG;TRACE 36 | prompt 37 | 4 38 | ..\WebApiStarter.Template\WebApiStarter.ruleset 39 | 40 | 41 | pdbonly 42 | true 43 | bin\Release\ 44 | TRACE 45 | prompt 46 | 4 47 | False 48 | ..\WebApiStarter.Template\WebApiStarter.ruleset 49 | 50 | 51 | 52 | 53 | 54 | 55 | Designer 56 | 57 | 58 | 59 | 60 | {0364047D-1E5C-4514-BFD4-360749EC32AA} 61 | WebApiStarter.Template 62 | ProjectTemplates 63 | false 64 | TemplateProjectOutputGroup%3b 65 | 66 | 67 | 68 | 69 | Always 70 | true 71 | 72 | 73 | 74 | 75 | 82 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/WebApiStarter.Template.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | Debug 10 | AnyCPU 11 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 12 | {0364047D-1E5C-4514-BFD4-360749EC32AA} 13 | Library 14 | Properties 15 | WebApiStarter.Template 16 | WebApiStarter.Template 17 | v4.7.2 18 | 512 19 | false 20 | false 21 | false 22 | false 23 | false 24 | false 25 | false 26 | false 27 | false 28 | false 29 | 30 | 31 | true 32 | full 33 | false 34 | bin\Debug\ 35 | DEBUG;TRACE 36 | prompt 37 | 4 38 | 39 | 40 | pdbonly 41 | true 42 | bin\Release\ 43 | TRACE 44 | prompt 45 | 4 46 | 47 | 48 | 49 | False 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Web\Previous Versions 69 | Designer 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 89 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Windows Store app package directory 170 | AppPackages/ 171 | BundleArtifacts/ 172 | 173 | # Visual Studio cache files 174 | # files ending in .cache can be ignored 175 | *.[Cc]ache 176 | # but keep track of directories ending in .cache 177 | !*.[Cc]ache/ 178 | 179 | # Others 180 | ClientBin/ 181 | [Ss]tyle[Cc]op.* 182 | ~$* 183 | *~ 184 | *.dbmdl 185 | *.dbproj.schemaview 186 | *.pfx 187 | *.publishsettings 188 | node_modules/ 189 | orleans.codegen.cs 190 | 191 | # RIA/Silverlight projects 192 | Generated_Code/ 193 | 194 | # Backup & report files from converting an old project file 195 | # to a newer Visual Studio version. Backup files are not needed, 196 | # because we have git ;-) 197 | _UpgradeReport_Files/ 198 | Backup*/ 199 | UpgradeLog*.XML 200 | UpgradeLog*.htm 201 | 202 | # SQL Server files 203 | *.mdf 204 | *.ldf 205 | 206 | # Business Intelligence projects 207 | *.rdl.data 208 | *.bim.layout 209 | *.bim_*.settings 210 | 211 | # Microsoft Fakes 212 | FakesAssemblies/ 213 | 214 | # GhostDoc plugin setting file 215 | *.GhostDoc.xml 216 | 217 | # Node.js Tools for Visual Studio 218 | .ntvs_analysis.dat 219 | 220 | # Visual Studio 6 build log 221 | *.plg 222 | 223 | # Visual Studio 6 workspace options file 224 | *.opt 225 | 226 | # Visual Studio LightSwitch build output 227 | **/*.HTMLClient/GeneratedArtifacts 228 | **/*.DesktopClient/GeneratedArtifacts 229 | **/*.DesktopClient/ModelManifest.xml 230 | **/*.Server/GeneratedArtifacts 231 | **/*.Server/ModelManifest.xml 232 | _Pvt_Extensions 233 | 234 | # LightSwitch generated files 235 | GeneratedArtifacts/ 236 | ModelManifest.xml 237 | 238 | # Paket dependency manager 239 | .paket/paket.exe 240 | 241 | # FAKE - F# Make 242 | .fake/ 243 | /WebApiStarter/WebApiStarter.VsixTemplate/packages.config 244 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/Controllers/FooController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Threading.Tasks; 5 | using System.Web.Http; 6 | using System.Web.Http.Description; 7 | using Swashbuckle.Examples; 8 | 9 | namespace WebApiStarter.Controllers 10 | { 11 | /// 12 | /// Represents test controller that should be removed. 13 | /// 14 | [RoutePrefix("api/foo")] 15 | 16 | public class FooController : ApiController 17 | { 18 | private readonly IFooService _service; 19 | 20 | public FooController(IFooService service) 21 | { 22 | _service = service; 23 | } 24 | 25 | /// 26 | /// Tries to create a new foo. 27 | /// 28 | /// Instance of . 29 | /// Returns 201. 30 | [HttpPost, Route(""), ResponseType(typeof(Foo))] 31 | [SwaggerRequestExample(typeof(Foo), typeof(FooRequestExample))] 32 | [SwaggerResponseExample(HttpStatusCode.Created, typeof(FooResponseExample))] 33 | public async Task Post(Foo foo) 34 | { 35 | var newFoo = await _service.Add(foo).ConfigureAwait(false); 36 | 37 | return CreatedAtRoute("GetById", new { newFoo.Id }, newFoo); 38 | } 39 | 40 | /// 41 | /// Tries to retrieve all foo objects. 42 | /// 43 | /// 200 with collection of foo objects. 44 | [HttpGet, Route(""), ResponseType(typeof(IEnumerable))] 45 | [SwaggerResponseExample(HttpStatusCode.OK, typeof(FooListResponseExample))] 46 | public async Task Get() 47 | { 48 | var foos = await _service.Get().ConfigureAwait(false); 49 | 50 | return Ok(foos); 51 | } 52 | 53 | /// 54 | /// Tries to retrieve specified foo. 55 | /// 56 | /// Unique identifier. 57 | /// 200, or 404 if the foo doesn't exist. 58 | [HttpGet, Route("{id:int}", Name = "GetById"), ResponseType(typeof(Foo))] 59 | [SwaggerResponseExample(HttpStatusCode.OK, typeof(FooResponseExample))] 60 | public async Task Get(int id) 61 | { 62 | var foo = await _service.Get(id).ConfigureAwait(false); 63 | 64 | if (foo == null) 65 | return NotFound(); 66 | 67 | return Ok(foo); 68 | } 69 | 70 | /// 71 | /// Tries to update the foo object. 72 | /// 73 | /// Instance of that contains modified values. 74 | /// 200. 75 | [HttpPatch, Route("")] 76 | [SwaggerRequestExample(typeof(Foo), typeof(FooRequestExample))] 77 | public async Task Patch(Foo foo) 78 | { 79 | await _service.Update(foo).ConfigureAwait(false); 80 | 81 | return Ok(); 82 | } 83 | 84 | /// 85 | /// Tries to delete the specified foo. 86 | /// 87 | /// Unique identifier. 88 | /// 200. 89 | [HttpDelete, Route("{id:int}")] 90 | public async Task Delete(int id) 91 | { 92 | // Delete should throw 404 if the resource doesn't exist, but it's skipped for brevity sake. 93 | await _service.Delete(id).ConfigureAwait(false); 94 | 95 | return Ok(); 96 | } 97 | } 98 | 99 | #region Services 100 | 101 | public interface IFooService 102 | { 103 | Task Add(Foo foo); 104 | 105 | Task Get(int id); 106 | 107 | Task> Get(); 108 | 109 | Task Update(Foo foo); 110 | 111 | Task Delete(int id); 112 | } 113 | 114 | public class FooService : IFooService 115 | { 116 | public Task Add(Foo foo) 117 | { 118 | return Task.FromResult(new Foo { Id = new Random().Next(), Value = foo.Value }); 119 | } 120 | 121 | public Task Get(int id) 122 | { 123 | return Task.FromResult(new Foo { Id = id, Value = "Foo" }); 124 | } 125 | 126 | public Task> Get() 127 | { 128 | return Task.FromResult>(new List 129 | { 130 | new Foo {Id = 1, Value = "Foo"}, 131 | new Foo {Id = 2, Value = "Boo"} 132 | }); 133 | } 134 | 135 | public Task Update(Foo foo) 136 | { 137 | return Task.CompletedTask; 138 | } 139 | 140 | public Task Delete(int id) 141 | { 142 | return Task.CompletedTask; 143 | } 144 | } 145 | 146 | #endregion 147 | 148 | #region Contracts 149 | 150 | public class Foo 151 | { 152 | /// 153 | /// Gets the creation date. 154 | /// 155 | public DateTime CreatedAt => DateTime.UtcNow; 156 | 157 | /// 158 | /// Gets or sets the unique identifier. 159 | /// 160 | public int Id { get; set; } 161 | 162 | /// 163 | /// Gets or sets the value. 164 | /// 165 | public object Value { get; set; } 166 | } 167 | 168 | #endregion 169 | 170 | #region Swagger Examples 171 | 172 | public class FooRequestExample : IExamplesProvider 173 | { 174 | public object GetExamples() 175 | { 176 | return new Foo 177 | { 178 | Id = new Random().Next(), 179 | Value = Guid.NewGuid().ToString().Remove(6) 180 | }; 181 | } 182 | } 183 | 184 | public class FooResponseExample : IExamplesProvider 185 | { 186 | public object GetExamples() 187 | { 188 | return new Foo 189 | { 190 | Id = new Random().Next(), 191 | Value = Guid.NewGuid().ToString().Remove(6) 192 | }; 193 | } 194 | } 195 | 196 | public class FooListResponseExample : IExamplesProvider 197 | { 198 | public object GetExamples() 199 | { 200 | return new List 201 | { 202 | new Foo {Id = new Random().Next(), Value = Guid.NewGuid().ToString().Remove(6)}, 203 | new Foo {Id = new Random().Next(), Value = Guid.NewGuid().ToString().Remove(6)} 204 | }; 205 | } 206 | } 207 | 208 | #endregion 209 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/Controllers/FooController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Threading.Tasks; 5 | using System.Web.Http; 6 | using System.Web.Http.Description; 7 | using Swashbuckle.Examples; 8 | 9 | namespace $safeprojectname$.Controllers 10 | { 11 | /// 12 | /// Represents test controller that should be removed. 13 | /// 14 | [RoutePrefix("api/foo")] 15 | 16 | public class FooController : ApiController 17 | { 18 | private readonly IFooService _service; 19 | 20 | public FooController(IFooService service) 21 | { 22 | _service = service; 23 | } 24 | 25 | /// 26 | /// Tries to create a new foo. 27 | /// 28 | /// Instance of . 29 | /// Returns 201. 30 | [HttpPost, Route(""), ResponseType(typeof(Foo))] 31 | [SwaggerRequestExample(typeof(Foo), typeof(FooRequestExample))] 32 | [SwaggerResponseExample(HttpStatusCode.Created, typeof(FooResponseExample))] 33 | public async Task Post(Foo foo) 34 | { 35 | var newFoo = await _service.Add(foo).ConfigureAwait(false); 36 | 37 | return CreatedAtRoute("GetById", new { newFoo.Id }, newFoo); 38 | } 39 | 40 | /// 41 | /// Tries to retrieve all foo objects. 42 | /// 43 | /// 200 with collection of foo objects. 44 | [HttpGet, Route(""), ResponseType(typeof(IEnumerable))] 45 | [SwaggerResponseExample(HttpStatusCode.OK, typeof(FooListResponseExample))] 46 | public async Task Get() 47 | { 48 | var foos = await _service.Get().ConfigureAwait(false); 49 | 50 | return Ok(foos); 51 | } 52 | 53 | /// 54 | /// Tries to retrieve specified foo. 55 | /// 56 | /// Unique identifier. 57 | /// 200, or 404 if the foo doesn't exist. 58 | [HttpGet, Route("{id:int}", Name = "GetById"), ResponseType(typeof(Foo))] 59 | [SwaggerResponseExample(HttpStatusCode.OK, typeof(FooResponseExample))] 60 | public async Task Get(int id) 61 | { 62 | var foo = await _service.Get(id).ConfigureAwait(false); 63 | 64 | if (foo == null) 65 | return NotFound(); 66 | 67 | return Ok(foo); 68 | } 69 | 70 | /// 71 | /// Tries to update the foo object. 72 | /// 73 | /// Instance of that contains modified values. 74 | /// 200. 75 | [HttpPatch, Route("")] 76 | [SwaggerRequestExample(typeof(Foo), typeof(FooRequestExample))] 77 | public async Task Patch(Foo foo) 78 | { 79 | await _service.Update(foo).ConfigureAwait(false); 80 | 81 | return Ok(); 82 | } 83 | 84 | /// 85 | /// Tries to delete the specified foo. 86 | /// 87 | /// Unique identifier. 88 | /// 200. 89 | [HttpDelete, Route("{id:int}")] 90 | public async Task Delete(int id) 91 | { 92 | // Delete should throw 404 if the resource doesn't exist, but it's skipped for brevity sake. 93 | await _service.Delete(id).ConfigureAwait(false); 94 | 95 | return Ok(); 96 | } 97 | } 98 | 99 | #region Services 100 | 101 | public interface IFooService 102 | { 103 | Task Add(Foo foo); 104 | 105 | Task Get(int id); 106 | 107 | Task> Get(); 108 | 109 | Task Update(Foo foo); 110 | 111 | Task Delete(int id); 112 | } 113 | 114 | public class FooService : IFooService 115 | { 116 | public Task Add(Foo foo) 117 | { 118 | return Task.FromResult(new Foo { Id = new Random().Next(), Value = foo.Value }); 119 | } 120 | 121 | public Task Get(int id) 122 | { 123 | return Task.FromResult(new Foo { Id = id, Value = "Foo" }); 124 | } 125 | 126 | public Task> Get() 127 | { 128 | return Task.FromResult>(new List 129 | { 130 | new Foo {Id = 1, Value = "Foo"}, 131 | new Foo {Id = 2, Value = "Boo"} 132 | }); 133 | } 134 | 135 | public Task Update(Foo foo) 136 | { 137 | return Task.CompletedTask; 138 | } 139 | 140 | public Task Delete(int id) 141 | { 142 | return Task.CompletedTask; 143 | } 144 | } 145 | 146 | #endregion 147 | 148 | #region Contracts 149 | 150 | public class Foo 151 | { 152 | /// 153 | /// Gets the creation date. 154 | /// 155 | public DateTime CreatedAt => DateTime.UtcNow; 156 | 157 | /// 158 | /// Gets or sets the unique identifier. 159 | /// 160 | public int Id { get; set; } 161 | 162 | /// 163 | /// Gets or sets the value. 164 | /// 165 | public object Value { get; set; } 166 | } 167 | 168 | #endregion 169 | 170 | #region Swagger Examples 171 | 172 | public class FooRequestExample : IExamplesProvider 173 | { 174 | public object GetExamples() 175 | { 176 | return new Foo 177 | { 178 | Id = new Random().Next(), 179 | Value = Guid.NewGuid().ToString().Remove(6) 180 | }; 181 | } 182 | } 183 | 184 | public class FooResponseExample : IExamplesProvider 185 | { 186 | public object GetExamples() 187 | { 188 | return new Foo 189 | { 190 | Id = new Random().Next(), 191 | Value = Guid.NewGuid().ToString().Remove(6) 192 | }; 193 | } 194 | } 195 | 196 | public class FooListResponseExample : IExamplesProvider 197 | { 198 | public object GetExamples() 199 | { 200 | return new List 201 | { 202 | new Foo {Id = new Random().Next(), Value = Guid.NewGuid().ToString().Remove(6)}, 203 | new Foo {Id = new Random().Next(), Value = Guid.NewGuid().ToString().Remove(6)} 204 | }; 205 | } 206 | } 207 | 208 | #endregion 209 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/App_Start/ApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Linq; 4 | using System.Net.Http.Formatting; 5 | using System.Net.Http.Headers; 6 | using System.Reflection; 7 | using System.Threading.Tasks; 8 | using System.Web; 9 | using System.Web.Cors; 10 | using System.Web.Http; 11 | using System.Web.Http.ExceptionHandling; 12 | using System.Xml.XPath; 13 | using Autofac; 14 | using Autofac.Integration.WebApi; 15 | using Microsoft.Owin.Cors; 16 | using Newtonsoft.Json.Serialization; 17 | using Owin; 18 | using Swashbuckle.Application; 19 | using Swashbuckle.Examples; 20 | using $safeprojectname$.Controllers; 21 | 22 | namespace $safeprojectname$.App_Start 23 | { 24 | /// 25 | /// Represents a class that encapsulates several Web Api configurations: CORS, routing, formatters, exception handling, dependency injection and Swagger 26 | /// 27 | [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Disposing HttpConfiguration will break Web API")] 28 | public sealed class ApiConfig 29 | { 30 | private readonly HttpConfiguration _configuration = new HttpConfiguration(); 31 | private readonly IAppBuilder _app; 32 | 33 | public ApiConfig(IAppBuilder app) 34 | { 35 | _app = app ?? throw new ArgumentNullException(nameof(app)); 36 | } 37 | 38 | /// 39 | /// Initializes and configures instance. 40 | /// 41 | /// String of allowed origins delimited by: ';' 42 | public ApiConfig ConfigureCorsMiddleware(string origins) 43 | { 44 | var corsOption = CorsOptions.AllowAll; 45 | 46 | if (string.IsNullOrWhiteSpace(origins)) 47 | _app.UseCors(corsOption); 48 | 49 | var corsPolicy = new CorsPolicy 50 | { 51 | AllowAnyMethod = true, 52 | AllowAnyHeader = true 53 | }; 54 | 55 | // StringSplitOptions.RemoveEmptyEntries doesn't remove whitespaces. 56 | origins.Split(';') 57 | .Where(x => !string.IsNullOrWhiteSpace(x)) 58 | .ToList() 59 | .ForEach(origin => corsPolicy.Origins.Add(origin)); 60 | 61 | if (!corsPolicy.Origins.Any()) 62 | _app.UseCors(corsOption); 63 | 64 | var corsOptions = new CorsOptions 65 | { 66 | PolicyProvider = new CorsPolicyProvider 67 | { 68 | PolicyResolver = context => Task.FromResult(corsPolicy) 69 | } 70 | }; 71 | 72 | _app.UseCors(corsOption); 73 | 74 | return this; 75 | } 76 | 77 | /// 78 | /// Configures formatter to use JSON only. 79 | /// 80 | public ApiConfig ConfigureFormatters() 81 | { 82 | // Delete 2 lines below if you need support for formatters other than json 83 | _configuration.Formatters.Clear(); 84 | _configuration.Formatters.Add(new JsonMediaTypeFormatter()); 85 | 86 | _configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver 87 | = new CamelCasePropertyNamesContractResolver(); 88 | 89 | _configuration.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; 90 | _configuration.Formatters.JsonFormatter.SupportedMediaTypes.Clear(); 91 | 92 | // Delete the line below if you nee more content type. E.g. application/text 93 | _configuration.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); 94 | 95 | return this; 96 | } 97 | 98 | /// 99 | /// Configures Web API routes. 100 | /// 101 | public ApiConfig ConfigureRoutes() 102 | { 103 | _configuration.MapHttpAttributeRoutes(); 104 | 105 | return this; 106 | } 107 | 108 | /// 109 | /// Configures custom implementations for: and . 110 | /// 111 | public ApiConfig ConfigureExceptionHandling() 112 | { 113 | _configuration.Services.Replace(typeof(IExceptionHandler), new ApiExceptionHandler()); 114 | _configuration.Services.Add(typeof(IExceptionLogger), new ApiExceptionLogger()); 115 | 116 | return this; 117 | } 118 | 119 | /// 120 | /// Initializes and configures instance of . 121 | /// 122 | public ApiConfig ConfigureAufacMiddleware() 123 | { 124 | var builder = new ContainerBuilder(); 125 | 126 | builder.RegisterType().As(); 127 | 128 | builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); 129 | 130 | var container = builder.Build(); 131 | 132 | _configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container); 133 | _app.UseAutofacMiddleware(container); 134 | 135 | return this; 136 | } 137 | 138 | /// 139 | /// COnfigures Swagger. 140 | /// 141 | public ApiConfig ConfigureSwagger() 142 | { 143 | _configuration 144 | .EnableSwagger(c => 145 | { 146 | c.SingleApiVersion("v1", GetType().Assembly.GetName().Name); 147 | c.PrettyPrint(); 148 | c.IncludeXmlComments(() => new XPathDocument($@"{AppContext.BaseDirectory}\bin\WebApiDocumentation.xml")); 149 | c.RootUrl(req => new Uri(req.RequestUri, HttpContext.Current.Request.ApplicationPath ?? string.Empty).ToString()); 150 | // In accordance with the built in JsonSerializer, Swashbuckle will, by default, describe enums as integers. 151 | // You can change the serializer behavior by configuring the StringToEnumConverter globally or for a given 152 | // enum type. Swashbuckle will honor this change out-of-the-box. However, if you use a different 153 | // approach to serialize enums as strings, you can also force Swashbuckle to describe them as strings. 154 | // 155 | c.DescribeAllEnumsAsStrings(); 156 | c.OperationFilter(); 157 | c.OperationFilter(); 158 | }) 159 | .EnableSwaggerUi(c => { }); 160 | 161 | return this; 162 | } 163 | 164 | public void UseWebApi() 165 | { 166 | _app.UseWebApi(_configuration); 167 | } 168 | } 169 | 170 | //public class CustomResponseType : IOperationFilter 171 | //{ 172 | // public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription) 173 | // { 174 | // operation.consumes.Clear(); 175 | // operation.produces.Clear(); 176 | // operation.consumes.Add("application/json"); 177 | // operation.produces.Add("application/json"); 178 | // } 179 | //} 180 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/App_Start/ApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Linq; 4 | using System.Net.Http.Formatting; 5 | using System.Net.Http.Headers; 6 | using System.Reflection; 7 | using System.Threading.Tasks; 8 | using System.Web; 9 | using System.Web.Cors; 10 | using System.Web.Http; 11 | using System.Web.Http.ExceptionHandling; 12 | using System.Xml.XPath; 13 | using Autofac; 14 | using Autofac.Integration.WebApi; 15 | using Microsoft.Owin.Cors; 16 | using Newtonsoft.Json.Serialization; 17 | using Owin; 18 | using Swashbuckle.Application; 19 | using Swashbuckle.Examples; 20 | using WebApiStarter.Controllers; 21 | 22 | namespace WebApiStarter.App_Start 23 | { 24 | /// 25 | /// Represents a class that encapsulates several Web Api configurations: CORS, routing, formatters, exception handling, dependency injection and Swagger 26 | /// 27 | [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Disposing HttpConfiguration will break Web API")] 28 | public sealed class ApiConfig 29 | { 30 | private readonly HttpConfiguration _configuration = new HttpConfiguration(); 31 | private readonly IAppBuilder _app; 32 | 33 | public ApiConfig(IAppBuilder app) 34 | { 35 | _app = app ?? throw new ArgumentNullException(nameof(app)); 36 | } 37 | 38 | /// 39 | /// Initializes and configures instance. 40 | /// 41 | /// String of allowed origins delimited by: ';' 42 | public ApiConfig ConfigureCorsMiddleware(string origins) 43 | { 44 | var corsOption = CorsOptions.AllowAll; 45 | 46 | if (string.IsNullOrWhiteSpace(origins)) 47 | _app.UseCors(corsOption); 48 | 49 | var corsPolicy = new CorsPolicy 50 | { 51 | AllowAnyMethod = true, 52 | AllowAnyHeader = true 53 | }; 54 | 55 | // StringSplitOptions.RemoveEmptyEntries doesn't remove whitespaces. 56 | origins.Split(';') 57 | .Where(x => !string.IsNullOrWhiteSpace(x)) 58 | .ToList() 59 | .ForEach(origin => corsPolicy.Origins.Add(origin)); 60 | 61 | if (!corsPolicy.Origins.Any()) 62 | _app.UseCors(corsOption); 63 | 64 | var corsOptions = new CorsOptions 65 | { 66 | PolicyProvider = new CorsPolicyProvider 67 | { 68 | PolicyResolver = context => Task.FromResult(corsPolicy) 69 | } 70 | }; 71 | 72 | _app.UseCors(corsOption); 73 | 74 | return this; 75 | } 76 | 77 | /// 78 | /// Configures formatter to use JSON only. 79 | /// 80 | public ApiConfig ConfigureFormatters() 81 | { 82 | // Delete 2 lines below if you need support for formatters other than json 83 | _configuration.Formatters.Clear(); 84 | _configuration.Formatters.Add(new JsonMediaTypeFormatter()); 85 | 86 | _configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver 87 | = new CamelCasePropertyNamesContractResolver(); 88 | 89 | _configuration.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; 90 | _configuration.Formatters.JsonFormatter.SupportedMediaTypes.Clear(); 91 | 92 | // Delete the line below if you nee more content type. E.g. application/text 93 | _configuration.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); 94 | 95 | return this; 96 | } 97 | 98 | /// 99 | /// Configures Web API routes. 100 | /// 101 | public ApiConfig ConfigureRoutes() 102 | { 103 | _configuration.MapHttpAttributeRoutes(); 104 | 105 | return this; 106 | } 107 | 108 | /// 109 | /// Configures custom implementations for: and . 110 | /// 111 | public ApiConfig ConfigureExceptionHandling() 112 | { 113 | _configuration.Services.Replace(typeof(IExceptionHandler), new ApiExceptionHandler()); 114 | _configuration.Services.Add(typeof(IExceptionLogger), new ApiExceptionLogger()); 115 | 116 | return this; 117 | } 118 | 119 | /// 120 | /// Initializes and configures instance of . 121 | /// 122 | public ApiConfig ConfigureAufacMiddleware() 123 | { 124 | var builder = new ContainerBuilder(); 125 | 126 | builder.RegisterType().As(); 127 | 128 | builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); 129 | 130 | var container = builder.Build(); 131 | 132 | _configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container); 133 | _app.UseAutofacMiddleware(container); 134 | 135 | return this; 136 | } 137 | 138 | /// 139 | /// COnfigures Swagger. 140 | /// 141 | public ApiConfig ConfigureSwagger() 142 | { 143 | _configuration 144 | .EnableSwagger(c => 145 | { 146 | c.SingleApiVersion("v1", GetType().Assembly.GetName().Name); 147 | c.PrettyPrint(); 148 | c.IncludeXmlComments(() => new XPathDocument(GetXmlDocumentationPath())); 149 | c.RootUrl(req => new Uri(req.RequestUri, HttpContext.Current.Request.ApplicationPath ?? string.Empty).ToString()); 150 | 151 | // In accordance with the built in JsonSerializer, Swashbuckle will, by default, describe enums as integers. 152 | // You can change the serializer behavior by configuring the StringToEnumConverter globally or for a given 153 | // enum type. Swashbuckle will honor this change out-of-the-box. However, if you use a different 154 | // approach to serialize enums as strings, you can also force Swashbuckle to describe them as strings. 155 | c.DescribeAllEnumsAsStrings(); 156 | c.OperationFilter(); 157 | c.OperationFilter(); 158 | }) 159 | .EnableSwaggerUi(c => { }); 160 | 161 | return this; 162 | 163 | string GetXmlDocumentationPath() 164 | { 165 | var path = $@"{AppContext.BaseDirectory}\bin\{GetType().Assembly.GetName().Name}.xml"; 166 | 167 | return path; 168 | } 169 | } 170 | 171 | public void UseWebApi() 172 | { 173 | _app.UseWebApi(_configuration); 174 | } 175 | } 176 | 177 | //public class CustomResponseType : IOperationFilter 178 | //{ 179 | // public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription) 180 | // { 181 | // operation.consumes.Clear(); 182 | // operation.produces.Clear(); 183 | // operation.consumes.Add("application/json"); 184 | // operation.produces.Add("application/json"); 185 | // } 186 | //} 187 | } -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter.Template/WebApiStarter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Debug 8 | AnyCPU 9 | 10 | 11 | 2.0 12 | {$guid1$} 13 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 14 | Library 15 | Properties 16 | $safeprojectname$ 17 | $safeprojectname$ 18 | v4.7.2 19 | true 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | true 32 | full 33 | false 34 | bin\ 35 | DEBUG;TRACE 36 | prompt 37 | 4 38 | bin\WebApiDocumentation.xml 39 | true 40 | true 41 | WebApiStarter.ruleset 42 | 43 | 44 | pdbonly 45 | true 46 | bin\ 47 | TRACE 48 | prompt 49 | 4 50 | bin\%24%28ProjectName%29.xml 51 | WebApiStarter.ruleset 52 | 53 | 54 | 55 | ..\packages\Autofac.4.8.1\lib\net45\Autofac.dll 56 | 57 | 58 | ..\packages\Autofac.Owin.4.2.0\lib\net45\Autofac.Integration.Owin.dll 59 | 60 | 61 | ..\packages\Autofac.WebApi2.4.2.0\lib\net45\Autofac.Integration.WebApi.dll 62 | 63 | 64 | ..\packages\Autofac.WebApi2.Owin.4.0.0\lib\net45\Autofac.Integration.WebApi.Owin.dll 65 | 66 | 67 | ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll 68 | 69 | 70 | 71 | ..\packages\Microsoft.Owin.4.0.0\lib\net451\Microsoft.Owin.dll 72 | 73 | 74 | ..\packages\Microsoft.Owin.Cors.4.0.0\lib\net451\Microsoft.Owin.Cors.dll 75 | 76 | 77 | ..\packages\Microsoft.Owin.Host.SystemWeb.4.0.0\lib\net451\Microsoft.Owin.Host.SystemWeb.dll 78 | 79 | 80 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 81 | 82 | 83 | ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll 84 | 85 | 86 | ..\packages\Owin.1.0\lib\net40\Owin.dll 87 | 88 | 89 | ..\packages\Swashbuckle.Core.5.6.0\lib\net40\Swashbuckle.Core.dll 90 | 91 | 92 | ..\packages\Swashbuckle.Examples.3.10.0\lib\net40\Swashbuckle.Examples.dll 93 | 94 | 95 | 96 | 97 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.6\lib\net45\System.Net.Http.Formatting.dll 98 | 99 | 100 | ..\packages\Microsoft.AspNet.Cors.5.2.6\lib\net45\System.Web.Cors.dll 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | ..\packages\Microsoft.AspNet.WebApi.Core.5.2.6\lib\net45\System.Web.Http.dll 113 | 114 | 115 | ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.6\lib\net45\System.Web.Http.Owin.dll 116 | 117 | 118 | ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.6\lib\net45\System.Web.Http.WebHost.dll 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | ..\packages\WebActivatorEx.2.2.0\lib\net40\WebActivatorEx.dll 127 | 128 | 129 | 130 | 131 | Designer 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | Web.config 146 | 147 | 148 | Web.config 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 10.0 157 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | True 167 | True 168 | 53986 169 | / 170 | http://localhost:53986/ 171 | False 172 | False 173 | 174 | 175 | False 176 | 177 | 178 | 179 | 180 | 181 | 182 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 201 | -------------------------------------------------------------------------------- /WebApiStarter/WebApiStarter/WebApiStarter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Debug 8 | AnyCPU 9 | 10 | 11 | 2.0 12 | {24DF2024-41A1-49C9-B2D2-96F0819DF41C} 13 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 14 | Library 15 | Properties 16 | WebApiStarter 17 | WebApiStarter 18 | v4.7.2 19 | true 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | true 32 | full 33 | false 34 | bin\ 35 | DEBUG;TRACE 36 | prompt 37 | 4 38 | bin\WebApiStarter.xml 39 | true 40 | true 41 | WebApiStarter.ruleset 42 | 43 | 44 | pdbonly 45 | true 46 | bin\ 47 | TRACE 48 | prompt 49 | 4 50 | bin\$(AssemblyName).xml 51 | WebApiStarter.ruleset 52 | 53 | 54 | 55 | ..\packages\Autofac.4.8.1\lib\net45\Autofac.dll 56 | 57 | 58 | ..\packages\Autofac.Owin.4.2.0\lib\net45\Autofac.Integration.Owin.dll 59 | 60 | 61 | ..\packages\Autofac.WebApi2.4.2.0\lib\net45\Autofac.Integration.WebApi.dll 62 | 63 | 64 | ..\packages\Autofac.WebApi2.Owin.4.0.0\lib\net45\Autofac.Integration.WebApi.Owin.dll 65 | 66 | 67 | ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll 68 | 69 | 70 | 71 | ..\packages\Microsoft.Owin.4.0.0\lib\net451\Microsoft.Owin.dll 72 | 73 | 74 | ..\packages\Microsoft.Owin.Cors.4.0.0\lib\net451\Microsoft.Owin.Cors.dll 75 | 76 | 77 | ..\packages\Microsoft.Owin.Host.SystemWeb.4.0.0\lib\net451\Microsoft.Owin.Host.SystemWeb.dll 78 | 79 | 80 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 81 | 82 | 83 | ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll 84 | 85 | 86 | ..\packages\Owin.1.0\lib\net40\Owin.dll 87 | 88 | 89 | ..\packages\Swashbuckle.Core.5.6.0\lib\net40\Swashbuckle.Core.dll 90 | 91 | 92 | ..\packages\Swashbuckle.Examples.3.10.0\lib\net40\Swashbuckle.Examples.dll 93 | 94 | 95 | 96 | 97 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.6\lib\net45\System.Net.Http.Formatting.dll 98 | 99 | 100 | ..\packages\Microsoft.AspNet.Cors.5.2.6\lib\net45\System.Web.Cors.dll 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | ..\packages\Microsoft.AspNet.WebApi.Core.5.2.6\lib\net45\System.Web.Http.dll 113 | 114 | 115 | ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.6\lib\net45\System.Web.Http.Owin.dll 116 | 117 | 118 | ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.6\lib\net45\System.Web.Http.WebHost.dll 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | ..\packages\WebActivatorEx.2.2.0\lib\net40\WebActivatorEx.dll 127 | 128 | 129 | 130 | 131 | Designer 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | Web.config 146 | 147 | 148 | Web.config 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 10.0 157 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | True 167 | True 168 | 53986 169 | / 170 | http://localhost:53986/ 171 | False 172 | False 173 | 174 | 175 | False 176 | 177 | 178 | 179 | 180 | 181 | 182 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 201 | --------------------------------------------------------------------------------