diff --git a/README.md b/README.md
index ff8bf3b1ad..0fbf6cf9d9 100644
--- a/README.md
+++ b/README.md
@@ -47,9 +47,10 @@ The NSwag project heavily uses [NJsonSchema for .NET](http://njsonschema.org) fo
**NuGet Packages**
-- [NSwag.Core](https://www.nuget.org/packages/NSwag.Core/): The Swagger reader and writer classes ([Source Code](https://github.com/NSwag/NSwag/tree/master/src/NSwag.Core))
-- [NSwag.Annotations](https://www.nuget.org/packages/NSwag.Annotations/): 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/): Classes to generate C# and TypeScript clients ([Source Code](https://github.com/NSwag/NSwag/tree/master/src/NSwag.CodeGeneration))
+- [NSwag.Core](https://www.nuget.org/packages/NSwag.Core/) (PCL 259): The Swagger reader and writer classes ([Source Code](https://github.com/NSwag/NSwag/tree/master/src/NSwag.Core))
+- [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
### Usage in C#
diff --git a/src/NSwag.Annotations/Properties/AssemblyInfo.cs b/src/NSwag.Annotations/Properties/AssemblyInfo.cs
index b62a49ec3c..614651799e 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.21.*")]
+[assembly: AssemblyVersion("2.22.*")]
diff --git a/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj b/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj
index 6807d06705..36051cdcac 100644
--- a/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj
+++ b/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj
@@ -39,8 +39,8 @@
..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
True
-
- ..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
+
+ ..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
True
diff --git a/src/NSwag.AssemblyLoader/Properties/AssemblyInfo.cs b/src/NSwag.AssemblyLoader/Properties/AssemblyInfo.cs
index db7d68752f..aae7d4961f 100644
--- a/src/NSwag.AssemblyLoader/Properties/AssemblyInfo.cs
+++ b/src/NSwag.AssemblyLoader/Properties/AssemblyInfo.cs
@@ -5,4 +5,4 @@
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwag.AssemblyLoader")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
-[assembly: AssemblyVersion("2.21.*")]
+[assembly: AssemblyVersion("2.22.*")]
diff --git a/src/NSwag.AssemblyLoader/app.config b/src/NSwag.AssemblyLoader/app.config
index ccc9ddf44d..a9acb11a1a 100644
--- a/src/NSwag.AssemblyLoader/app.config
+++ b/src/NSwag.AssemblyLoader/app.config
@@ -4,7 +4,7 @@
-
+
diff --git a/src/NSwag.AssemblyLoader/packages.config b/src/NSwag.AssemblyLoader/packages.config
index 1dc1ea8003..6787c3ca25 100644
--- a/src/NSwag.AssemblyLoader/packages.config
+++ b/src/NSwag.AssemblyLoader/packages.config
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj
index e7783b4d12..89dc1f34f8 100644
--- a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj
+++ b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj
@@ -39,12 +39,12 @@
..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
True
-
- ..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
+
+ ..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
True
-
- ..\packages\NJsonSchema.CodeGeneration.2.18.5976.28451\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll
+
+ ..\packages\NJsonSchema.CodeGeneration.2.19.5978.21535\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll
True
diff --git a/src/NSwag.CodeGeneration.Tests/Properties/AssemblyInfo.cs b/src/NSwag.CodeGeneration.Tests/Properties/AssemblyInfo.cs
index d5718d7b1c..46dd1e37e3 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.21.*")]
+// [assembly: AssemblyVersion("2.22.*")]
[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 c1ec64e199..3ab13fdaa3 100644
--- a/src/NSwag.CodeGeneration.Tests/packages.config
+++ b/src/NSwag.CodeGeneration.Tests/packages.config
@@ -3,6 +3,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/SwaggerToTypeScriptClientGenerator.cs b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/SwaggerToTypeScriptClientGenerator.cs
index e2611e3088..789685573a 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/SwaggerToTypeScriptClientGenerator.cs
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/SwaggerToTypeScriptClientGenerator.cs
@@ -62,13 +62,14 @@ internal override string RenderFile(string clientCode)
var template = new FileTemplate();
template.Initialize(new
{
- Toolchain = SwaggerService.ToolchainVersion,
- IsAngular2 = Settings.GenerateClientClasses && Settings.Template == TypeScriptTemplate.Angular2,
+ Toolchain = SwaggerService.ToolchainVersion,
+ IsAngular2 = Settings.GenerateClientClasses && Settings.Template == TypeScriptTemplate.Angular2,
- Clients = Settings.GenerateClientClasses ? clientCode : string.Empty,
+ Clients = Settings.GenerateClientClasses ? clientCode : string.Empty,
Interfaces = Settings.GenerateDtoTypes ? _resolver.GenerateTypes() : string.Empty,
+ AdditionalCode = Settings.TypeScriptGeneratorSettings.TransformedAdditionalCode,
- HasModuleName = !string.IsNullOrEmpty(Settings.ModuleName),
+ HasModuleName = !string.IsNullOrEmpty(Settings.ModuleName),
ModuleName = Settings.ModuleName
});
return template.Render();
@@ -85,15 +86,16 @@ internal override string RenderClientCode(string controllerName, IEnumerable <#if(Model.GenerateClientInterfaces){#>implements
}#>
<#if(operation.HasContent){#>
- var content = JSON.stringify(<#=operation.ContentParameter.VariableNameLower#>);
+ var content = <#if(Model.UsesKnockout){#>ko.toJSON<#}else{#>JSON.stringify<#}#>(<#=operation.ContentParameter.VariableNameLower#>);
<#}else{#>
var content = "";
<#}#>
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/AngularJSTemplate.cs b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/AngularJSTemplate.cs
index 8316ead233..a9002d2dae 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/AngularJSTemplate.cs
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/AngularJSTemplate.cs
@@ -679,7 +679,28 @@ public virtual string TransformText()
#line default
#line hidden
- this.Write(" var content = JSON.stringify(");
+ this.Write(" var content = ");
+
+ #line 71 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\AngularJSTemplate.tt"
+if(Model.UsesKnockout){
+
+ #line default
+ #line hidden
+ this.Write("ko.toJSON)");
+
+ #line 71 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\AngularJSTemplate.tt"
+}else{
+
+ #line default
+ #line hidden
+ this.Write("JSON.stringify");
+
+ #line 71 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\AngularJSTemplate.tt"
+}
+
+ #line default
+ #line hidden
+ this.Write("(");
#line 71 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\AngularJSTemplate.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.ContentParameter.VariableNameLower));
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/AngularJSTemplate.tt b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/AngularJSTemplate.tt
index d7c77b050b..0c03720c86 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/AngularJSTemplate.tt
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/AngularJSTemplate.tt
@@ -68,7 +68,7 @@ export class <#=Model.Class#> <#if(Model.GenerateClientInterfaces){#>implements
}#>
<#if(operation.HasContent){#>
- var content = JSON.stringify(<#=operation.ContentParameter.VariableNameLower#>);
+ var content = <#if(Model.UsesKnockout){#>ko.toJSON<#}else{#>JSON.stringify<#}#>(<#=operation.ContentParameter.VariableNameLower#>);
<#}else{#>
var content = "";
<#}#>
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/FileTemplate.cs b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/FileTemplate.cs
index c729000349..dde0efe6a0 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/FileTemplate.cs
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/FileTemplate.cs
@@ -42,37 +42,37 @@ public virtual string TransformText()
#line default
#line hidden
this.Write("\r\nimport \'rxjs/Rx\'; \r\nimport {Observable} from \'rxjs/Observable\';\r\nimport {Inject" +
- "able, Inject, Optional, OpaqueToken} from \'angular2/core\';\r\nimport {Http, Header" +
- "s, Response} from \'angular2/http\';\r\n\r\n");
+ "able, Inject, Optional, OpaqueToken} from \'@angular/core\';\r\nimport {Http, Header" +
+ "s, Response} from \'@angular/http\';\r\n");
- #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 15 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
}
#line default
#line hidden
this.Write("\r\n");
- #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 17 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
if(Model.HasModuleName){
#line default
#line hidden
this.Write("module ");
- #line 19 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Model.ModuleName));
#line default
#line hidden
this.Write(" {\r\n");
- #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 19 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
}
#line default
#line hidden
- #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
if(Model.IsAngular2){
#line default
@@ -80,36 +80,43 @@ public virtual string TransformText()
this.Write("export const API_BASE_URL = new OpaqueToken(\'API_BASE_URL\');\r\nexport const JSON_P" +
"ARSE_REVIVER = new OpaqueToken(\'JSON_PARSE_REVIVER\');\r\n\r\n");
- #line 25 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
}
#line default
#line hidden
- #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 25 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Model.Clients));
#line default
#line hidden
this.Write("\r\n\r\n");
- #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Model.Interfaces));
#line default
#line hidden
this.Write("\r\n");
- #line 29 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
if(Model.HasModuleName){
#line default
#line hidden
this.Write("}\r\n");
- #line 31 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
}
+ #line default
+ #line hidden
+ this.Write("\r\n");
+
+ #line 32 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FileTemplate.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture(Model.AdditionalCode));
+
#line default
#line hidden
return this.GenerationEnvironment.ToString();
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/FileTemplate.tt b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/FileTemplate.tt
index 6fbd0f6216..c9f266894f 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/FileTemplate.tt
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/FileTemplate.tt
@@ -10,9 +10,8 @@
import 'rxjs/Rx';
import {Observable} from 'rxjs/Observable';
-import {Injectable, Inject, Optional, OpaqueToken} from 'angular2/core';
-import {Http, Headers, Response} from 'angular2/http';
-
+import {Injectable, Inject, Optional, OpaqueToken} from '@angular/core';
+import {Http, Headers, Response} from '@angular/http';
<#}#>
<#if(Model.HasModuleName){#>
@@ -29,3 +28,5 @@ export const JSON_PARSE_REVIVER = new OpaqueToken('JSON_PARSE_REVIVER');
<#if(Model.HasModuleName){#>
}
<#}#>
+
+<#=Model.AdditionalCode#>
\ No newline at end of file
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryCallbacksTemplate.cs b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryCallbacksTemplate.cs
index 19835c04ce..70df019bb0 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryCallbacksTemplate.cs
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryCallbacksTemplate.cs
@@ -716,7 +716,28 @@ public virtual string TransformText()
#line default
#line hidden
- this.Write(" var content = JSON.stringify(");
+ this.Write(" var content = ");
+
+ #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\JQueryCallbacksTemplate.tt"
+if(Model.UsesKnockout){
+
+ #line default
+ #line hidden
+ this.Write("ko.toJSON)");
+
+ #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\JQueryCallbacksTemplate.tt"
+}else{
+
+ #line default
+ #line hidden
+ this.Write("JSON.stringify");
+
+ #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\JQueryCallbacksTemplate.tt"
+}
+
+ #line default
+ #line hidden
+ this.Write("(");
#line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\JQueryCallbacksTemplate.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.ContentParameter.VariableNameLower));
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryCallbacksTemplate.tt b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryCallbacksTemplate.tt
index 262df85e15..8bf732743e 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryCallbacksTemplate.tt
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryCallbacksTemplate.tt
@@ -65,7 +65,7 @@ export class <#=Model.Class#> <#if(Model.GenerateClientInterfaces){#>implements
}#>
<#if(operation.HasContent){#>
- var content = JSON.stringify(<#=operation.ContentParameter.VariableNameLower#>);
+ var content = <#if(Model.UsesKnockout){#>ko.toJSON<#}else{#>JSON.stringify<#}#>(<#=operation.ContentParameter.VariableNameLower#>);
<#}else{#>
var content = "";
<#}#>
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryPromisesTemplate.cs b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryPromisesTemplate.cs
index b36920efd7..5c1ea0627c 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryPromisesTemplate.cs
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryPromisesTemplate.cs
@@ -803,7 +803,28 @@ public virtual string TransformText()
#line default
#line hidden
- this.Write(" var content = JSON.stringify(");
+ this.Write(" var content = ");
+
+ #line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\JQueryPromisesTemplate.tt"
+if(Model.UsesKnockout){
+
+ #line default
+ #line hidden
+ this.Write("ko.toJSON)");
+
+ #line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\JQueryPromisesTemplate.tt"
+}else{
+
+ #line default
+ #line hidden
+ this.Write("JSON.stringify");
+
+ #line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\JQueryPromisesTemplate.tt"
+}
+
+ #line default
+ #line hidden
+ this.Write("(");
#line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\JQueryPromisesTemplate.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.ContentParameter.VariableNameLower));
diff --git a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryPromisesTemplate.tt b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryPromisesTemplate.tt
index 6c6f883b16..a271b4b467 100644
--- a/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryPromisesTemplate.tt
+++ b/src/NSwag.CodeGeneration/CodeGenerators/TypeScript/Templates/JQueryPromisesTemplate.tt
@@ -70,7 +70,7 @@ export class <#=Model.Class#> <#if(Model.GenerateClientInterfaces){#>implements
}#>
<#if(operation.HasContent){#>
- var content = JSON.stringify(<#=operation.ContentParameter.VariableNameLower#>);
+ var content = <#if(Model.UsesKnockout){#>ko.toJSON<#}else{#>JSON.stringify<#}#>(<#=operation.ContentParameter.VariableNameLower#>);
<#}else{#>
var content = "";
<#}#>
diff --git a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj
index ae0529dca1..162d206ab6 100644
--- a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj
+++ b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj
@@ -40,12 +40,12 @@
..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
True
-
- ..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
+
+ ..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
True
-
- ..\packages\NJsonSchema.CodeGeneration.2.18.5976.28451\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll
+
+ ..\packages\NJsonSchema.CodeGeneration.2.19.5978.21535\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll
True
diff --git a/src/NSwag.CodeGeneration/Properties/AssemblyInfo.cs b/src/NSwag.CodeGeneration/Properties/AssemblyInfo.cs
index 1f32965678..eddf421009 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.21.*")]
+[assembly: AssemblyVersion("2.22.*")]
diff --git a/src/NSwag.CodeGeneration/packages.config b/src/NSwag.CodeGeneration/packages.config
index 0f734864b7..06d984ef11 100644
--- a/src/NSwag.CodeGeneration/packages.config
+++ b/src/NSwag.CodeGeneration/packages.config
@@ -1,6 +1,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/NSwag.Core/NSwag.Core.csproj b/src/NSwag.Core/NSwag.Core.csproj
index d707e2053a..2a089d72aa 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.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
+
+ ..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
True
diff --git a/src/NSwag.Core/Properties/AssemblyInfo.cs b/src/NSwag.Core/Properties/AssemblyInfo.cs
index d5cf758823..6d502efa5a 100644
--- a/src/NSwag.Core/Properties/AssemblyInfo.cs
+++ b/src/NSwag.Core/Properties/AssemblyInfo.cs
@@ -5,4 +5,4 @@
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwag")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
-[assembly: AssemblyVersion("2.21.*")]
+[assembly: AssemblyVersion("2.22.*")]
diff --git a/src/NSwag.Core/packages.config b/src/NSwag.Core/packages.config
index a73e89bf4e..a78ec281ca 100644
--- a/src/NSwag.Core/packages.config
+++ b/src/NSwag.Core/packages.config
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/src/NSwag.Demo.Client/Properties/AssemblyInfo.cs b/src/NSwag.Demo.Client/Properties/AssemblyInfo.cs
index e6f8ee2d74..c3d78f1a9a 100644
--- a/src/NSwag.Demo.Client/Properties/AssemblyInfo.cs
+++ b/src/NSwag.Demo.Client/Properties/AssemblyInfo.cs
@@ -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.21.*")]
+// [assembly: AssemblyVersion("2.22.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj b/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj
index 23701a9d7a..df9aa34308 100644
--- a/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj
+++ b/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj
@@ -47,8 +47,8 @@
..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
True
-
- ..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
+
+ ..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
True
diff --git a/src/NSwag.Demo.Web/Web.config b/src/NSwag.Demo.Web/Web.config
index 6f57576599..cf6d93b764 100644
--- a/src/NSwag.Demo.Web/Web.config
+++ b/src/NSwag.Demo.Web/Web.config
@@ -58,7 +58,7 @@
-
+
diff --git a/src/NSwag.Demo.Web/packages.config b/src/NSwag.Demo.Web/packages.config
index 39549b1bf5..e06eb20c62 100644
--- a/src/NSwag.Demo.Web/packages.config
+++ b/src/NSwag.Demo.Web/packages.config
@@ -7,5 +7,5 @@
-
+
\ No newline at end of file
diff --git a/src/NSwag.Tests/NSwag.Tests.csproj b/src/NSwag.Tests/NSwag.Tests.csproj
index 629f6e97b4..98a95a19cf 100644
--- a/src/NSwag.Tests/NSwag.Tests.csproj
+++ b/src/NSwag.Tests/NSwag.Tests.csproj
@@ -39,8 +39,8 @@
..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
True
-
- ..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
+
+ ..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
True
diff --git a/src/NSwag.Tests/Properties/AssemblyInfo.cs b/src/NSwag.Tests/Properties/AssemblyInfo.cs
index 70cdafa218..41f3180efd 100644
--- a/src/NSwag.Tests/Properties/AssemblyInfo.cs
+++ b/src/NSwag.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.21.*")]
+// [assembly: AssemblyVersion("2.22.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/NSwag.Tests/app.config b/src/NSwag.Tests/app.config
index f9e9e96f04..4a93b8a4a7 100644
--- a/src/NSwag.Tests/app.config
+++ b/src/NSwag.Tests/app.config
@@ -8,7 +8,7 @@
-
+
diff --git a/src/NSwag.Tests/packages.config b/src/NSwag.Tests/packages.config
index a25347c1f6..cdfde686ae 100644
--- a/src/NSwag.Tests/packages.config
+++ b/src/NSwag.Tests/packages.config
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/src/NSwag/Commands/SwaggerToTypeScriptCommand.cs b/src/NSwag/Commands/SwaggerToTypeScriptCommand.cs
index 8fef6f6435..b7abed2d51 100644
--- a/src/NSwag/Commands/SwaggerToTypeScriptCommand.cs
+++ b/src/NSwag/Commands/SwaggerToTypeScriptCommand.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.IO;
using System.Threading.Tasks;
using NConsole;
using Newtonsoft.Json;
@@ -100,6 +101,19 @@ public TypeScriptTypeStyle TypeStyle
set { Settings.TypeScriptGeneratorSettings.TypeStyle = value; }
}
+ // TODO: Implement a way to pass mappings via cmd line
+ //[Description("Type class mappings.")]
+ //[Argument(Name = "ClassMappings", DefaultValue = null)]
+ public TypeScriptClassMapping[] ClassMappings
+ {
+ get { return Settings.TypeScriptGeneratorSettings.ClassMappings; }
+ set { Settings.TypeScriptGeneratorSettings.ClassMappings = value; }
+ }
+
+ [Description("The additional code (string or file path).")]
+ [Argument(Name = "AdditionalCode", DefaultValue = "")]
+ public string AdditionalCode { get; set; }
+
public override async Task RunAsync(CommandLineProcessor processor, IConsoleHost host)
{
var output = await RunAsync();
@@ -108,6 +122,11 @@ public override async Task RunAsync(CommandLineProcessor processor, IConsoleHost
public async Task RunAsync()
{
+ var additionalCode = AdditionalCode ?? "";
+ if (File.Exists(additionalCode))
+ additionalCode = File.ReadAllText(additionalCode);
+ Settings.TypeScriptGeneratorSettings.AdditionalCode = additionalCode;
+
var clientGenerator = new SwaggerToTypeScriptClientGenerator(InputSwaggerService, Settings);
return clientGenerator.GenerateFile();
}
diff --git a/src/NSwag/NSwag.csproj b/src/NSwag/NSwag.csproj
index 92a6fd0de1..66b929af98 100644
--- a/src/NSwag/NSwag.csproj
+++ b/src/NSwag/NSwag.csproj
@@ -42,12 +42,12 @@
..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
True
-
- ..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
+
+ ..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
True
-
- ..\packages\NJsonSchema.CodeGeneration.2.18.5976.28451\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll
+
+ ..\packages\NJsonSchema.CodeGeneration.2.19.5978.21535\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll
True
diff --git a/src/NSwag/Properties/AssemblyInfo.cs b/src/NSwag/Properties/AssemblyInfo.cs
index 0dd1354944..a5970051bf 100644
--- a/src/NSwag/Properties/AssemblyInfo.cs
+++ b/src/NSwag/Properties/AssemblyInfo.cs
@@ -5,4 +5,4 @@
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwag.Console")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
-[assembly: AssemblyVersion("2.21.*")]
+[assembly: AssemblyVersion("2.22.*")]
diff --git a/src/NSwag/packages.config b/src/NSwag/packages.config
index 5b9fe1b721..f487aed64c 100644
--- a/src/NSwag/packages.config
+++ b/src/NSwag/packages.config
@@ -2,6 +2,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/NSwagStudio.Installer/Generated.wxs b/src/NSwagStudio.Installer/Generated.wxs
index 3c95a5c83a..f3259a60dc 100644
--- a/src/NSwagStudio.Installer/Generated.wxs
+++ b/src/NSwagStudio.Installer/Generated.wxs
@@ -516,197 +516,197 @@
-
-
+
+
-
-
-
-
+
-
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
-
+
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -715,128 +715,128 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -845,507 +845,504 @@
-
-
-
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
-
-
+
+
-
+
-
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
-
-
+
+
-
+
-
-
-
-
+
-
-
-
-
+
-
+
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1359,6 +1356,9 @@
+
+
+
diff --git a/src/NSwagStudio/NSwagDocument.cs b/src/NSwagStudio/NSwagDocument.cs
index c451dcedd3..ef723a1122 100644
--- a/src/NSwagStudio/NSwagDocument.cs
+++ b/src/NSwagStudio/NSwagDocument.cs
@@ -6,9 +6,11 @@
// Rico Suter, mail@rsuter.com
//-----------------------------------------------------------------------
+using System.Collections.Generic;
using System.IO;
using MyToolkit.Model;
using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
using NSwag.Commands;
using NSwagStudio.Utilities;
@@ -54,8 +56,14 @@ public static NSwagDocument LoadDocument(string filePath)
public void Save()
{
ConvertToRelativePaths();
-
- _latestData = JsonConvert.SerializeObject(this, Formatting.Indented);
+
+ _latestData = JsonConvert.SerializeObject(this, Formatting.Indented, new JsonSerializerSettings
+ {
+ Converters = new List
+ {
+ new StringEnumConverter()
+ }
+ });
ConvertToAbsolutePaths();
File.WriteAllText(Path, _latestData);
}
@@ -66,6 +74,8 @@ private void ConvertToAbsolutePaths()
AssemblyTypeToSwaggerCommand.AssemblyPath = ConvertToAbsolute(AssemblyTypeToSwaggerCommand.AssemblyPath);
WebApiToSwaggerCommand.AssemblyConfig = ConvertToAbsolute(WebApiToSwaggerCommand.AssemblyConfig);
AssemblyTypeToSwaggerCommand.AssemblyConfig = ConvertToAbsolute(AssemblyTypeToSwaggerCommand.AssemblyConfig);
+
+ SwaggerToTypeScriptCommand.AdditionalCode = ConvertToAbsolute(SwaggerToTypeScriptCommand.AdditionalCode);
}
private string ConvertToAbsolute(string path)
@@ -81,13 +91,15 @@ private void ConvertToRelativePaths()
AssemblyTypeToSwaggerCommand.AssemblyPath = ConvertToRelativePath(AssemblyTypeToSwaggerCommand.AssemblyPath);
WebApiToSwaggerCommand.AssemblyConfig = ConvertToRelativePath(WebApiToSwaggerCommand.AssemblyConfig);
AssemblyTypeToSwaggerCommand.AssemblyConfig = ConvertToRelativePath(AssemblyTypeToSwaggerCommand.AssemblyConfig);
+
+ SwaggerToTypeScriptCommand.AdditionalCode = ConvertToRelativePath(SwaggerToTypeScriptCommand.AdditionalCode);
}
private string ConvertToRelativePath(string path)
{
if (!string.IsNullOrEmpty(path))
return PathUtilities.MakeRelativePath(path, System.IO.Path.GetDirectoryName(Path));
- return path;
+ return path;
}
public static NSwagDocument CreateDocument()
@@ -113,7 +125,13 @@ public string Path
public string Name => System.IO.Path.GetFileName(Path);
[JsonIgnore]
- public bool IsDirty => _latestData != JsonConvert.SerializeObject(this, Formatting.Indented);
+ public bool IsDirty => _latestData != JsonConvert.SerializeObject(this, Formatting.Indented, new JsonSerializerSettings
+ {
+ Converters = new List
+ {
+ new StringEnumConverter()
+ }
+ });
/// Gets or sets the selected Swagger generator.
[JsonProperty("SelectedSwaggerGenerator")]
@@ -136,7 +154,7 @@ public int SelectedClientGenerator
[JsonProperty("InputSwaggerUrl")]
public string InputSwaggerUrl { get; set; }
-
+
[JsonProperty("InputJsonSchema")]
public string InputJsonSchema { get; set; }
diff --git a/src/NSwagStudio/NSwagStudio.csproj b/src/NSwagStudio/NSwagStudio.csproj
index 2d94cb7490..1d13f2ad91 100644
--- a/src/NSwagStudio/NSwagStudio.csproj
+++ b/src/NSwagStudio/NSwagStudio.csproj
@@ -70,12 +70,12 @@
..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
True
-
- ..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
+
+ ..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll
True
-
- ..\packages\NJsonSchema.CodeGeneration.2.18.5976.28451\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll
+
+ ..\packages\NJsonSchema.CodeGeneration.2.19.5978.21535\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll
True
diff --git a/src/NSwagStudio/Properties/AssemblyInfo.cs b/src/NSwagStudio/Properties/AssemblyInfo.cs
index 4bfad1fe6d..64a1552fae 100644
--- a/src/NSwagStudio/Properties/AssemblyInfo.cs
+++ b/src/NSwagStudio/Properties/AssemblyInfo.cs
@@ -5,4 +5,4 @@
[assembly: AssemblyCompany("Rico Suter")]
[assembly: AssemblyProduct("NSwagStudio")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
-[assembly: AssemblyVersion("2.21.*")]
+[assembly: AssemblyVersion("2.22.*")]
diff --git a/src/NSwagStudio/ViewModels/CodeGenerators/TypeScriptClientGeneratorViewModel.cs b/src/NSwagStudio/ViewModels/CodeGenerators/TypeScriptClientGeneratorViewModel.cs
index c8b8df71b9..b14822cc3e 100644
--- a/src/NSwagStudio/ViewModels/CodeGenerators/TypeScriptClientGeneratorViewModel.cs
+++ b/src/NSwagStudio/ViewModels/CodeGenerators/TypeScriptClientGeneratorViewModel.cs
@@ -11,6 +11,7 @@
using System.Threading.Tasks;
using System.Windows;
using MyToolkit.Storage;
+using Newtonsoft.Json;
using NJsonSchema.CodeGeneration.TypeScript;
using NSwag.CodeGeneration.CodeGenerators;
using NSwag.CodeGeneration.CodeGenerators.TypeScript;
@@ -45,7 +46,7 @@ public TypeScriptTemplate[] Templates
{
get { return Enum.GetNames(typeof(TypeScriptTemplate)).Select(t => (TypeScriptTemplate)Enum.Parse(typeof(TypeScriptTemplate), t)).ToArray(); }
}
-
+
/// Gets the operation modes.
public OperationGenerationMode[] OperationGenerationModes
{
@@ -69,6 +70,22 @@ public TypeScriptTypeStyle[] TypeStyles
}
}
+ public string ClassMappings
+ {
+ get { return _command.ClassMappings != null ? JsonConvert.SerializeObject(_command.ClassMappings, Formatting.Indented) : "[]"; }
+ set
+ {
+ try
+ {
+ _command.ClassMappings = JsonConvert.DeserializeObject(value);
+ }
+ catch
+ {
+ _command.ClassMappings = new TypeScriptClassMapping[] { };
+ }
+ RaisePropertyChanged();
+ }
+ }
/// Gets or sets the client code.
public string ClientCode
diff --git a/src/NSwagStudio/Views/CodeGenerators/TypeScriptClientGeneratorView.xaml b/src/NSwagStudio/Views/CodeGenerators/TypeScriptClientGeneratorView.xaml
index 1b657a9fe1..6cc8d2a81e 100644
--- a/src/NSwagStudio/Views/CodeGenerators/TypeScriptClientGeneratorView.xaml
+++ b/src/NSwagStudio/Views/CodeGenerators/TypeScriptClientGeneratorView.xaml
@@ -83,6 +83,15 @@
+
+
+
+
+
+
diff --git a/src/NSwagStudio/packages.config b/src/NSwagStudio/packages.config
index 5ee64802de..5feadf9112 100644
--- a/src/NSwagStudio/packages.config
+++ b/src/NSwagStudio/packages.config
@@ -7,6 +7,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/Samples/DemoWeb.nswag b/src/Samples/DemoWeb.nswag
index b3315cbc1a..7381db97d7 100644
--- a/src/Samples/DemoWeb.nswag
+++ b/src/Samples/DemoWeb.nswag
@@ -9,12 +9,10 @@
"ReferencePaths": [],
"ControllerName": "",
"ControllerNames": [
- "NSwag.Demo.Web.Controllers.FileController",
- "NSwag.Demo.Web.Controllers.PersonsController",
- "NSwag.Demo.Web.Controllers.RequestParameterTestController"
+ "NSwag.Demo.Web.Controllers.PersonsController"
],
"DefaultUrlTemplate": "api/{controller}/{action}/{id}",
- "DefaultEnumHandling": 0,
+ "DefaultEnumHandling": "Integer",
"FlattenInheritanceHierarchy": false,
"GenerateKnownTypes": true,
"OutputFilePath": null
@@ -23,7 +21,7 @@
"AssemblyPath": null,
"AssemblyConfig": null,
"ReferencePaths": [],
- "DefaultEnumHandling": 0,
+ "DefaultEnumHandling": "Integer",
"FlattenInheritanceHierarchy": false,
"GenerateKnownTypes": true,
"ClassNames": [],
@@ -32,14 +30,26 @@
"SwaggerToTypeScriptCommand": {
"ClassName": "{controller}Client",
"ModuleName": "",
- "Template": 3,
- "PromiseType": 0,
+ "Template": "JQueryPromises",
+ "PromiseType": "Promise",
"GenerateClientClasses": true,
- "GenerateClientInterfaces": true,
+ "GenerateClientInterfaces": false,
"GenerateDtoTypes": true,
- "OperationGenerationMode": 0,
- "GenerateReadOnlyKeywords": false,
- "TypeStyle": 1,
+ "OperationGenerationMode": "MultipleClientsFromOperationId",
+ "GenerateReadOnlyKeywords": true,
+ "TypeStyle": "Class",
+ "ClassMappings": [
+ {
+ "Class": "Person",
+ "TargetModule": "MyModule",
+ "TargetClass": "MyPerson"
+ },
+ {
+ "Class": "Car",
+ "TargetModule": "MyModule",
+ "TargetClass": "MyCar"
+ }
+ ],
"Input": null,
"OutputFilePath": null
},
@@ -58,14 +68,14 @@
"DateTimeType": "DateTime",
"ArrayType": "ObservableCollection",
"DictionaryType": "Dictionary",
- "ClassStyle": 0
+ "ClassStyle": "Poco"
},
"ClassName": "{controller}Client",
"AdditionalNamespaceUsages": [
"a",
"b"
],
- "OperationGenerationMode": 0,
+ "OperationGenerationMode": "MultipleClientsFromOperationId",
"GenerateDtoTypes": true,
"GenerateClientInterfaces": true,
"GenerateClientClasses": true
@@ -80,8 +90,8 @@
"DateTimeType": "DateTime",
"ArrayType": "ObservableCollection",
"DictionaryType": "Dictionary",
- "ClassStyle": 0,
- "OperationGenerationMode": 0,
+ "ClassStyle": "Poco",
+ "OperationGenerationMode": "MultipleClientsFromOperationId",
"Input": null,
"OutputFilePath": null
},
@@ -95,13 +105,13 @@
"DateTimeType": "DateTime",
"ArrayType": "IEnumerable",
"DictionaryType": "Dictionary",
- "ClassStyle": 1
+ "ClassStyle": "Inpc"
},
"ClassName": "{controller}",
"AdditionalNamespaceUsages": [
"System.Web.Http"
],
- "OperationGenerationMode": 0,
+ "OperationGenerationMode": "MultipleClientsFromOperationId",
"GenerateDtoTypes": true,
"GenerateClientInterfaces": false,
"GenerateClientClasses": true
@@ -115,8 +125,8 @@
"DateTimeType": "DateTime",
"ArrayType": "IEnumerable",
"DictionaryType": "Dictionary",
- "ClassStyle": 1,
- "OperationGenerationMode": 0,
+ "ClassStyle": "Inpc",
+ "OperationGenerationMode": "MultipleClientsFromOperationId",
"Input": null,
"OutputFilePath": null
}