Skip to content

Commit

Permalink
Merge pull request #105 from NSwag/master
Browse files Browse the repository at this point in the history
Release v2.22
  • Loading branch information
RicoSuter committed May 14, 2016
2 parents 60c5e7f + 2246ba9 commit 90b8f8f
Show file tree
Hide file tree
Showing 46 changed files with 983 additions and 815 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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#

Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.Annotations/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.Annotations")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
[assembly: AssemblyVersion("2.21.*")]
[assembly: AssemblyVersion("2.22.*")]
4 changes: 2 additions & 2 deletions src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NJsonSchema, Version=2.18.5976.28450, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
<HintPath>..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll</HintPath>
<Reference Include="NJsonSchema, Version=2.19.5978.21534, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
<HintPath>..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AssemblyLoader/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.AssemblyLoader")]
[assembly: AssemblyCopyright("Copyright © Rico Suter, 2015")]
[assembly: AssemblyVersion("2.21.*")]
[assembly: AssemblyVersion("2.22.*")]
2 changes: 1 addition & 1 deletion src/NSwag.AssemblyLoader/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NJsonSchema" publicKeyToken="c2f9c3bdfae56102" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.15.5975.679" newVersion="2.15.5975.679" />
<bindingRedirect oldVersion="0.0.0.0-2.19.5978.21534" newVersion="2.19.5978.21534" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AssemblyLoader/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
<package id="NJsonSchema" version="2.18.5976.28450" targetFramework="net45" />
<package id="NJsonSchema" version="2.19.5978.21534" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NJsonSchema, Version=2.18.5976.28450, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
<HintPath>..\packages\NJsonSchema.2.18.5976.28450\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll</HintPath>
<Reference Include="NJsonSchema, Version=2.19.5978.21534, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
<HintPath>..\packages\NJsonSchema.2.19.5978.21534\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NJsonSchema.CodeGeneration, Version=2.18.5976.28451, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NJsonSchema.CodeGeneration.2.18.5976.28451\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll</HintPath>
<Reference Include="NJsonSchema.CodeGeneration, Version=2.19.5978.21535, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NJsonSchema.CodeGeneration.2.19.5978.21535\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
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.21.*")]
// [assembly: AssemblyVersion("2.22.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
4 changes: 2 additions & 2 deletions src/NSwag.CodeGeneration.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<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="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
<package id="NJsonSchema" version="2.18.5976.28450" targetFramework="net45" />
<package id="NJsonSchema.CodeGeneration" version="2.18.5976.28451" targetFramework="net45" />
<package id="NJsonSchema" version="2.19.5978.21534" targetFramework="net45" />
<package id="NJsonSchema.CodeGeneration" version="2.19.5978.21535" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -85,15 +86,16 @@ internal override string RenderClientCode(string controllerName, IEnumerable<Ope

HasOperations = operations.Any(),
Operations = operations,
UsesKnockout = Settings.TypeScriptGeneratorSettings.TypeStyle == TypeScriptTypeStyle.KnockoutClass,

GenerateClientInterfaces = Settings.GenerateClientInterfaces,
BaseUrl = _service.BaseUrl,
BaseUrl = _service.BaseUrl,
UseDtoClasses = Settings.TypeScriptGeneratorSettings.TypeStyle != TypeScriptTypeStyle.Interface,

PromiseType = Settings.PromiseType == PromiseType.Promise ? "Promise" : "Q.Promise",
PromiseConstructor = Settings.PromiseType == PromiseType.Promise ? "new Promise" : "Q.Promise"
});

return template.Render();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,28 @@ public virtual string TransformText()

#line default
#line hidden
this.Write(" var content = JSON.stringify(");
this.Write(" var content = ");

#line 72 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\Angular2Template.tt"
if(Model.UsesKnockout){

#line default
#line hidden
this.Write("ko.toJSON");

#line 72 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\Angular2Template.tt"
}else{

#line default
#line hidden
this.Write("JSON.stringify");

#line 72 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\Angular2Template.tt"
}

#line default
#line hidden
this.Write("(");

#line 72 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\Angular2Template.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.ContentParameter.VariableNameLower));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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 = "";
<#}#>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
<#}#>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,74 +42,81 @@ 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
#line hidden
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){#>
Expand All @@ -29,3 +28,5 @@ export const JSON_PARSE_REVIVER = new OpaqueToken('JSON_PARSE_REVIVER');
<#if(Model.HasModuleName){#>
}
<#}#>

<#=Model.AdditionalCode#>
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
<#}#>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading

0 comments on commit 90b8f8f

Please sign in to comment.