Skip to content

Commit

Permalink
Merge pull request #132 from NSwag/master
Browse files Browse the repository at this point in the history
Release v2.33
  • Loading branch information
RicoSuter committed May 21, 2016
2 parents ba09701 + 389caf4 commit 50b333b
Show file tree
Hide file tree
Showing 19 changed files with 661 additions and 611 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The NSwag project heavily uses [NJsonSchema for .NET](http://njsonschema.org) fo
- [NSwag.Annotations](https://www.nuget.org/packages/NSwag.Annotations/) (PCL 259): Attributes to decorate Web API controllers to control the Swagger generation ([Source Code](https://github.com/NSwag/NSwag/tree/master/src/NSwag.Annotations))
- [NSwag.CodeGeneration](https://www.nuget.org/packages/NSwag.CodeGeneration/) (PCL 259): Classes to generate C# and TypeScript clients ([Source Code](https://github.com/NSwag/NSwag/tree/master/src/NSwag.CodeGeneration))
- [NSwag.AssemblyLoader](https://www.nuget.org/packages/NSwag.AssemblyLoader/) (.NET 4.5+): Classes to load assemblies in an isolated AppDomain and generate Swagger specs from Web API controllers
- [NSwag.MSBuild](https://www.nuget.org/packages/NSwag.MSBuild/) (MSBuild .targets): Adds a .targets file to your Visual Studio project, so that you can run the NSwag command line tool in a MSBuild target
- [NSwag.MSBuild](https://www.nuget.org/packages/NSwag.MSBuild/) (MSBuild .targets): Adds a .targets file to your Visual Studio project, so that you can run the NSwag command line tool in an MSBuild target

### Usage in C#

Expand Down
4 changes: 2 additions & 2 deletions src/NSwag.Annotations/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;

[assembly: AssemblyTitle("NSwag.Annotations")]
[assembly: AssemblyDescription("NSwag: The Swagger API toolchain for .NET")]
[assembly: AssemblyDescription("NSwag: The Swagger API toolchain for .NET and TypeScript")]
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwag.Annotations")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
[assembly: AssemblyVersion("2.32.*")]
[assembly: AssemblyVersion("2.33.*")]
4 changes: 2 additions & 2 deletions src/NSwag.AssemblyLoader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;

[assembly: AssemblyTitle("NSwag.AssemblyLoader")]
[assembly: AssemblyDescription("NSwag: The Swagger API toolchain for .NET")]
[assembly: AssemblyDescription("NSwag: The Swagger API toolchain for .NET and TypeScript")]
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwag.AssemblyLoader")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
[assembly: AssemblyVersion("2.32.*")]
[assembly: AssemblyVersion("2.33.*")]
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public string[] GetClasses()
{
if (File.Exists(Settings.AssemblyPath))
{
using (var isolated = new AppDomainIsolation<NetAssemblyLoader>(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig))
using (var isolated = new AppDomainIsolation<NetAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPath)), Settings.AssemblyConfig))
return isolated.Object.GetClasses(Settings.AssemblyPath, Settings.ReferencePaths);
}
return new string[] { };
Expand All @@ -47,7 +47,7 @@ public string[] GetClasses()
/// <returns>The Swagger definition.</returns>
public SwaggerService Generate(string[] classNames)
{
using (var isolated = new AppDomainIsolation<NetAssemblyLoader>(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig))
using (var isolated = new AppDomainIsolation<NetAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPath)), Settings.AssemblyConfig))
return SwaggerService.FromJson(isolated.Object.FromAssemblyType(classNames, JsonConvert.SerializeObject(Settings)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public string[] GetControllerClasses()
if (!string.IsNullOrEmpty(Settings.AssemblyConfig) && !File.Exists(Settings.AssemblyConfig))
throw new FileNotFoundException("The assembly config file could not be found.", Settings.AssemblyConfig);

using (var isolated = new AppDomainIsolation<WebApiAssemblyLoader>(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig))
using (var isolated = new AppDomainIsolation<WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPath)), Settings.AssemblyConfig))
return isolated.Object.GetControllerClasses(Settings.AssemblyPath, Settings.ReferencePaths);
}

