From d888c6dbd52598030b8227f7faa427ea10c2acb9 Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Tue, 14 Feb 2017 16:13:39 +0100 Subject: [PATCH] Updated NJS, minor tpl and code fixes, #591 --- .../NSwag.AspNet.Owin.csproj | 4 +- src/NSwag.AspNet.Owin/packages.config | 2 +- .../NSwag.AssemblyLoader.csproj | 4 +- src/NSwag.AssemblyLoader/app.config | 2 +- src/NSwag.AssemblyLoader/packages.config | 2 +- .../NSwag.CodeGeneration.CSharp.Tests.csproj | 4 +- .../app.config | 2 +- .../packages.config | 2 +- .../Models/CSharpOperationModel.cs | 298 +-- .../NSwag.CodeGeneration.CSharp.csproj | 12 +- .../Templates/ClientTemplate.cs | 11 +- .../Templates/ClientTemplate.tt | 4 +- .../packages.config | 6 +- .../NSwag.CodeGeneration.Tests.csproj | 16 +- .../packages.config | 8 +- ...wag.CodeGeneration.TypeScript.Tests.csproj | 4 +- .../app.config | 2 +- .../packages.config | 2 +- .../NSwag.CodeGeneration.TypeScript.csproj | 12 +- .../Templates/FetchClientTemplate.cs | 2052 +++++++++-------- .../packages.config | 6 +- .../Models/OperationModelBase.cs | 2 +- .../NSwag.CodeGeneration.csproj | 8 +- src/NSwag.CodeGeneration/packages.config | 4 +- src/NSwag.Commands/NSwag.Commands.csproj | 16 +- src/NSwag.Commands/packages.config | 8 +- src/NSwag.Console/NSwag.Console.csproj | 16 +- src/NSwag.Console/packages.config | 8 +- src/NSwag.Core/NSwag.Core.csproj | 4 +- src/NSwag.Core/packages.config | 2 +- .../NSwag.Demo.OwinWeb.csproj | 4 +- src/NSwag.Demo.OwinWeb/Web.config | 2 +- src/NSwag.Demo.OwinWeb/packages.config | 2 +- src/NSwag.Demo.Web/NSwag.Demo.Web.csproj | 4 +- src/NSwag.Demo.Web/Web.config | 2 +- src/NSwag.Demo.Web/packages.config | 2 +- .../NSwag.Integration.WebAPI.csproj | 4 +- src/NSwag.Integration.WebAPI/Web.config | 2 +- src/NSwag.Integration.WebAPI/packages.config | 2 +- ...Swag.SwaggerGeneration.WebApi.Tests.csproj | 4 +- .../app.config | 2 +- .../packages.config | 2 +- .../NSwag.SwaggerGeneration.WebApi.csproj | 4 +- .../packages.config | 2 +- .../NSwag.SwaggerGeneration.csproj | 4 +- src/NSwag.SwaggerGeneration/packages.config | 2 +- src/NSwag.Tests/NSwag.Tests.csproj | 8 +- src/NSwag.Tests/app.config | 4 +- src/NSwag.Tests/packages.config | 4 +- src/NSwagStudio/NSwagStudio.csproj | 16 +- src/NSwagStudio/packages.config | 8 +- 51 files changed, 1313 insertions(+), 1294 deletions(-) diff --git a/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj b/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj index 809de32559..63a25fb4b7 100644 --- a/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj +++ b/src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj @@ -83,8 +83,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True diff --git a/src/NSwag.AspNet.Owin/packages.config b/src/NSwag.AspNet.Owin/packages.config index da8398a448..d86564473a 100644 --- a/src/NSwag.AspNet.Owin/packages.config +++ b/src/NSwag.AspNet.Owin/packages.config @@ -5,6 +5,6 @@ - + \ No newline at end of file diff --git a/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj b/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj index a31591993f..12e8d75d04 100644 --- a/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj +++ b/src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj @@ -69,8 +69,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True diff --git a/src/NSwag.AssemblyLoader/app.config b/src/NSwag.AssemblyLoader/app.config index c2f0a8e31d..31261b89e6 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 d9da51654b..499d9efa8f 100644 --- a/src/NSwag.AssemblyLoader/packages.config +++ b/src/NSwag.AssemblyLoader/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/NSwag.CodeGeneration.CSharp.Tests.csproj b/src/NSwag.CodeGeneration.CSharp.Tests/NSwag.CodeGeneration.CSharp.Tests.csproj index 91fce9934e..1846c56fd4 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/NSwag.CodeGeneration.CSharp.Tests.csproj +++ b/src/NSwag.CodeGeneration.CSharp.Tests/NSwag.CodeGeneration.CSharp.Tests.csproj @@ -37,8 +37,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/app.config b/src/NSwag.CodeGeneration.CSharp.Tests/app.config index 0286537728..1b1f91d9e9 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/app.config +++ b/src/NSwag.CodeGeneration.CSharp.Tests/app.config @@ -8,7 +8,7 @@ - + diff --git a/src/NSwag.CodeGeneration.CSharp.Tests/packages.config b/src/NSwag.CodeGeneration.CSharp.Tests/packages.config index 03f2326419..6072edefab 100644 --- a/src/NSwag.CodeGeneration.CSharp.Tests/packages.config +++ b/src/NSwag.CodeGeneration.CSharp.Tests/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs b/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs index 401dca929a..0ef033a588 100644 --- a/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs +++ b/src/NSwag.CodeGeneration.CSharp/Models/CSharpOperationModel.cs @@ -1,151 +1,151 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) Rico Suter. All rights reserved. -// -// https://github.com/NSwag/NSwag/blob/master/LICENSE.md -// Rico Suter, mail@rsuter.com -//----------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Linq; -using NJsonSchema; -using NSwag.CodeGeneration.Models; - -namespace NSwag.CodeGeneration.CSharp.Models -{ - /// The CSharp operation model. - public class CSharpOperationModel : OperationModelBase - { - private static readonly string[] ReservedKeywords = - { - "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", - "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", - "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", - "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", - "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", - "ushort", "using", "virtual", "void", "volatile", "while" - }; - - private readonly SwaggerToCSharpGeneratorSettings _settings; - private readonly SwaggerOperation _operation; - private readonly SwaggerToCSharpGeneratorBase _generator; - - /// Initializes a new instance of the class. - /// The operation. - /// The settings. - /// The generator. - /// The resolver. - public CSharpOperationModel( - SwaggerOperation operation, - SwaggerToCSharpGeneratorSettings settings, - SwaggerToCSharpGeneratorBase generator, - SwaggerToCSharpTypeResolver resolver) - : base(resolver.ExceptionSchema, operation, resolver, generator, settings) - { - _settings = settings; - _operation = operation; - _generator = generator; - - var parameters = _operation.ActualParameters.ToList(); - if (settings.GenerateOptionalParameters) - parameters = parameters.OrderBy(p => !p.IsRequired).ToList(); - - Parameters = parameters.Select(parameter => +//----------------------------------------------------------------------- +// +// Copyright (c) Rico Suter. All rights reserved. +// +// https://github.com/NSwag/NSwag/blob/master/LICENSE.md +// Rico Suter, mail@rsuter.com +//----------------------------------------------------------------------- + +using System.Collections.Generic; +using System.Linq; +using NJsonSchema; +using NSwag.CodeGeneration.Models; + +namespace NSwag.CodeGeneration.CSharp.Models +{ + /// The CSharp operation model. + public class CSharpOperationModel : OperationModelBase + { + private static readonly string[] ReservedKeywords = + { + "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", + "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", + "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", + "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", + "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", + "ushort", "using", "virtual", "void", "volatile", "while" + }; + + private readonly SwaggerToCSharpGeneratorSettings _settings; + private readonly SwaggerOperation _operation; + private readonly SwaggerToCSharpGeneratorBase _generator; + + /// Initializes a new instance of the class. + /// The operation. + /// The settings. + /// The generator. + /// The resolver. + public CSharpOperationModel( + SwaggerOperation operation, + SwaggerToCSharpGeneratorSettings settings, + SwaggerToCSharpGeneratorBase generator, + SwaggerToCSharpTypeResolver resolver) + : base(resolver.ExceptionSchema, operation, resolver, generator, settings) + { + _settings = settings; + _operation = operation; + _generator = generator; + + var parameters = _operation.ActualParameters.ToList(); + if (settings.GenerateOptionalParameters) + parameters = parameters.OrderBy(p => !p.IsRequired).ToList(); + + Parameters = parameters.Select(parameter => new CSharpParameterModel(parameter.Name, GetParameterVariableName(parameter, _operation.Parameters), - ResolveParameterType(parameter), parameter, parameters, - _settings.CodeGeneratorSettings, - _generator)) - .ToList(); - } - - /// Gets the method's access modifier. - public string MethodAccessModifier - { - get - { - var controllerName = _settings.GenerateControllerName(ControllerName); - var settings = _settings as SwaggerToCSharpClientGeneratorSettings; - if (settings != null && settings.ProtectedMethods?.Contains(controllerName + "." + OperationNameUpper + "Async") == true) - return "protected"; - - return "public"; - } - } - + ResolveParameterType(parameter), parameter, parameters, + _settings.CodeGeneratorSettings, + _generator)) + .ToList(); + } + + /// Gets the method's access modifier. + public string MethodAccessModifier + { + get + { + var controllerName = _settings.GenerateControllerName(ControllerName); + var settings = _settings as SwaggerToCSharpClientGeneratorSettings; + if (settings != null && settings.ProtectedMethods?.Contains(controllerName + "." + OperationNameUpper + "Async") == true) + return "protected"; + + return "public"; + } + } + /// Gets a value indicating whether this operation is rendered as interface method. - public bool IsInterfaceMethod => MethodAccessModifier == "public"; - - /// Gets or sets the type of the result. - public override string ResultType - { - get - { - if (UnwrappedResultType == "FileResponse") - return "System.Threading.Tasks.Task"; - - if (_settings != null && _settings.WrapResponses) - return UnwrappedResultType == "void" - ? "System.Threading.Tasks.Task<" + _settings.ResponseClass.Replace("{controller}", ControllerName) + ">" - : "System.Threading.Tasks.Task<" + _settings.ResponseClass.Replace("{controller}", ControllerName) + "<" + UnwrappedResultType + ">>"; - - return UnwrappedResultType == "void" - ? "System.Threading.Tasks.Task" - : "System.Threading.Tasks.Task<" + UnwrappedResultType + ">"; - } - } - - /// Gets or sets the type of the exception. - public override string ExceptionType - { - get - { - if (_operation.Responses.Count(r => !HttpUtilities.IsSuccessStatusCode(r.Key)) != 1) - return "System.Exception"; - - var response = _operation.Responses.Single(r => !HttpUtilities.IsSuccessStatusCode(r.Key)).Value; - return _generator.GetTypeName(response.ActualResponseSchema, response.IsNullable(_settings.CodeGeneratorSettings.NullHandling), "Exception"); - } - } - - /// Gets the name of the parameter variable. - /// The parameter. - /// All parameters. - /// The parameter variable name. - protected override string GetParameterVariableName(SwaggerParameter parameter, IEnumerable allParameters) - { - var name = base.GetParameterVariableName(parameter, allParameters); - return ReservedKeywords.Contains(name) ? "@" + name : name; - } - - /// Resolves the type of the parameter. - /// The parameter. - /// The parameter type name. - protected override string ResolveParameterType(SwaggerParameter parameter) - { - var schema = parameter.ActualSchema; - if (schema.Type == JsonObjectType.File) - { - if (parameter.CollectionFormat == SwaggerParameterCollectionFormat.Multi && !schema.Type.HasFlag(JsonObjectType.Array)) - return "System.Collections.Generic.IEnumerable"; - - return "FileParameter"; - } - - return base.ResolveParameterType(parameter) - .Replace(_settings.CSharpGeneratorSettings.ArrayType + "<", "System.Collections.Generic.IEnumerable<") - .Replace(_settings.CSharpGeneratorSettings.DictionaryType + "<", "System.Collections.Generic.IDictionary<"); - } - - /// Creates the response model. - /// The status code. - /// The response. - /// The exception schema. - /// The generator. - /// The settings. - /// - protected override CSharpResponseModel CreateResponseModel(string statusCode, SwaggerResponse response, JsonSchema4 exceptionSchema, IClientGenerator generator, ClientGeneratorBaseSettings settings) - { - return new CSharpResponseModel(statusCode, response, response == GetSuccessResponse(), exceptionSchema, generator, settings.CodeGeneratorSettings); - } - } -} + public bool IsInterfaceMethod => MethodAccessModifier == "public"; + + /// Gets or sets the type of the result. + public override string ResultType + { + get + { + if (UnwrappedResultType == "FileResponse") + return "System.Threading.Tasks.Task"; + + if (_settings != null && _settings.WrapResponses) + return UnwrappedResultType == "void" + ? "System.Threading.Tasks.Task<" + _settings.ResponseClass.Replace("{controller}", ControllerName) + ">" + : "System.Threading.Tasks.Task<" + _settings.ResponseClass.Replace("{controller}", ControllerName) + "<" + UnwrappedResultType + ">>"; + + return UnwrappedResultType == "void" + ? "System.Threading.Tasks.Task" + : "System.Threading.Tasks.Task<" + UnwrappedResultType + ">"; + } + } + + /// Gets or sets the type of the exception. + public override string ExceptionType + { + get + { + if (_operation.Responses.Count(r => !HttpUtilities.IsSuccessStatusCode(r.Key)) != 1) + return "System.Exception"; + + var response = _operation.Responses.Single(r => !HttpUtilities.IsSuccessStatusCode(r.Key)).Value; + return _generator.GetTypeName(response.ActualResponseSchema, response.IsNullable(_settings.CodeGeneratorSettings.NullHandling), "Exception"); + } + } + + /// Gets the name of the parameter variable. + /// The parameter. + /// All parameters. + /// The parameter variable name. + protected override string GetParameterVariableName(SwaggerParameter parameter, IEnumerable allParameters) + { + var name = base.GetParameterVariableName(parameter, allParameters); + return ReservedKeywords.Contains(name) ? "@" + name : name; + } + + /// Resolves the type of the parameter. + /// The parameter. + /// The parameter type name. + protected override string ResolveParameterType(SwaggerParameter parameter) + { + var schema = parameter.ActualSchema; + if (schema.Type == JsonObjectType.File) + { + if (parameter.CollectionFormat == SwaggerParameterCollectionFormat.Multi && !schema.Type.HasFlag(JsonObjectType.Array)) + return "System.Collections.Generic.IEnumerable"; + + return "FileParameter"; + } + + return base.ResolveParameterType(parameter) + .Replace(_settings.CSharpGeneratorSettings.ArrayType + "<", "System.Collections.Generic.IEnumerable<") + .Replace(_settings.CSharpGeneratorSettings.DictionaryType + "<", "System.Collections.Generic.IDictionary<"); + } + + /// Creates the response model. + /// The status code. + /// The response. + /// The exception schema. + /// The generator. + /// The settings. + /// + protected override CSharpResponseModel CreateResponseModel(string statusCode, SwaggerResponse response, JsonSchema4 exceptionSchema, IClientGenerator generator, ClientGeneratorBaseSettings settings) + { + return new CSharpResponseModel(statusCode, response, response == GetSuccessResponse(), exceptionSchema, generator, settings.CodeGeneratorSettings); + } + } +} diff --git a/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj b/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj index 23768de5f1..9f34bc3de5 100644 --- a/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj +++ b/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj @@ -133,16 +133,16 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll True - - ..\packages\NJsonSchema.CodeGeneration.CSharp.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll + + ..\packages\NJsonSchema.CodeGeneration.CSharp.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll True diff --git a/src/NSwag.CodeGeneration.CSharp/Templates/ClientTemplate.cs b/src/NSwag.CodeGeneration.CSharp/Templates/ClientTemplate.cs index e945d5a8f6..39a264f5e1 100644 --- a/src/NSwag.CodeGeneration.CSharp/Templates/ClientTemplate.cs +++ b/src/NSwag.CodeGeneration.CSharp/Templates/ClientTemplate.cs @@ -1349,7 +1349,14 @@ public virtual string TransformText() #line default #line hidden - this.Write(");\r\n"); + this.Write(" != null ? "); + + #line 158 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); + + #line default + #line hidden + this.Write(".ToString() : null);\r\n"); #line 159 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ClientTemplate.tt" } @@ -1620,7 +1627,7 @@ public virtual string TransformText() var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { - var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h => h.Key, h => h.Value); + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; diff --git a/src/NSwag.CodeGeneration.CSharp/Templates/ClientTemplate.tt b/src/NSwag.CodeGeneration.CSharp/Templates/ClientTemplate.tt index b26661b133..8152b4128c 100644 --- a/src/NSwag.CodeGeneration.CSharp/Templates/ClientTemplate.tt +++ b/src/NSwag.CodeGeneration.CSharp/Templates/ClientTemplate.tt @@ -155,7 +155,7 @@ public partial interface I<#=Model.Class#> { PrepareRequest(client_, ref url_); <#foreach(var parameter in operation.HeaderParameters){#> - request_.Headers.TryAddWithoutValidation("<#=parameter.Name#>", <#=parameter.VariableName#>); + request_.Headers.TryAddWithoutValidation("<#=parameter.Name#>", <#=parameter.VariableName#> != null ? <#=parameter.VariableName#>.ToString() : null); <#}#> <#if(operation.HasContent){#> var content_ = new System.Net.Http.StringContent(<#if(operation.HasXmlBodyParameter){#><#=operation.ContentParameter.VariableName#><#}else{#>Newtonsoft.Json.JsonConvert.SerializeObject(<#=operation.ContentParameter.VariableName#><#=Model.JsonConverters#>)<#}#>); @@ -194,7 +194,7 @@ public partial interface I<#=Model.Class#> var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { - var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h => h.Key, h => h.Value); + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; diff --git a/src/NSwag.CodeGeneration.CSharp/packages.config b/src/NSwag.CodeGeneration.CSharp/packages.config index 36827c3eee..57b24b668d 100644 --- a/src/NSwag.CodeGeneration.CSharp/packages.config +++ b/src/NSwag.CodeGeneration.CSharp/packages.config @@ -1,7 +1,7 @@  - - - + + + \ 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 db58200510..1d9b19cb95 100644 --- a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj +++ b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj @@ -65,20 +65,20 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll True - - ..\packages\NJsonSchema.CodeGeneration.CSharp.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll + + ..\packages\NJsonSchema.CodeGeneration.CSharp.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll True - - ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll + + ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll True diff --git a/src/NSwag.CodeGeneration.Tests/packages.config b/src/NSwag.CodeGeneration.Tests/packages.config index 08746a5114..f3162cfd39 100644 --- a/src/NSwag.CodeGeneration.Tests/packages.config +++ b/src/NSwag.CodeGeneration.Tests/packages.config @@ -7,9 +7,9 @@ - - - - + + + + \ No newline at end of file diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/NSwag.CodeGeneration.TypeScript.Tests.csproj b/src/NSwag.CodeGeneration.TypeScript.Tests/NSwag.CodeGeneration.TypeScript.Tests.csproj index 2a2d5b19e1..dd4f660ae9 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/NSwag.CodeGeneration.TypeScript.Tests.csproj +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/NSwag.CodeGeneration.TypeScript.Tests.csproj @@ -37,8 +37,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/app.config b/src/NSwag.CodeGeneration.TypeScript.Tests/app.config index 0286537728..1b1f91d9e9 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/app.config +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/app.config @@ -8,7 +8,7 @@ - + diff --git a/src/NSwag.CodeGeneration.TypeScript.Tests/packages.config b/src/NSwag.CodeGeneration.TypeScript.Tests/packages.config index 03f2326419..6072edefab 100644 --- a/src/NSwag.CodeGeneration.TypeScript.Tests/packages.config +++ b/src/NSwag.CodeGeneration.TypeScript.Tests/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj b/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj index 0a30a8ce8a..c1cb6586c5 100644 --- a/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj +++ b/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj @@ -190,16 +190,16 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll True - - ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll + + ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll True diff --git a/src/NSwag.CodeGeneration.TypeScript/Templates/FetchClientTemplate.cs b/src/NSwag.CodeGeneration.TypeScript/Templates/FetchClientTemplate.cs index 6ac6b5d9d3..8ff85836e8 100644 --- a/src/NSwag.CodeGeneration.TypeScript/Templates/FetchClientTemplate.cs +++ b/src/NSwag.CodeGeneration.TypeScript/Templates/FetchClientTemplate.cs @@ -1,1020 +1,1032 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version: 14.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace NSwag.CodeGeneration.TypeScript.Templates -{ - using NJsonSchema; - using CodeGeneration.TypeScript; - using System; - - /// - /// Class to produce the template output - /// - - #line 1 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "14.0.0.0")] - internal partial class FetchClientTemplate : FetchClientTemplateBase - { -#line hidden - /// - /// Create the template output - /// - public virtual string TransformText() - { - this.Write("\r\n"); - - #line 5 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.HasOperations){ - - #line default - #line hidden - - #line 6 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.GenerateClientInterfaces){ - - #line default - #line hidden - this.Write("export interface I"); - - #line 7 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); - - #line default - #line hidden - this.Write(" {\r\n"); - - #line 8 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -foreach(var operation in Model.Operations){ - - #line default - #line hidden - - #line 9 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(operation.HasDocumentation){ - - #line default - #line hidden - this.Write(" /**\r\n"); - - #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(operation.HasSummary){ - - #line default - #line hidden - this.Write(" * "); - - #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary)); - - #line default - #line hidden - this.Write("\r\n"); - - #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -foreach(var parameter in operation.Parameters){ - - #line default - #line hidden - - #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(parameter.HasDescription){ - - #line default - #line hidden - this.Write(" * @"); - - #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); - - #line default - #line hidden - this.Write(" "); - - #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? "")); - - #line default - #line hidden - this.Write("\r\n"); - - #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(operation.HasResultDescription){ - - #line default - #line hidden - this.Write(" * @return "); - - #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription)); - - #line default - #line hidden - this.Write("\r\n"); - - #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(operation.IsDeprecated){ - - #line default - #line hidden - this.Write(" * @deprecated\r\n"); - - #line 15 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" */\r\n"); - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" "); - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameLower)); - - #line default - #line hidden - this.Write("("); - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -foreach(var parameter in operation.Parameters){ - - #line default - #line hidden - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); - - #line default - #line hidden - this.Write(": "); - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type)); - - #line default - #line hidden - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(!parameter.IsLast){ - - #line default - #line hidden - this.Write(", "); - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write("): Promise<"); - - #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); - - #line default - #line hidden - this.Write(">;\r\n"); - - #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write("}\r\n"); - - #line 18 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write("\r\n"); - - #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.UseAureliaHttpInjection){ - - #line default - #line hidden - this.Write("@inject(String, HttpClient)\r\n"); - - #line 22 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write("export class "); - - #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); - - #line default - #line hidden - this.Write(" "); - - #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.HasClientBaseClass){ - - #line default - #line hidden - this.Write("extends "); - - #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClientBaseClass)); - - #line default - #line hidden - this.Write(" "); - - #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.GenerateClientInterfaces){ - - #line default - #line hidden - this.Write("implements I"); - - #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); - - #line default - #line hidden - this.Write(" "); - - #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write("{\r\n private baseUrl: string; \r\n private http: { fetch(url: RequestInfo, ini" + - "t?: RequestInit): Promise };\r\n protected jsonParseReviver: "); - - #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.SupportsStrictNullChecks){ - - #line default - #line hidden - this.Write("((key: string, value: any) => any) | undefined"); - - #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -}else{ - - #line default - #line hidden - this.Write("(key: string, value: any) => any"); - - #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" = undefined;\r\n\r\n constructor(baseUrl?: string, http?: { fetch(url: RequestInf" + - "o, init?: RequestInit): Promise }) {\r\n"); - - #line 29 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.HasClientBaseClass){ - - #line default - #line hidden - this.Write(" super();\r\n"); - - #line 31 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" this.baseUrl = baseUrl ? baseUrl : \"\";\r\n this.http = http ? http :" + - " window;\r\n }\r\n"); - - #line 35 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.HasExtensionClass && !Model.HasClientBaseClass){ - - #line default - #line hidden - - #line 36 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - if(Model.UseTransformOptionsMethod){ - - #line default - #line hidden - this.Write("\r\n protected transformOptions(options: RequestInit) {\r\n return Promise." + - "resolve(options); \r\n }\r\n"); - - #line 41 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - } - - #line default - #line hidden - - #line 42 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - if(Model.UseTransformResultMethod){ - - #line default - #line hidden - this.Write("\r\n protected transformResult(url: string, response: Response, processor: (resp" + - "onse: Response) => any) {\r\n return processor(response);\r\n }\r\n"); - - #line 47 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - } - - #line default - #line hidden - - #line 48 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 49 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -foreach(var operation in Model.Operations){ - - #line default - #line hidden - this.Write("\r\n"); - - #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(operation.HasDocumentation){ - - #line default - #line hidden - this.Write(" /**\r\n"); - - #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(operation.HasSummary){ - - #line default - #line hidden - this.Write(" * "); - - #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary)); - - #line default - #line hidden - this.Write("\r\n"); - - #line 53 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 53 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -foreach(var parameter in operation.Parameters){ - - #line default - #line hidden - - #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(parameter.HasDescription){ - - #line default - #line hidden - this.Write(" * @"); - - #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); - - #line default - #line hidden - this.Write(" "); - - #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? "")); - - #line default - #line hidden - this.Write("\r\n"); - - #line 55 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 55 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 55 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(operation.HasResultDescription){ - - #line default - #line hidden - this.Write(" * @return "); - - #line 55 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription)); - - #line default - #line hidden - this.Write("\r\n"); - - #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(operation.IsDeprecated){ - - #line default - #line hidden - this.Write(" * @deprecated\r\n"); - - #line 57 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" */\r\n"); - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" "); - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameLower)); - - #line default - #line hidden - this.Write("("); - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -foreach(var parameter in operation.Parameters){ - - #line default - #line hidden - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); - - #line default - #line hidden - this.Write(": "); - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type)); - - #line default - #line hidden - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(!parameter.IsLast){ - - #line default - #line hidden - this.Write(", "); - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write("): Promise<"); - - #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); - - #line default - #line hidden - this.Write("> {\r\n "); - - #line 59 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2))); - - #line default - #line hidden - this.Write("\r\n\r\n"); - - #line 61 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(!operation.IsGetOrHead){ - - #line default - #line hidden - this.Write(" "); - - #line 62 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2))); - - #line default - #line hidden - this.Write("\r\n"); - - #line 63 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write("\r\n let options_ = {\r\n"); - - #line 66 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(!operation.IsGetOrHead){ - - #line default - #line hidden - this.Write(" body: content_,\r\n"); - - #line 68 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" method: \""); - - #line 69 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodUpper.ToUpperInvariant())); - - #line default - #line hidden - this.Write("\",\r\n headers: {\r\n"); - - #line 71 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -foreach(var parameter in operation.HeaderParameters){ - - #line default - #line hidden - this.Write(" \""); - - #line 72 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name)); - - #line default - #line hidden - this.Write("\": "); - - #line 72 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); - - #line default - #line hidden - this.Write(", \r\n"); - - #line 73 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 74 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(!operation.HasFormParameters){ - - #line default - #line hidden - this.Write(" \"Content-Type\": \""); - - #line 75 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes)); - - #line default - #line hidden - this.Write("; charset=UTF-8\", \r\n"); - - #line 76 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" \"Accept\": \""); - - #line 77 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces)); - - #line default - #line hidden - this.Write("; charset=UTF-8\"\r\n }\r\n };\r\n\r\n"); - - #line 81 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.UseTransformOptionsMethod){ - - #line default - #line hidden - this.Write(" return this.transformOptions(options_).then(transformedOptions_ => {\r\n " + - " return this.http.fetch(url_, transformedOptions_);\r\n }).then((re" + - "sponse) => {\r\n"); - - #line 85 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -}else{ - - #line default - #line hidden - this.Write(" return this.http.fetch(url_, options_).then((response) => {\r\n"); - - #line 87 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - - #line 88 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -if(Model.UseTransformResultMethod){ - - #line default - #line hidden - this.Write(" return this.transformResult(url_, response, (response) => this.proces" + - "s"); - - #line 89 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); - - #line default - #line hidden - this.Write("(response));\r\n"); - - #line 90 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -}else{ - - #line default - #line hidden - this.Write(" return this.process"); - - #line 91 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); - - #line default - #line hidden - this.Write("(response);\r\n"); - - #line 92 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write(" });\r\n }\r\n\r\n protected process"); - - #line 96 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); - - #line default - #line hidden - this.Write("(response: Response): Promise<"); - - #line 96 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); - - #line default - #line hidden - this.Write("> {\r\n return response.text().then((responseText) => {\r\n const s" + - "tatus = response.status; \r\n\r\n "); - - #line 100 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 3))); - - #line default - #line hidden - this.Write("\r\n });\r\n }\r\n"); - - #line 103 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - this.Write("\r\n "); - - #line 105 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderClientMethodsCode(Model, 1))); - - #line default - #line hidden - this.Write("\r\n}\r\n"); - - #line 107 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" -} - - #line default - #line hidden - return this.GenerationEnvironment.ToString(); - } - } - - #line default - #line hidden - #region Base class - /// - /// Base class for this transformation - /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "14.0.0.0")] - internal class FetchClientTemplateBase - { - #region Fields - private global::System.Text.StringBuilder generationEnvironmentField; - private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; - private global::System.Collections.Generic.List indentLengthsField; - private string currentIndentField = ""; - private bool endsWithNewline; - private global::System.Collections.Generic.IDictionary sessionField; - #endregion - #region Properties - /// - /// The string builder that generation-time code is using to assemble generated output - /// - protected System.Text.StringBuilder GenerationEnvironment - { - get - { - if ((this.generationEnvironmentField == null)) - { - this.generationEnvironmentField = new global::System.Text.StringBuilder(); - } - return this.generationEnvironmentField; - } - set - { - this.generationEnvironmentField = value; - } - } - /// - /// The error collection for the generation process - /// - public System.CodeDom.Compiler.CompilerErrorCollection Errors - { - get - { - if ((this.errorsField == null)) - { - this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); - } - return this.errorsField; - } - } - /// - /// A list of the lengths of each indent that was added with PushIndent - /// - private System.Collections.Generic.List indentLengths - { - get - { - if ((this.indentLengthsField == null)) - { - this.indentLengthsField = new global::System.Collections.Generic.List(); - } - return this.indentLengthsField; - } - } - /// - /// Gets the current indent we use when adding lines to the output - /// - public string CurrentIndent - { - get - { - return this.currentIndentField; - } - } - /// - /// Current transformation session - /// - public virtual global::System.Collections.Generic.IDictionary Session - { - get - { - return this.sessionField; - } - set - { - this.sessionField = value; - } - } - #endregion - #region Transform-time helpers - /// - /// Write text directly into the generated output - /// - public void Write(string textToAppend) - { - if (string.IsNullOrEmpty(textToAppend)) - { - return; - } - // If we're starting off, or if the previous text ended with a newline, - // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) - || this.endsWithNewline)) - { - this.GenerationEnvironment.Append(this.currentIndentField); - this.endsWithNewline = false; - } - // Check if the current text ends with a newline - if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) - { - this.endsWithNewline = true; - } - // This is an optimization. If the current indent is "", then we don't have to do any - // of the more complex stuff further down. - if ((this.currentIndentField.Length == 0)) - { - this.GenerationEnvironment.Append(textToAppend); - return; - } - // Everywhere there is a newline in the text, add an indent after it - textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); - // If the text ends with a newline, then we should strip off the indent added at the very end - // because the appropriate indent will be added when the next time Write() is called - if (this.endsWithNewline) - { - this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); - } - else - { - this.GenerationEnvironment.Append(textToAppend); - } - } - /// - /// Write text directly into the generated output - /// - public void WriteLine(string textToAppend) - { - this.Write(textToAppend); - this.GenerationEnvironment.AppendLine(); - this.endsWithNewline = true; - } - /// - /// Write formatted text directly into the generated output - /// - public void Write(string format, params object[] args) - { - this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); - } - /// - /// Write formatted text directly into the generated output - /// - public void WriteLine(string format, params object[] args) - { - this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); - } - /// - /// Raise an error - /// - public void Error(string message) - { - System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); - error.ErrorText = message; - this.Errors.Add(error); - } - /// - /// Raise a warning - /// - public void Warning(string message) - { - System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); - error.ErrorText = message; - error.IsWarning = true; - this.Errors.Add(error); - } - /// - /// Increase the indent - /// - public void PushIndent(string indent) - { - if ((indent == null)) - { - throw new global::System.ArgumentNullException("indent"); - } - this.currentIndentField = (this.currentIndentField + indent); - this.indentLengths.Add(indent.Length); - } - /// - /// Remove the last indent that was added with PushIndent - /// - public string PopIndent() - { - string returnValue = ""; - if ((this.indentLengths.Count > 0)) - { - int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; - this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); - if ((indentLength > 0)) - { - returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); - this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); - } - } - return returnValue; - } - /// - /// Remove any indentation - /// - public void ClearIndent() - { - this.indentLengths.Clear(); - this.currentIndentField = ""; - } - #endregion - #region ToString Helpers - /// - /// Utility class to produce culture-oriented representation of an object as a string. - /// - public class ToStringInstanceHelper - { - private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; - /// - /// Gets or sets format provider to be used by ToStringWithCulture method. - /// - public System.IFormatProvider FormatProvider - { - get - { - return this.formatProviderField ; - } - set - { - if ((value != null)) - { - this.formatProviderField = value; - } - } - } - /// - /// This is called from the compile/run appdomain to convert objects within an expression block to a string - /// - public string ToStringWithCulture(object objectToConvert) - { - if ((objectToConvert == null)) - { - throw new global::System.ArgumentNullException("objectToConvert"); - } - System.Type t = objectToConvert.GetType(); - System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { - typeof(System.IFormatProvider)}); - if ((method == null)) - { - return objectToConvert.ToString(); - } - else - { - return ((string)(method.Invoke(objectToConvert, new object[] { - this.formatProviderField }))); - } - } - } - private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); - /// - /// Helper to produce culture-oriented representation of an object as a string - /// - public ToStringInstanceHelper ToStringHelper - { - get - { - return this.toStringHelperField; - } - } - #endregion - } - #endregion -} +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version: 14.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace NSwag.CodeGeneration.TypeScript.Templates +{ + using NJsonSchema; + using CodeGeneration.TypeScript; + using System; + + /// + /// Class to produce the template output + /// + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "14.0.0.0")] + internal partial class FetchClientTemplate : FetchClientTemplateBase + { +#line hidden + /// + /// Create the template output + /// + public virtual string TransformText() + { + this.Write("\n"); + this.Write("\n"); + this.Write("\n\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.HasOperations){ + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.GenerateClientInterfaces){ + + #line default + #line hidden + this.Write("\nexport interface I"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); + + #line default + #line hidden + this.Write(" {\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +foreach(var operation in Model.Operations){ + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(operation.HasDocumentation){ + + #line default + #line hidden + this.Write(" /**\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(operation.HasSummary){ + + #line default + #line hidden + this.Write(" * "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary)); + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +foreach(var parameter in operation.Parameters){ + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(parameter.HasDescription){ + + #line default + #line hidden + this.Write(" * @"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); + + #line default + #line hidden + this.Write(" "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? "")); + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(operation.HasResultDescription){ + + #line default + #line hidden + this.Write(" * @return "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription)); + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(operation.IsDeprecated){ + + #line default + #line hidden + this.Write(" * @deprecated\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write(" */\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write(" "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameLower)); + + #line default + #line hidden + this.Write("("); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +foreach(var parameter in operation.Parameters){ + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); + + #line default + #line hidden + this.Write(": "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type)); + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(!parameter.IsLast){ + + #line default + #line hidden + this.Write(", "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("): Promise<"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); + + #line default + #line hidden + this.Write(">;\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("}\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.UseAureliaHttpInjection){ + + #line default + #line hidden + this.Write("\n@inject(String, HttpClient)\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\nexport class "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); + + #line default + #line hidden + this.Write(" "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.HasClientBaseClass){ + + #line default + #line hidden + this.Write("extends "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClientBaseClass)); + + #line default + #line hidden + this.Write(" "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.GenerateClientInterfaces){ + + #line default + #line hidden + this.Write("implements I"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); + + #line default + #line hidden + this.Write(" "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("{\n private baseUrl: string; \n private http: { fetch(url: RequestInfo, init?" + + ": RequestInit): Promise };\n protected jsonParseReviver: "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.SupportsStrictNullChecks){ + + #line default + #line hidden + this.Write("((key: string, value: any) => any) | undefined"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +}else{ + + #line default + #line hidden + this.Write("(key: string, value: any) => any"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write(" = undefined;\n\n constructor(baseUrl?: string, http?: { fetch(url: RequestInfo," + + " init?: RequestInit): Promise }) {\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.HasClientBaseClass){ + + #line default + #line hidden + this.Write("\n super();\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n this.baseUrl = baseUrl ? baseUrl : \"\";\n this.http = http ? http :" + + " window;\n }\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.HasExtensionClass && !Model.HasClientBaseClass){ + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + if(Model.UseTransformOptionsMethod){ + + #line default + #line hidden + this.Write("\n\n protected transformOptions(options: RequestInit) {\n return Promise.r" + + "esolve(options); \n }\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + } + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + if(Model.UseTransformResultMethod){ + + #line default + #line hidden + this.Write("\n\n protected transformResult(url: string, response: Response, processor: (resp" + + "onse: Response) => any) {\n return processor(response);\n }\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + } + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +foreach(var operation in Model.Operations){ + + #line default + #line hidden + this.Write("\n\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(operation.HasDocumentation){ + + #line default + #line hidden + this.Write(" /**\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(operation.HasSummary){ + + #line default + #line hidden + this.Write(" * "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary)); + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +foreach(var parameter in operation.Parameters){ + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(parameter.HasDescription){ + + #line default + #line hidden + this.Write(" * @"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); + + #line default + #line hidden + this.Write(" "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? "")); + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(operation.HasResultDescription){ + + #line default + #line hidden + this.Write(" * @return "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription)); + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(operation.IsDeprecated){ + + #line default + #line hidden + this.Write(" * @deprecated\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write(" */\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write(" "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameLower)); + + #line default + #line hidden + this.Write("("); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +foreach(var parameter in operation.Parameters){ + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); + + #line default + #line hidden + this.Write(": "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type)); + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(!parameter.IsLast){ + + #line default + #line hidden + this.Write(", "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("): Promise<"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); + + #line default + #line hidden + this.Write("> {\n "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2))); + + #line default + #line hidden + this.Write("\n\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(!operation.IsGetOrHead){ + + #line default + #line hidden + this.Write("\n "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2))); + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n\n let options_ = {\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(!operation.IsGetOrHead){ + + #line default + #line hidden + this.Write("\n body: content_,\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n method: \""); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodUpper.ToUpperInvariant())); + + #line default + #line hidden + this.Write("\",\n headers: {\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +foreach(var parameter in operation.HeaderParameters){ + + #line default + #line hidden + this.Write("\n \""); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name)); + + #line default + #line hidden + this.Write("\": "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); + + #line default + #line hidden + this.Write(", \n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(!operation.HasFormParameters){ + + #line default + #line hidden + this.Write("\n \"Content-Type\": \""); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes)); + + #line default + #line hidden + this.Write("; charset=UTF-8\", \n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n \"Accept\": \""); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces)); + + #line default + #line hidden + this.Write("; charset=UTF-8\"\n }\n };\n\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.UseTransformOptionsMethod){ + + #line default + #line hidden + this.Write("\n return this.transformOptions(options_).then(transformedOptions_ => {\n " + + " return this.http.fetch(url_, transformedOptions_);\n }).then((res" + + "ponse: Response) => {\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +}else{ + + #line default + #line hidden + this.Write("\n return this.http.fetch(url_, options_).then((response: Response) => {\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +if(Model.UseTransformResultMethod){ + + #line default + #line hidden + this.Write("\n return this.transformResult(url_, response, (response: Response) => " + + "this.process"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); + + #line default + #line hidden + this.Write("(response));\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +}else{ + + #line default + #line hidden + this.Write("\n return this.process"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); + + #line default + #line hidden + this.Write("(response);\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n });\n }\n\n protected process"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); + + #line default + #line hidden + this.Write("(response: Response): Promise<"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); + + #line default + #line hidden + this.Write("> {\n return response.text().then((responseText) => {\n const sta" + + "tus = response.status; \n\n "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 3))); + + #line default + #line hidden + this.Write("\n });\n }\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + this.Write("\n\n "); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderClientMethodsCode(Model, 1))); + + #line default + #line hidden + this.Write("\n}\n"); + + #line 1 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt" +} + + #line default + #line hidden + return this.GenerationEnvironment.ToString(); + } + } + + #line default + #line hidden + #region Base class + /// + /// Base class for this transformation + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "14.0.0.0")] + internal class FetchClientTemplateBase + { + #region Fields + private global::System.Text.StringBuilder generationEnvironmentField; + private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; + private global::System.Collections.Generic.List indentLengthsField; + private string currentIndentField = ""; + private bool endsWithNewline; + private global::System.Collections.Generic.IDictionary sessionField; + #endregion + #region Properties + /// + /// The string builder that generation-time code is using to assemble generated output + /// + protected System.Text.StringBuilder GenerationEnvironment + { + get + { + if ((this.generationEnvironmentField == null)) + { + this.generationEnvironmentField = new global::System.Text.StringBuilder(); + } + return this.generationEnvironmentField; + } + set + { + this.generationEnvironmentField = value; + } + } + /// + /// The error collection for the generation process + /// + public System.CodeDom.Compiler.CompilerErrorCollection Errors + { + get + { + if ((this.errorsField == null)) + { + this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); + } + return this.errorsField; + } + } + /// + /// A list of the lengths of each indent that was added with PushIndent + /// + private System.Collections.Generic.List indentLengths + { + get + { + if ((this.indentLengthsField == null)) + { + this.indentLengthsField = new global::System.Collections.Generic.List(); + } + return this.indentLengthsField; + } + } + /// + /// Gets the current indent we use when adding lines to the output + /// + public string CurrentIndent + { + get + { + return this.currentIndentField; + } + } + /// + /// Current transformation session + /// + public virtual global::System.Collections.Generic.IDictionary Session + { + get + { + return this.sessionField; + } + set + { + this.sessionField = value; + } + } + #endregion + #region Transform-time helpers + /// + /// Write text directly into the generated output + /// + public void Write(string textToAppend) + { + if (string.IsNullOrEmpty(textToAppend)) + { + return; + } + // If we're starting off, or if the previous text ended with a newline, + // we have to append the current indent first. + if (((this.GenerationEnvironment.Length == 0) + || this.endsWithNewline)) + { + this.GenerationEnvironment.Append(this.currentIndentField); + this.endsWithNewline = false; + } + // Check if the current text ends with a newline + if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) + { + this.endsWithNewline = true; + } + // This is an optimization. If the current indent is "", then we don't have to do any + // of the more complex stuff further down. + if ((this.currentIndentField.Length == 0)) + { + this.GenerationEnvironment.Append(textToAppend); + return; + } + // Everywhere there is a newline in the text, add an indent after it + textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); + // If the text ends with a newline, then we should strip off the indent added at the very end + // because the appropriate indent will be added when the next time Write() is called + if (this.endsWithNewline) + { + this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); + } + else + { + this.GenerationEnvironment.Append(textToAppend); + } + } + /// + /// Write text directly into the generated output + /// + public void WriteLine(string textToAppend) + { + this.Write(textToAppend); + this.GenerationEnvironment.AppendLine(); + this.endsWithNewline = true; + } + /// + /// Write formatted text directly into the generated output + /// + public void Write(string format, params object[] args) + { + this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Write formatted text directly into the generated output + /// + public void WriteLine(string format, params object[] args) + { + this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + } + /// + /// Raise an error + /// + public void Error(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + this.Errors.Add(error); + } + /// + /// Raise a warning + /// + public void Warning(string message) + { + System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); + error.ErrorText = message; + error.IsWarning = true; + this.Errors.Add(error); + } + /// + /// Increase the indent + /// + public void PushIndent(string indent) + { + if ((indent == null)) + { + throw new global::System.ArgumentNullException("indent"); + } + this.currentIndentField = (this.currentIndentField + indent); + this.indentLengths.Add(indent.Length); + } + /// + /// Remove the last indent that was added with PushIndent + /// + public string PopIndent() + { + string returnValue = ""; + if ((this.indentLengths.Count > 0)) + { + int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; + this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); + if ((indentLength > 0)) + { + returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); + this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); + } + } + return returnValue; + } + /// + /// Remove any indentation + /// + public void ClearIndent() + { + this.indentLengths.Clear(); + this.currentIndentField = ""; + } + #endregion + #region ToString Helpers + /// + /// Utility class to produce culture-oriented representation of an object as a string. + /// + public class ToStringInstanceHelper + { + private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; + /// + /// Gets or sets format provider to be used by ToStringWithCulture method. + /// + public System.IFormatProvider FormatProvider + { + get + { + return this.formatProviderField ; + } + set + { + if ((value != null)) + { + this.formatProviderField = value; + } + } + } + /// + /// This is called from the compile/run appdomain to convert objects within an expression block to a string + /// + public string ToStringWithCulture(object objectToConvert) + { + if ((objectToConvert == null)) + { + throw new global::System.ArgumentNullException("objectToConvert"); + } + System.Type t = objectToConvert.GetType(); + System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { + typeof(System.IFormatProvider)}); + if ((method == null)) + { + return objectToConvert.ToString(); + } + else + { + return ((string)(method.Invoke(objectToConvert, new object[] { + this.formatProviderField }))); + } + } + } + private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); + /// + /// Helper to produce culture-oriented representation of an object as a string + /// + public ToStringInstanceHelper ToStringHelper + { + get + { + return this.toStringHelperField; + } + } + #endregion + } + #endregion +} diff --git a/src/NSwag.CodeGeneration.TypeScript/packages.config b/src/NSwag.CodeGeneration.TypeScript/packages.config index e6e575f61e..2a8960ba97 100644 --- a/src/NSwag.CodeGeneration.TypeScript/packages.config +++ b/src/NSwag.CodeGeneration.TypeScript/packages.config @@ -1,7 +1,7 @@  - - - + + + \ No newline at end of file diff --git a/src/NSwag.CodeGeneration/Models/OperationModelBase.cs b/src/NSwag.CodeGeneration/Models/OperationModelBase.cs index 05fa258421..c08284920c 100644 --- a/src/NSwag.CodeGeneration/Models/OperationModelBase.cs +++ b/src/NSwag.CodeGeneration/Models/OperationModelBase.cs @@ -110,7 +110,7 @@ public string UnwrappedResultType get { var response = GetSuccessResponse(); - if (response?.Schema == null) + if (response?.ActualResponseSchema == null) return "void"; var isNullable = response.IsNullable(_settings.CodeGeneratorSettings.NullHandling); diff --git a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj index 08da3ac087..a9ccb15f65 100644 --- a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj +++ b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj @@ -44,12 +44,12 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll True diff --git a/src/NSwag.CodeGeneration/packages.config b/src/NSwag.CodeGeneration/packages.config index 1c736902bc..da9c1a1d3d 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.Commands/NSwag.Commands.csproj b/src/NSwag.Commands/NSwag.Commands.csproj index fd873f6c22..7bca3ebb9f 100644 --- a/src/NSwag.Commands/NSwag.Commands.csproj +++ b/src/NSwag.Commands/NSwag.Commands.csproj @@ -106,20 +106,20 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll True - - ..\packages\NJsonSchema.CodeGeneration.CSharp.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll + + ..\packages\NJsonSchema.CodeGeneration.CSharp.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll True - - ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll + + ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll True diff --git a/src/NSwag.Commands/packages.config b/src/NSwag.Commands/packages.config index 531970f4ba..160d716e74 100644 --- a/src/NSwag.Commands/packages.config +++ b/src/NSwag.Commands/packages.config @@ -2,8 +2,8 @@ - - - - + + + + \ No newline at end of file diff --git a/src/NSwag.Console/NSwag.Console.csproj b/src/NSwag.Console/NSwag.Console.csproj index e79b7dd622..7f1f2325ca 100644 --- a/src/NSwag.Console/NSwag.Console.csproj +++ b/src/NSwag.Console/NSwag.Console.csproj @@ -71,20 +71,20 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll True - - ..\packages\NJsonSchema.CodeGeneration.CSharp.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll + + ..\packages\NJsonSchema.CodeGeneration.CSharp.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll True - - ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll + + ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll True diff --git a/src/NSwag.Console/packages.config b/src/NSwag.Console/packages.config index 9d55ee6598..5e8a2ff6a4 100644 --- a/src/NSwag.Console/packages.config +++ b/src/NSwag.Console/packages.config @@ -2,8 +2,8 @@ - - - - + + + + \ No newline at end of file diff --git a/src/NSwag.Core/NSwag.Core.csproj b/src/NSwag.Core/NSwag.Core.csproj index 0732c648ec..443d38da34 100644 --- a/src/NSwag.Core/NSwag.Core.csproj +++ b/src/NSwag.Core/NSwag.Core.csproj @@ -67,8 +67,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll True diff --git a/src/NSwag.Core/packages.config b/src/NSwag.Core/packages.config index f8440d83f0..ea1d4c5d49 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.OwinWeb/NSwag.Demo.OwinWeb.csproj b/src/NSwag.Demo.OwinWeb/NSwag.Demo.OwinWeb.csproj index 18f242b219..f530dde0a7 100644 --- a/src/NSwag.Demo.OwinWeb/NSwag.Demo.OwinWeb.csproj +++ b/src/NSwag.Demo.OwinWeb/NSwag.Demo.OwinWeb.csproj @@ -54,8 +54,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True diff --git a/src/NSwag.Demo.OwinWeb/Web.config b/src/NSwag.Demo.OwinWeb/Web.config index c70f363860..5cc08c80e9 100644 --- a/src/NSwag.Demo.OwinWeb/Web.config +++ b/src/NSwag.Demo.OwinWeb/Web.config @@ -25,7 +25,7 @@ - + diff --git a/src/NSwag.Demo.OwinWeb/packages.config b/src/NSwag.Demo.OwinWeb/packages.config index ef7c94e9f1..af3d788d87 100644 --- a/src/NSwag.Demo.OwinWeb/packages.config +++ b/src/NSwag.Demo.OwinWeb/packages.config @@ -6,6 +6,6 @@ - + \ No newline at end of file diff --git a/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj b/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj index d2ba449f90..b1b95daaff 100644 --- a/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj +++ b/src/NSwag.Demo.Web/NSwag.Demo.Web.csproj @@ -63,8 +63,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True diff --git a/src/NSwag.Demo.Web/Web.config b/src/NSwag.Demo.Web/Web.config index ce0a606528..9f8bb2c17b 100644 --- a/src/NSwag.Demo.Web/Web.config +++ b/src/NSwag.Demo.Web/Web.config @@ -43,7 +43,7 @@ - + diff --git a/src/NSwag.Demo.Web/packages.config b/src/NSwag.Demo.Web/packages.config index 706744c578..3252171fd1 100644 --- a/src/NSwag.Demo.Web/packages.config +++ b/src/NSwag.Demo.Web/packages.config @@ -14,6 +14,6 @@ - + \ No newline at end of file diff --git a/src/NSwag.Integration.WebAPI/NSwag.Integration.WebAPI.csproj b/src/NSwag.Integration.WebAPI/NSwag.Integration.WebAPI.csproj index 62bc4932cd..1e920fe355 100644 --- a/src/NSwag.Integration.WebAPI/NSwag.Integration.WebAPI.csproj +++ b/src/NSwag.Integration.WebAPI/NSwag.Integration.WebAPI.csproj @@ -62,8 +62,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True diff --git a/src/NSwag.Integration.WebAPI/Web.config b/src/NSwag.Integration.WebAPI/Web.config index 381b4de523..4c651b15fb 100644 --- a/src/NSwag.Integration.WebAPI/Web.config +++ b/src/NSwag.Integration.WebAPI/Web.config @@ -40,7 +40,7 @@ - + diff --git a/src/NSwag.Integration.WebAPI/packages.config b/src/NSwag.Integration.WebAPI/packages.config index a492ac33da..e2766026ec 100644 --- a/src/NSwag.Integration.WebAPI/packages.config +++ b/src/NSwag.Integration.WebAPI/packages.config @@ -9,6 +9,6 @@ - + \ No newline at end of file diff --git a/src/NSwag.SwaggerGeneration.WebApi.Tests/NSwag.SwaggerGeneration.WebApi.Tests.csproj b/src/NSwag.SwaggerGeneration.WebApi.Tests/NSwag.SwaggerGeneration.WebApi.Tests.csproj index 37a431cb02..c993b116b2 100644 --- a/src/NSwag.SwaggerGeneration.WebApi.Tests/NSwag.SwaggerGeneration.WebApi.Tests.csproj +++ b/src/NSwag.SwaggerGeneration.WebApi.Tests/NSwag.SwaggerGeneration.WebApi.Tests.csproj @@ -41,8 +41,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True diff --git a/src/NSwag.SwaggerGeneration.WebApi.Tests/app.config b/src/NSwag.SwaggerGeneration.WebApi.Tests/app.config index 1cf22c2076..8f44a16572 100644 --- a/src/NSwag.SwaggerGeneration.WebApi.Tests/app.config +++ b/src/NSwag.SwaggerGeneration.WebApi.Tests/app.config @@ -16,7 +16,7 @@ - + diff --git a/src/NSwag.SwaggerGeneration.WebApi.Tests/packages.config b/src/NSwag.SwaggerGeneration.WebApi.Tests/packages.config index edff7f9598..9ae70adbd6 100644 --- a/src/NSwag.SwaggerGeneration.WebApi.Tests/packages.config +++ b/src/NSwag.SwaggerGeneration.WebApi.Tests/packages.config @@ -8,7 +8,7 @@ - + diff --git a/src/NSwag.SwaggerGeneration.WebApi/NSwag.SwaggerGeneration.WebApi.csproj b/src/NSwag.SwaggerGeneration.WebApi/NSwag.SwaggerGeneration.WebApi.csproj index d26ce58364..3ec1ff74ac 100644 --- a/src/NSwag.SwaggerGeneration.WebApi/NSwag.SwaggerGeneration.WebApi.csproj +++ b/src/NSwag.SwaggerGeneration.WebApi/NSwag.SwaggerGeneration.WebApi.csproj @@ -70,8 +70,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll True diff --git a/src/NSwag.SwaggerGeneration.WebApi/packages.config b/src/NSwag.SwaggerGeneration.WebApi/packages.config index f8440d83f0..ea1d4c5d49 100644 --- a/src/NSwag.SwaggerGeneration.WebApi/packages.config +++ b/src/NSwag.SwaggerGeneration.WebApi/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/NSwag.SwaggerGeneration/NSwag.SwaggerGeneration.csproj b/src/NSwag.SwaggerGeneration/NSwag.SwaggerGeneration.csproj index aa473e2f80..d824f393a3 100644 --- a/src/NSwag.SwaggerGeneration/NSwag.SwaggerGeneration.csproj +++ b/src/NSwag.SwaggerGeneration/NSwag.SwaggerGeneration.csproj @@ -66,8 +66,8 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.dll True diff --git a/src/NSwag.SwaggerGeneration/packages.config b/src/NSwag.SwaggerGeneration/packages.config index f8440d83f0..ea1d4c5d49 100644 --- a/src/NSwag.SwaggerGeneration/packages.config +++ b/src/NSwag.SwaggerGeneration/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/NSwag.Tests/NSwag.Tests.csproj b/src/NSwag.Tests/NSwag.Tests.csproj index 6f5d6055e4..47ec7da45e 100644 --- a/src/NSwag.Tests/NSwag.Tests.csproj +++ b/src/NSwag.Tests/NSwag.Tests.csproj @@ -60,12 +60,12 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll True diff --git a/src/NSwag.Tests/app.config b/src/NSwag.Tests/app.config index 58c0883fd1..fcd048eae7 100644 --- a/src/NSwag.Tests/app.config +++ b/src/NSwag.Tests/app.config @@ -8,11 +8,11 @@ - + - + diff --git a/src/NSwag.Tests/packages.config b/src/NSwag.Tests/packages.config index b12556b6dd..ff3b50b575 100644 --- a/src/NSwag.Tests/packages.config +++ b/src/NSwag.Tests/packages.config @@ -3,6 +3,6 @@ - - + + \ No newline at end of file diff --git a/src/NSwagStudio/NSwagStudio.csproj b/src/NSwagStudio/NSwagStudio.csproj index 5e1fe57b13..4634b3df57 100644 --- a/src/NSwagStudio/NSwagStudio.csproj +++ b/src/NSwagStudio/NSwagStudio.csproj @@ -96,20 +96,20 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\NJsonSchema.8.3.6252.27806\lib\net45\NJsonSchema.dll + + ..\packages\NJsonSchema.8.4.6254.24648\lib\net45\NJsonSchema.dll True - - ..\packages\NJsonSchema.CodeGeneration.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll + + ..\packages\NJsonSchema.CodeGeneration.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.dll True - - ..\packages\NJsonSchema.CodeGeneration.CSharp.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll + + ..\packages\NJsonSchema.CodeGeneration.CSharp.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.CSharp.dll True - - ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.3.6252.27823\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll + + ..\packages\NJsonSchema.CodeGeneration.TypeScript.8.4.6254.24670\lib\portable45-net45+win8+wp8+wpa81\NJsonSchema.CodeGeneration.TypeScript.dll True diff --git a/src/NSwagStudio/packages.config b/src/NSwagStudio/packages.config index 793be6ae49..f67bd6a569 100644 --- a/src/NSwagStudio/packages.config +++ b/src/NSwagStudio/packages.config @@ -7,8 +7,8 @@ - - - - + + + + \ No newline at end of file