From d804b091398b0aa322a60f76a07625d3ce3ed492 Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Tue, 3 May 2016 19:52:19 +0200 Subject: [PATCH] Various improvements, v2.15 --- .../Properties/AssemblyInfo.cs | 2 +- .../NSwag.CodeGeneration.Tests.csproj | 8 +- .../Properties/AssemblyInfo.cs | 2 +- .../packages.config | 4 +- .../Infrastructure/AppDomainIsolation.cs | 4 +- .../NSwag.CodeGeneration.csproj | 8 +- .../Properties/AssemblyInfo.cs | 2 +- .../AssemblyTypeToSwaggerGenerator.cs | 4 +- .../AssemblyTypeToSwaggerGeneratorSettings.cs | 43 +- .../WebApiAssemblyToSwaggerGenerator.cs | 6 +- ...ebApiAssemblyToSwaggerGeneratorSettings.cs | 3 + src/NSwag.CodeGeneration/packages.config | 4 +- src/NSwag.Core/NSwag.Core.csproj | 7 +- src/NSwag.Core/Properties/AssemblyInfo.cs | 2 +- src/NSwag.Core/packages.config | 2 +- .../Properties/AssemblyInfo.cs | 2 +- src/NSwag.Demo.Web/NSwag.Demo.Web.csproj | 4 +- src/NSwag.Demo.Web/Web.config | 2 +- src/NSwag.Demo.Web/packages.config | 2 +- src/NSwag.Tests/NSwag.Tests.csproj | 4 +- src/NSwag.Tests/Properties/AssemblyInfo.cs | 2 +- src/NSwag.Tests/app.config | 2 +- src/NSwag.Tests/packages.config | 2 +- .../Commands/AssemblyTypeToSwaggerCommand.cs | 10 +- src/NSwag/Commands/WebApiToSwaggerCommand.cs | 12 +- src/NSwag/NSwag.csproj | 8 +- src/NSwag/Properties/AssemblyInfo.cs | 2 +- src/NSwag/packages.config | 4 +- src/NSwagStudio.Installer/Generated.wxs | 1436 ++++++++--------- src/NSwagStudio/NSwagDocument.cs | 54 +- src/NSwagStudio/NSwagStudio.csproj | 8 +- src/NSwagStudio/Properties/AssemblyInfo.cs | 2 +- .../AssemblySwaggerGeneratorView.xaml | 54 +- .../WebApiSwaggerGeneratorView.xaml | 54 +- src/NSwagStudio/packages.config | 4 +- 35 files changed, 911 insertions(+), 858 deletions(-) diff --git a/src/NSwag.Annotations/Properties/AssemblyInfo.cs b/src/NSwag.Annotations/Properties/AssemblyInfo.cs index 817a2b6c88..d123389cae 100644 --- a/src/NSwag.Annotations/Properties/AssemblyInfo.cs +++ b/src/NSwag.Annotations/Properties/AssemblyInfo.cs @@ -5,4 +5,4 @@ [assembly: AssemblyCompany("Rico Suter")] [assembly: AssemblyProduct("NSwag.Annotations")] [assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")] -[assembly: AssemblyVersion("2.14.*")] +[assembly: AssemblyVersion("2.15.*")] diff --git a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj index 3cd9951428..e59a5d404c 100644 --- a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj +++ b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj @@ -43,12 +43,12 @@ ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.2.13.5966.35759\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NJsonSchema.dll + + ..\packages\NJsonSchema.2.14.5967.31319\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.2.13.5966.35760\lib\net45\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.2.14.5967.31320\lib\net45\NJsonSchema.CodeGeneration.dll True diff --git a/src/NSwag.CodeGeneration.Tests/Properties/AssemblyInfo.cs b/src/NSwag.CodeGeneration.Tests/Properties/AssemblyInfo.cs index ac60d2bc44..20c6864185 100644 --- a/src/NSwag.CodeGeneration.Tests/Properties/AssemblyInfo.cs +++ b/src/NSwag.CodeGeneration.Tests/Properties/AssemblyInfo.cs @@ -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.14.*")] +// [assembly: AssemblyVersion("2.15.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/NSwag.CodeGeneration.Tests/packages.config b/src/NSwag.CodeGeneration.Tests/packages.config index abfd8d75e5..bb37463230 100644 --- a/src/NSwag.CodeGeneration.Tests/packages.config +++ b/src/NSwag.CodeGeneration.Tests/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file diff --git a/src/NSwag.CodeGeneration/Infrastructure/AppDomainIsolation.cs b/src/NSwag.CodeGeneration/Infrastructure/AppDomainIsolation.cs index a7bbc74348..33585bc618 100644 --- a/src/NSwag.CodeGeneration/Infrastructure/AppDomainIsolation.cs +++ b/src/NSwag.CodeGeneration/Infrastructure/AppDomainIsolation.cs @@ -13,7 +13,7 @@ namespace NSwag.CodeGeneration.Infrastructure internal sealed class AppDomainIsolation : IDisposable where T : MarshalByRefObject { /// is . - public AppDomainIsolation(string assemblyDirectory) + public AppDomainIsolation(string assemblyDirectory, string assemblyConfiguration) { if (string.IsNullOrEmpty(assemblyDirectory)) throw new ArgumentNullException("assemblyDirectory"); @@ -24,7 +24,7 @@ public AppDomainIsolation(string assemblyDirectory) { ShadowCopyFiles = "true", ApplicationBase = assemblyDirectory, - ConfigurationFile = transformer.GetConfigurationPath(assemblyDirectory) + ConfigurationFile = !string.IsNullOrEmpty(assemblyConfiguration) ? assemblyConfiguration : transformer.GetConfigurationPath(assemblyDirectory) }; Domain = AppDomain.CreateDomain("AppDomainIsolation:" + Guid.NewGuid(), null, setup); diff --git a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj index dbff1c4dd5..6369cd910a 100644 --- a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj +++ b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj @@ -41,12 +41,12 @@ ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.2.13.5966.35759\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NJsonSchema.dll + + ..\packages\NJsonSchema.2.14.5967.31319\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.2.13.5966.35760\lib\net45\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.2.14.5967.31320\lib\net45\NJsonSchema.CodeGeneration.dll True diff --git a/src/NSwag.CodeGeneration/Properties/AssemblyInfo.cs b/src/NSwag.CodeGeneration/Properties/AssemblyInfo.cs index 75ed061335..a8b1a00e2e 100644 --- a/src/NSwag.CodeGeneration/Properties/AssemblyInfo.cs +++ b/src/NSwag.CodeGeneration/Properties/AssemblyInfo.cs @@ -5,4 +5,4 @@ [assembly: AssemblyCompany("Rico Suter")] [assembly: AssemblyProduct("NSwag.CodeGeneration")] [assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")] -[assembly: AssemblyVersion("2.14.*")] +[assembly: AssemblyVersion("2.15.*")] diff --git a/src/NSwag.CodeGeneration/SwaggerGenerators/AssemblyTypeToSwaggerGenerator.cs b/src/NSwag.CodeGeneration/SwaggerGenerators/AssemblyTypeToSwaggerGenerator.cs index 34e86e15d0..b0f4d98d59 100644 --- a/src/NSwag.CodeGeneration/SwaggerGenerators/AssemblyTypeToSwaggerGenerator.cs +++ b/src/NSwag.CodeGeneration/SwaggerGenerators/AssemblyTypeToSwaggerGenerator.cs @@ -36,7 +36,7 @@ public string[] GetClasses() { if (File.Exists(Settings.AssemblyPath)) { - using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath))) + using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig)) return isolated.Object.GetClasses(Settings.AssemblyPath, Settings.ReferencePaths); } return new string[] { }; @@ -47,7 +47,7 @@ public string[] GetClasses() /// The Swagger definition. public SwaggerService Generate(string[] classNames) { - using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath))) + using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig)) return SwaggerService.FromJson(isolated.Object.FromAssemblyType(classNames, JsonConvert.SerializeObject(Settings))); } diff --git a/src/NSwag.CodeGeneration/SwaggerGenerators/AssemblyTypeToSwaggerGeneratorSettings.cs b/src/NSwag.CodeGeneration/SwaggerGenerators/AssemblyTypeToSwaggerGeneratorSettings.cs index d00edac257..b3b7f13f53 100644 --- a/src/NSwag.CodeGeneration/SwaggerGenerators/AssemblyTypeToSwaggerGeneratorSettings.cs +++ b/src/NSwag.CodeGeneration/SwaggerGenerators/AssemblyTypeToSwaggerGeneratorSettings.cs @@ -1,28 +1,31 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) Rico Suter. All rights reserved. -// -// https://github.com/NSwag/NSwag/blob/master/LICENSE.md -// Rico Suter, mail@rsuter.com -//----------------------------------------------------------------------- - -using NJsonSchema.Generation; - -namespace NSwag.CodeGeneration.SwaggerGenerators -{ - /// Settings for the . - public class AssemblyTypeToSwaggerGeneratorSettings : JsonSchemaGeneratorSettings - { +//----------------------------------------------------------------------- +// +// Copyright (c) Rico Suter. All rights reserved. +// +// https://github.com/NSwag/NSwag/blob/master/LICENSE.md +// Rico Suter, mail@rsuter.com +//----------------------------------------------------------------------- + +using NJsonSchema.Generation; + +namespace NSwag.CodeGeneration.SwaggerGenerators +{ + /// Settings for the . + public class AssemblyTypeToSwaggerGeneratorSettings : JsonSchemaGeneratorSettings + { /// Initializes a new instance of the class. public AssemblyTypeToSwaggerGeneratorSettings() { ReferencePaths = new string[] { }; } - - /// Gets or sets the assembly path. - public string AssemblyPath { get; set; } + + /// Gets or sets the assembly path. + public string AssemblyPath { get; set; } + + /// Gets or sets the path to the assembly App.config or Web.config (optional). + public string AssemblyConfig { get; set; } /// Gets ot sets the paths where to search for referenced assemblies - public string[] ReferencePaths { get; set; } - } + public string[] ReferencePaths { get; set; } + } } \ No newline at end of file diff --git a/src/NSwag.CodeGeneration/SwaggerGenerators/WebApi/WebApiAssemblyToSwaggerGenerator.cs b/src/NSwag.CodeGeneration/SwaggerGenerators/WebApi/WebApiAssemblyToSwaggerGenerator.cs index 8b7137fd2b..6c842b6e50 100644 --- a/src/NSwag.CodeGeneration/SwaggerGenerators/WebApi/WebApiAssemblyToSwaggerGenerator.cs +++ b/src/NSwag.CodeGeneration/SwaggerGenerators/WebApi/WebApiAssemblyToSwaggerGenerator.cs @@ -36,7 +36,7 @@ public string[] GetControllerClasses() { if (File.Exists(Settings.AssemblyPath)) { - using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath))) + using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig)) return isolated.Object.GetControllerClasses(Settings.AssemblyPath, Settings.ReferencePaths); } return new string[] { }; @@ -47,7 +47,7 @@ public string[] GetControllerClasses() /// The Swagger definition. public SwaggerService GenerateForController(string controllerClassName) { - using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath))) + using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig)) { var service = isolated.Object.GenerateForController(controllerClassName, JsonConvert.SerializeObject(Settings)); return SwaggerService.FromJson(service); @@ -59,7 +59,7 @@ public SwaggerService GenerateForController(string controllerClassName) /// The Swagger definition. public SwaggerService GenerateForControllers(IEnumerable controllerClassNames) { - using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath))) + using (var isolated = new AppDomainIsolation(Path.GetDirectoryName(Settings.AssemblyPath), Settings.AssemblyConfig)) { var service = isolated.Object.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings)); return SwaggerService.FromJson(service); diff --git a/src/NSwag.CodeGeneration/SwaggerGenerators/WebApi/WebApiAssemblyToSwaggerGeneratorSettings.cs b/src/NSwag.CodeGeneration/SwaggerGenerators/WebApi/WebApiAssemblyToSwaggerGeneratorSettings.cs index cf6a9e9853..6131acafa3 100644 --- a/src/NSwag.CodeGeneration/SwaggerGenerators/WebApi/WebApiAssemblyToSwaggerGeneratorSettings.cs +++ b/src/NSwag.CodeGeneration/SwaggerGenerators/WebApi/WebApiAssemblyToSwaggerGeneratorSettings.cs @@ -20,6 +20,9 @@ public WebApiAssemblyToSwaggerGeneratorSettings() /// Gets or sets the Web API assembly path. public string AssemblyPath { get; set; } + /// Gets or sets the path to the assembly App.config or Web.config (optional). + public string AssemblyConfig { get; set; } + /// Gets ot sets the paths where to search for referenced assemblies public string[] ReferencePaths { get; set; } } diff --git a/src/NSwag.CodeGeneration/packages.config b/src/NSwag.CodeGeneration/packages.config index 33054f0eb4..7b60e7c09c 100644 --- a/src/NSwag.CodeGeneration/packages.config +++ b/src/NSwag.CodeGeneration/packages.config @@ -2,6 +2,6 @@ - - + + \ No newline at end of file diff --git a/src/NSwag.Core/NSwag.Core.csproj b/src/NSwag.Core/NSwag.Core.csproj index ee1495ff0b..0bcb157419 100644 --- a/src/NSwag.Core/NSwag.Core.csproj +++ b/src/NSwag.Core/NSwag.Core.csproj @@ -46,8 +46,8 @@ ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.2.13.5966.35759\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NJsonSchema.dll + + ..\packages\NJsonSchema.2.14.5967.31319\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\NJsonSchema.dll True @@ -91,6 +91,9 @@ Designer + + +