Expand All @@ -50,7 +50,7 @@ public string[] GetControllerClasses()
/// <returns>The Swagger definition.</returns>
public SwaggerService GenerateForController(string controllerClassName)
{
using (var isolated = new AppDomainIsolation<WebApiAssemblyLoader>(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig))
using (var isolated = new AppDomainIsolation<WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPath)), Settings.AssemblyConfig))
{
var service = isolated.Object.GenerateForController(controllerClassName, JsonConvert.SerializeObject(Settings));
return SwaggerService.FromJson(service);
Expand All @@ -62,7 +62,7 @@ public SwaggerService GenerateForController(string controllerClassName)
/// <returns>The Swagger definition.</returns>
public SwaggerService GenerateForControllers(IEnumerable<string> controllerClassNames)
{
using (var isolated = new AppDomainIsolation<WebApiAssemblyLoader>(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig))
using (var isolated = new AppDomainIsolation<WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPath)), Settings.AssemblyConfig))
{
var service = isolated.Object.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings));
return SwaggerService.FromJson(service);
Expand Down Expand Up @@ -106,9 +106,9 @@ private IEnumerable<Type> GetControllerTypes(IEnumerable<string> controllerClass
var type = types.First(t => t.FullName == className || t.Name == className);
controllerTypes.Add(type);
}
catch
catch (Exception exception)
{
throw new TypeLoadException("Unable to load type for controller: " + className);
throw new TypeLoadException("Unable to load type for controller: " + className, exception);
}
}
return controllerTypes;
Expand All @@ -119,7 +119,10 @@ internal string[] GetControllerClasses(string assemblyPath, IEnumerable<string>
RegisterReferencePaths(referencePaths);
var assembly = Assembly.LoadFrom(assemblyPath);
return assembly.ExportedTypes
.Where(t => t.Name.EndsWith("Controller") || t.InheritsFrom("ApiController") || t.InheritsFrom("Controller"))
.Where(t => t.Name.EndsWith("Controller") ||
t.InheritsFrom("ApiController") ||
t.InheritsFrom("Controller")) // in ASP.NET Core, a Web API controller inherits from Controller
.Where(t => t.GetTypeInfo().ImplementedInterfaces.All(i => i.FullName != "System.Web.Mvc.IController")) // no MVC controllers (legacy ASP.NET)
.Select(t => t.FullName)
.ToArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.CodeGeneration.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("2.32.*")]
// [assembly: AssemblyVersion("2.33.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
4 changes: 2 additions & 2 deletions src/NSwag.CodeGeneration/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;

[assembly: AssemblyTitle("NSwag.CodeGeneration")]
[assembly: AssemblyDescription("NSwag: The Swagger API toolchain for .NET")]
[assembly: AssemblyDescription("NSwag: The Swagger API toolchain for .NET and TypeScript")]
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwag.CodeGeneration")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
[assembly: AssemblyVersion("2.32.*")]
[assembly: AssemblyVersion("2.33.*")]
4 changes: 2 additions & 2 deletions src/NSwag.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;

[assembly: AssemblyTitle("NSwag")]
[assembly: AssemblyDescription("NSwag: The Swagger API toolchain for .NET")]
[assembly: AssemblyDescription("NSwag: The Swagger API toolchain for .NET and TypeScript")]
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwag")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
[assembly: AssemblyVersion("2.32.*")]
[assembly: AssemblyVersion("2.33.*")]
2 changes: 1 addition & 1 deletion src/NSwag.Demo.Client/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("2.32.*")]
// [assembly: AssemblyVersion("2.33.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
14 changes: 14 additions & 0 deletions src/NSwag.Demo.Web/Controllers/MvcController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Web.Mvc;

namespace NSwag.Demo.Web.Controllers
{
// Shold not be picked up by GetControllerClasses()
public class MvcController : Controller
{
public ActionResult Index()
{
throw new NotImplementedException();
}
}
}
29 changes: 29 additions & 0 deletions src/NSwag.Demo.Web/NSwag.Demo.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
Expand All @@ -65,6 +69,10 @@
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
<Private>True</Private>
Expand All @@ -73,6 +81,26 @@
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
Expand All @@ -95,6 +123,7 @@
<ItemGroup>
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\FileController.cs" />
<Compile Include="Controllers\MvcController.cs" />
<Compile Include="Controllers\PersonsController.cs" />
<Compile Include="Controllers\RequestParameterTestController.cs" />
<Compile Include="Global.asax.cs">
Expand Down
24 changes: 12 additions & 12 deletions src/NSwag.Demo.Web/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,10 @@
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
Expand All @@ -60,6 +48,18 @@
<assemblyIdentity name="NJsonSchema" publicKeyToken="c2f9c3bdfae56102" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.23.5984.32960" newVersion="2.23.5984.32960" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.webServer>
Expand Down
4 changes: 4 additions & 0 deletions src/NSwag.Demo.Web/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
<packages>
<package id="jQuery" version="2.1.4" targetFramework="net45" />
<package id="jquery.TypeScript.DefinitelyTyped" version="2.3.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
<package id="NJsonSchema" version="2.23.5984.32960" targetFramework="net45" />
</packages>
4 changes: 2 additions & 2 deletions src/NSwag.MSBuild/NSwag.MSBuild.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>NSwag.MSBuild</id>
<version>2.32</version>
<version>2.33</version>
<authors>Rico Suter</authors>
<owners>Rico Suter</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/NSwag/NSwag</projectUrl>
<iconUrl>https://raw.githubusercontent.com/NSwag/NSwag/master/assets/NuGetIcon.png</iconUrl>
<description>NSwag: The Swagger API toolchain for .NET</description>
<description>NSwag: The Swagger API toolchain for .NET and TypeScript</description>
<tags>Swagger Documentation WebApi AspNet TypeScript CodeGen</tags>
<developmentDependency>true</developmentDependency>
<dependencies />
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("2.32.*")]
// [assembly: AssemblyVersion("2.33.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 1 addition & 1 deletion src/NSwag/Commands/WebApiToSwaggerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public string[] ReferencePaths
}

[Description("The Web API controller full class name or empty to load all controllers from the assembly.")]
[Argument(Name = "Controller", DefaultValue = null)]
[Argument(Name = "Controller", DefaultValue = "")]
public string ControllerName { get; set; }

[Description("The Web API controller full class names or empty to load all controllers from the assembly.")]
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwag.Console")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
[assembly: AssemblyVersion("2.32.*")]
[assembly: AssemblyVersion("2.33.*")]
Loading

0 comments on commit 50b333b

Please sign in to comment.