/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 2 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {\r\n"); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden #line 6 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.IsOptional) { #line default #line hidden this.Write("?"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(": "); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.TypePostfix)); #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden this.Write(" = "); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(";\r\n"); #line 10 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 11 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasIndexerProperty) { #line default #line hidden this.Write("\r\n [key: string]: "); #line 13 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.IndexerPropertyValueType)); #line default #line hidden this.Write("; \r\n"); #line 14 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 15 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write("\r\n protected _discriminator: string;\r\n"); #line 18 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 20 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.GenerateConstructorInterface || Model.HasBaseDiscriminator) { #line default #line hidden this.Write(" constructor("); #line 21 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.GenerateConstructorInterface) { #line default #line hidden this.Write("data?: I"); #line 21 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 21 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(") {\r\n"); #line 22 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super("); #line 23 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.GenerateConstructorInterface) { #line default #line hidden this.Write("data"); #line 23 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(");\r\n"); #line 24 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } else if (Model.GenerateConstructorInterface) { #line default #line hidden this.Write(" if (data) {\r\n for (var property in data) {\r\n if" + " (data.hasOwnProperty(property))\r\n (<any>this)[property] = (<" + "any>data)[property];\r\n }\r\n }\r\n"); #line 31 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 32 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden this.Write(" this._discriminator = \""); #line 33 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DiscriminatorName)); #line default #line hidden this.Write("\";\r\n"); #line 34 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n"); #line 36 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n init(data?: any"); #line 38 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write(", _mappings?: any"); #line 38 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(") {\r\n"); #line 39 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super.init(data);\r\n"); #line 41 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" if (data) {\r\n"); #line 43 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasIndexerProperty) { #line default #line hidden this.Write(" for (var property in data) {\r\n if (data.hasOwnProperty" + "(property))\r\n this[property] = data[property];\r\n }" + "\r\n"); #line 48 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 49 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 50 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToClassCode, 3))); #line default #line hidden this.Write("\r\n"); #line 51 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n\r\n static fromJS(data: any"); #line 55 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write(", _mappings?: any"); #line 55 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("): "); #line 55 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(" {\r\n"); #line 56 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden #line 57 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden #line 58 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 59 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 59 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\")\r\n return createInstance<"); #line 60 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write(">(data, _mappings, "); #line 60 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write(");\r\n"); #line 61 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return createInstance<"); #line 62 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(">(data, _mappings, "); #line 62 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(");\r\n"); #line 63 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } else { #line default #line hidden this.Write(" return createInstance<"); #line 64 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(">(data, _mappings, "); #line 64 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(");\r\n"); #line 65 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 66 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } else { #line default #line hidden #line 67 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden #line 68 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 69 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 69 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\") {\r\n let result = new "); #line 70 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("();\r\n result.init(data);\r\n return result;\r\n }\r\n"); #line 74 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 75 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" let result = new "); #line 76 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("();\r\n result.init(data);\r\n return result;\r\n"); #line 79 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n\r\n toJSON(data?: any) {\r\n data = typeof data === \'object\' ? data" + " : {};\r\n"); #line 84 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasIndexerProperty) { #line default #line hidden this.Write(" for (var property in this) {\r\n if (this.hasOwnProperty(propert" + "y))\r\n data[property] = this[property];\r\n }\r\n"); #line 89 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 90 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" data[\""); #line 91 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] = this._discriminator; \r\n"); #line 92 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 93 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 94 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToJavaScriptCode, 2))); #line default #line hidden this.Write("\r\n"); #line 95 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 96 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super.toJSON(data);\r\n"); #line 98 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return data; \r\n }\r\n"); #line 101 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.GenerateCloneMethod) { #line default #line hidden this.Write("\r\n clone() {\r\n const json = this.toJSON();\r\n let result = new "); #line 105 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("();\r\n result.init(json);\r\n return result;\r\n }\r\n"); #line 109 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("}\r\n"); #line 111 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.GenerateConstructorInterface) { #line default #line hidden this.Write("\r\n"); #line 113 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 114 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 115 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("export interface I"); #line 116 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 116 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.InterfaceInheritance)); #line default #line hidden this.Write(" {\r\n"); #line 117 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden #line 118 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 119 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 120 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 121 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden #line 121 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.IsOptional) { #line default #line hidden this.Write("?"); #line 121 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(": "); #line 121 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden #line 121 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.TypePostfix)); #line default #line hidden this.Write(";\r\n"); #line 122 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 123 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasIndexerProperty) { #line default #line hidden this.Write("\r\n [key: string]: "); #line 125 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.IndexerPropertyValueType)); #line default #line hidden this.Write("; \r\n"); #line 126 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("}\r\n"); #line 128 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("//----------------------\r\n// <auto-generated>\r\n// Generated using the NSwag t" + "oolchain v"); #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Toolchain)); #line default #line hidden this.Write(@" (http://NSwag.org) // </auto-generated> //---------------------- using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Globalization; using System.Net; using System.Net.Http; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using System.Text; using Newtonsoft.Json; using Newtonsoft.Json.Converters; "); #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" foreach (var usage in Model.NamespaceUsages) { #line default #line hidden this.Write("using "); #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(usage)); #line default #line hidden this.Write(";\r\n"); #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("\r\nnamespace "); #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Namespace)); #line default #line hidden this.Write("\r\n{\r\n "); #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Clients, 1))); #line default #line hidden this.Write("\r\n\r\n "); #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Classes, 1))); #line default #line hidden this.Write("\r\n}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 4 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 4 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 5 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 5 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 5 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {\r\n"); #line 6 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden #line 7 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 7 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write(" = "); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsArray) { #line default #line hidden this.Write("ko.observableArray<"); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.ArrayItemType)); #line default #line hidden this.Write(">("); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write("ko.observable<"); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden this.Write(">("); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 8 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(";\r\n"); #line 9 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 11 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" protected _discriminator: string;\r\n"); #line 13 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n constructor(data?: any) {\r\n"); #line 16 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super(data);\r\n"); #line 18 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 19 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden this.Write(" this._discriminator = \""); #line 20 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DiscriminatorName)); #line default #line hidden this.Write("\";\r\n"); #line 21 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" if (data !== undefined) {\r\n"); #line 23 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" var "); #line 24 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_: "); #line 24 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden this.Write(" = null; \r\n "); #line 25 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToClassCode, 3))); #line default #line hidden this.Write("\r\n this."); #line 26 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("("); #line 26 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_);\r\n\r\n"); #line 28 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n\r\n static fromJS(data: any): "); #line 31 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write(" {\r\n"); #line 32 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 34 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 34 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\")\r\n return new "); #line 35 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("(data);\r\n"); #line 36 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" return new "); #line 37 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\r\n"); #line 38 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write(" return new "); #line 39 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\r\n"); #line 40 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n\r\n toJS(data?: any) {\r\n data = data === undefined ? {} : data;\r\n" + ""); #line 45 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" data[\""); #line 46 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] = this._discriminator; \r\n"); #line 47 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 48 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" var "); #line 49 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_ = this."); #line 49 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("(); \r\n "); #line 50 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToJavaScriptCode, 2))); #line default #line hidden this.Write("\r\n\r\n"); #line 52 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } if (Model.HasInheritance) { #line default #line hidden this.Write(" super.toJS(data);\r\n"); #line 54 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" return data; \r\n }\r\n\r\n toJSON() {\r\n return JSON.stringify(thi" + "s.toJS());\r\n }\r\n\r\n clone() {\r\n var json = this.toJSON();\r\n r" + "eturn new "); #line 64 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(JSON.parse(json));\r\n }\r\n}"); return(this.GenerationEnvironment.ToString()); }
/// <summary>Gets the JSON exception converter code.</summary> /// <returns>The code.</returns> public static string GetJsonExceptionConverterCode(int tabCount) { return(ConversionUtilities.Tab(new JsonExceptionConverterTemplate().TransformText(), tabCount)); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 3 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write("let mappings: { source: any, target: any }[] = [];\r\n"); #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" foreach (var response in Model.Responses) { #line default #line hidden this.Write("if (status === "); #line 7 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(") {\r\n"); #line 8 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (response.IsFile && !response.IsJQuery) { #line default #line hidden #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (response.IsAngularJS) { #line default #line hidden this.Write(" return new Blob([response], { type: \"application/octet-stream\" });\r\n"); #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" return response.blob();\r\n"); #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden #line 15 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (response.HasType) { #line default #line hidden this.Write(" let result"); #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(": "); #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.Type)); #line default #line hidden #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.SupportsStrictNullChecks) { #line default #line hidden this.Write(" | null"); #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write(" = null;\r\n"); #line 17 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (response.IsDate) { #line default #line hidden this.Write(" result"); #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = new Date(responseText);\r\n"); #line 19 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { if (response.UseDtoClass) { #line default #line hidden this.Write(" let resultData"); #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = responseText === \"\" ? null : "); #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write("jp"); #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write("JSON.parse"); #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write("(responseText, this.jsonParseReviver);\r\n "); #line 22 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(response.DataConversionCode, 1))); #line default #line hidden this.Write("\r\n"); #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" result"); #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = responseText === \"\" ? null : <"); #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.Type)); #line default #line hidden this.Write(">"); #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write("jp"); #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write("JSON.parse"); #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write("(responseText, this.jsonParseReviver);\r\n"); #line 25 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } } if (response.IsSuccess) { #line default #line hidden this.Write(" return result"); #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(";\r\n"); #line 29 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" this.throwException(\"A server error occurred.\", status, responseText, result"); #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(");\r\n"); #line 31 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } } else if (response.IsSuccess) { #line default #line hidden this.Write(" return null;\r\n"); #line 34 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" this.throwException(\"A server error occurred.\", status, responseText);\r\n"); #line 36 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden #line 37 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write("} else "); #line 38 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } if (Model.HasDefaultResponse) { #line default #line hidden this.Write("{\r\n"); #line 40 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.DefaultResponse.IsFile && !Model.DefaultResponse.IsJQuery) { #line default #line hidden #line 41 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.DefaultResponse.IsAngularJS) { #line default #line hidden this.Write(" return new Blob([response], { type: \"application/octet-stream\" });\r\n"); #line 43 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" return response.blob();\r\n"); #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.DefaultResponse.HasType) { #line default #line hidden this.Write(" let result: "); #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DefaultResponse.Type)); #line default #line hidden #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.SupportsStrictNullChecks) { #line default #line hidden this.Write(" | null"); #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write(" = null;\r\n"); #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.DefaultResponse.IsDate) { #line default #line hidden this.Write(" result = new Date(responseText);\r\n"); #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { if (Model.DefaultResponse.UseDtoClass) { #line default #line hidden this.Write(" let resultData = responseText === \"\" ? null : "); #line 53 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write("jp"); #line 53 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write("JSON.parse"); #line 53 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write("(responseText, this.jsonParseReviver);\r\n "); #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.DefaultResponse.DataConversionCode, 1))); #line default #line hidden this.Write("\r\n"); #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" result = responseText === \"\" ? null : <"); #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DefaultResponse.Type)); #line default #line hidden this.Write(">"); #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write("jp"); #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write("JSON.parse"); #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write("(responseText, this.jsonParseReviver);\r\n"); #line 57 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } } if (!Model.HasSuccessResponse) { #line default #line hidden this.Write(" return result;\r\n"); #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" this.throwException(\"A server error occurred.\", status, responseText, result)" + ";\r\n"); #line 63 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } } else if (!Model.HasSuccessResponse) { #line default #line hidden this.Write(" return null;\r\n"); #line 66 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" this.throwException(\"A server error occurred.\", status, responseText);\r\n"); #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden #line 69 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write("}"); #line 70 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write("if (status !== 200 && status !== 204) {\r\n this.throwException(\"An unexpected s" + "erver error occurred.\", status, responseText);\r\n}\r\nreturn null;\r\n"); #line 77 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {"); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" \r\n"); #line 6 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 6 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write(": "); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden this.Write(" = "); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(";"); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n\r\n constructor(data?: any) {\r\n"); #line 11 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super(data);\r\n"); #line 13 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" if (data !== undefined) {\r\n"); #line 15 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 16 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.DataConversionCode, 3))); #line default #line hidden this.Write("\r\n"); #line 17 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n\r\n toJS(data?: any) {\r\n data = data === undefined ? {" + "} : data;\r\n"); #line 23 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 24 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.DataBackConversionCode, 2))); #line default #line hidden this.Write("\r\n"); #line 25 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } if (Model.HasInheritance) { #line default #line hidden this.Write(" super.toJS(data);\r\n"); #line 27 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return data; \r\n }\r\n\r\n toJSON() {\r\n return JSON.stringify(thi" + "s.toJS());\r\n }\r\n\r\n clone() {\r\n var json = this.toJSON();\r\n r" + "eturn new "); #line 37 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.RealClass)); #line default #line hidden this.Write("(JSON.parse(json));\r\n }\r\n}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 3 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 3 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 4 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 4 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 4 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {\r\n"); #line 5 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden #line 6 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 7 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 8 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write(" = "); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsArray) { #line default #line hidden this.Write("ko.observableArray<"); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.ArrayItemType)); #line default #line hidden this.Write(">("); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write("ko.observable<"); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.TypePostfix)); #line default #line hidden this.Write(">("); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 9 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(";\r\n"); #line 10 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 12 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write("\r\n protected _discriminator: string;\r\n"); #line 15 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 17 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden this.Write(" constructor() {\r\n"); #line 19 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super();\r\n"); #line 21 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" this._discriminator = \""); #line 22 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DiscriminatorName)); #line default #line hidden this.Write("\";\r\n }\r\n"); #line 24 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n init(data?: any"); #line 26 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write(", _mappings?: any"); #line 26 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(") {\r\n"); #line 27 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super.init(data);\r\n"); #line 29 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" if (data !== undefined) {\r\n"); #line 31 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" var "); #line 32 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_: any; \r\n "); #line 33 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToClassCode, 3))); #line default #line hidden this.Write("\r\n this."); #line 34 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("("); #line 34 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_);\r\n\r\n"); #line 36 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n\r\n static fromJS(data: any"); #line 40 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write(", _mappings?: any"); #line 40 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("): "); #line 40 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(" {\r\n"); #line 41 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden #line 42 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden #line 43 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 44 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 44 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\")\r\n return createInstance<"); #line 45 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write(">(data, _mappings, "); #line 45 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write(");\r\n"); #line 46 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" return createInstance<"); #line 47 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(">(data, _mappings, "); #line 47 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(");\r\n"); #line 48 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write(" return createInstance<"); #line 49 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(">(data, _mappings, "); #line 49 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(");\r\n"); #line 50 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 51 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden #line 52 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden #line 53 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 54 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 54 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\") {\r\n let result = new "); #line 55 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("();\r\n result.init(data);\r\n return result;\r\n }\r\n"); #line 59 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 60 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" let result = new "); #line 61 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("();\r\n result.init(data);\r\n return result;\r\n"); #line 64 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n\r\n toJSON(data?: any) {\r\n data = typeof data === \'object\' ? data" + " : {};\r\n"); #line 69 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" data[\""); #line 70 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] = this._discriminator; \r\n"); #line 71 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 72 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" let "); #line 73 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_: any = this."); #line 73 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("(); \r\n "); #line 74 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToJavaScriptCode, 2))); #line default #line hidden this.Write("\r\n\r\n"); #line 76 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } if (Model.HasInheritance) { #line default #line hidden this.Write(" super.toJSON(data);\r\n"); #line 78 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" return data; \r\n }\r\n"); #line 81 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.GenerateCloneMethod) { #line default #line hidden this.Write("\r\n clone() {\r\n const json = this.toJSON();\r\n let result = new "); #line 85 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("();\r\n result.init(json);\r\n return result;\r\n }\r\n"); #line 89 "C:\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("}"); return(this.GenerationEnvironment.ToString()); }
public static string WrapInNamespace(this ApiClientDefinition definition, string typescript, string baseClass) { return("namespace " + definition.Namespace + " {\n " + ConversionUtilities.Tab(baseClass, 1).TrimEnd('\n') + "\n " + ConversionUtilities.Tab(typescript, 1).TrimEnd('\n') + "\n}\n"); }
public static string Tab(Context context, string input, int tabCount) { return(ConversionUtilities.Tab(input, tabCount)); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("//----------------------\r\n// <auto-generated>\r\n// Generated using the NSwag t" + "oolchain v"); #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write(" (NJsonSchema v"); #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(JsonSchema4.ToolchainVersion)); #line default #line hidden this.Write(") (http://NSwag.org)\r\n// </auto-generated>\r\n//----------------------\r\n\r\n"); #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" foreach (var usage in Model.NamespaceUsages) { #line default #line hidden this.Write("using "); #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(usage)); #line default #line hidden this.Write(";\r\n"); #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("\r\nnamespace "); #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Namespace)); #line default #line hidden this.Write("\r\n{\r\n #pragma warning disable // Disable all warnings\r\n\r\n "); #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Clients, 1))); #line default #line hidden this.Write("\r\n\r\n"); #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.GenerateContracts) { #line default #line hidden this.Write(" "); #line 19 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Classes, 1))); #line default #line hidden this.Write("\r\n\r\n"); #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.RequiresFileParameterType) { #line default #line hidden this.Write(" [System.CodeDom.Compiler.GeneratedCode(\"NSwag\", \""); #line 22 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write(@""")] public class FileParameter { public FileParameter(System.IO.Stream data) : this (data, null) { } public FileParameter(System.IO.Stream data, string fileName) { Data = data; FileName = fileName; } public System.IO.Stream Data { get; private set; } public string FileName { get; private set; } } " ); #line 40 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 42 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" foreach (var exceptionClassName in Model.ExceptionClassNames) { #line default #line hidden this.Write(" [System.CodeDom.Compiler.GeneratedCode(\"NSwag\", \""); #line 43 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(" : System.Exception\r\n {\r\n public string StatusCode { get; private set; " + "}\r\n\r\n public byte[] ResponseData { get; private set; }\r\n\r\n public " + ""); #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(@"(string message, string statusCode, byte[] responseData, System.Exception innerException) : base(message, innerException) { StatusCode = statusCode; ResponseData = responseData; } public override string ToString() { return string.Format(""HTTP Response: n{0}n{1}"", System.Text.Encoding.UTF8.GetString(ResponseData, 0, ResponseData.Length), base.ToString()); } } [System.CodeDom.Compiler.GeneratedCode(""NSwag"", """); #line 63 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 64 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("<TResponse> : "); #line 64 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("\r\n {\r\n public TResponse Response { get; private set; }\r\n\r\n publi" + "c "); #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("(string message, string statusCode, byte[] responseData, TResponse response, Syst" + "em.Exception innerException) \r\n : base(message, statusCode, responseD" + "ata, innerException)\r\n {\r\n Response = response;\r\n }\r\n " + " }\r\n\r\n"); #line 75 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 76 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 77 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.GenerateImplementation) { #line default #line hidden #line 78 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.RequiresJsonExceptionConverter) { #line default #line hidden this.Write(" "); #line 79 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.JsonExceptionConverterCode)); #line default #line hidden this.Write("\r\n"); #line 80 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 81 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("\r\n"); #line 6 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (Model.HasOperations) { #line default #line hidden #line 7 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (Model.GenerateClientInterfaces) { #line default #line hidden this.Write("export interface I"); #line 8 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(" {\r\n"); #line 9 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" foreach (var operation in Model.Operations) { #line default #line hidden #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.HasDocumentation) { #line default #line hidden this.Write(" /**\r\n"); #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.HasSummary) { #line default #line hidden this.Write(" * "); #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary)); #line default #line hidden this.Write("\r\n"); #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" foreach (var parameter in operation.Parameters) { #line default #line hidden #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (parameter.HasDescription) { #line default #line hidden this.Write(" * @"); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden this.Write(" "); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? "")); #line default #line hidden this.Write("\r\n"); #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.HasResultDescription) { #line default #line hidden this.Write(" * @return "); #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription)); #line default #line hidden this.Write("\r\n"); #line 15 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 15 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.IsDeprecated) { #line default #line hidden this.Write(" * @deprecated\r\n"); #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" */\r\n"); #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" "); #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameLower)); #line default #line hidden this.Write("("); #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" foreach (var parameter in operation.Parameters) { #line default #line hidden #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden this.Write(": "); #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type)); #line default #line hidden #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (!parameter.IsLast) { #line default #line hidden this.Write(", "); #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write("): Promise<"); #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); #line default #line hidden this.Write(">;\r\n"); #line 18 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write("}\r\n"); #line 19 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (Model.UseAureliaHttpInjection) { #line default #line hidden this.Write("@inject(String, HttpClient)\r\n"); #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write("export class "); #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(" "); #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (Model.GenerateClientInterfaces) { #line default #line hidden this.Write("implements I"); #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(" "); #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(@"{ private baseUrl: string; private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }; protected jsonParseReviver: (key: string, value: any) => any = undefined; constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) { this.baseUrl = baseUrl ? baseUrl : """"; this.http = http ? http : window; } "); #line 33 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (Model.IsExtended) { #line default #line hidden this.Write("\r\n protected transformOptions(options: RequestInit) {\r\n return options;" + " \r\n }\r\n\r\n protected transformResult(url: string, response: Response, proce" + "ssor: (response: Response) => any) {\r\n return processor(response);\r\n }" + "\r\n"); #line 42 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 43 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" foreach (var operation in Model.Operations) { #line default #line hidden this.Write("\r\n"); #line 45 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.HasDocumentation) { #line default #line hidden this.Write(" /**\r\n"); #line 46 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.HasSummary) { #line default #line hidden this.Write(" * "); #line 46 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary)); #line default #line hidden this.Write("\r\n"); #line 47 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 47 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" foreach (var parameter in operation.Parameters) { #line default #line hidden #line 48 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (parameter.HasDescription) { #line default #line hidden this.Write(" * @"); #line 48 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden this.Write(" "); #line 48 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? "")); #line default #line hidden this.Write("\r\n"); #line 49 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 49 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 49 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.HasResultDescription) { #line default #line hidden this.Write(" * @return "); #line 49 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription)); #line default #line hidden this.Write("\r\n"); #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.IsDeprecated) { #line default #line hidden this.Write(" * @deprecated\r\n"); #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" */\r\n"); #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" "); #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameLower)); #line default #line hidden this.Write("("); #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" foreach (var parameter in operation.Parameters) { #line default #line hidden #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden this.Write(": "); #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type)); #line default #line hidden #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (!parameter.IsLast) { #line default #line hidden this.Write(", "); #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write("): Promise<"); #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); #line default #line hidden this.Write("> {\r\n "); #line 53 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(RequestUrlGenerator.Render(operation, 2))); #line default #line hidden this.Write("\r\n\r\n"); #line 55 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (!operation.IsGetOrHead) { #line default #line hidden this.Write(" "); #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(RequestBodyGenerator.Render(operation, 2))); #line default #line hidden this.Write("\r\n"); #line 57 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" return this.http.fetch(url_, "); #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (Model.IsExtended) { #line default #line hidden this.Write("this.transformOptions("); #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write("{\r\n"); #line 59 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (!operation.IsGetOrHead) { #line default #line hidden this.Write("\t\t\tbody: content_,\r\n"); #line 61 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" method: \""); #line 62 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodUpper.ToUpperInvariant())); #line default #line hidden this.Write("\",\r\n headers: {\r\n"); #line 64 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" foreach (var parameter in operation.HeaderParameters) { #line default #line hidden this.Write(" \""); #line 65 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name)); #line default #line hidden this.Write("\": "); #line 65 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden this.Write(", \r\n"); #line 66 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 67 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.HasFormParameters) { #line default #line hidden this.Write(" \'Content-Type\': undefined\r\n"); #line 68 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } else { #line default #line hidden this.Write(" \"Content-Type\": \"application/json; charset=UTF-8\"\r\n"); #line 70 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" }\r\n }"); #line 72 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (Model.IsExtended) { #line default #line hidden this.Write(")"); #line 72 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(").then((response) => {\r\n"); #line 73 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (Model.IsExtended) { #line default #line hidden this.Write(" return this.transformResult(url_, response, (response) => this.proces" + "s"); #line 74 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); #line default #line hidden this.Write("(response));\r\n"); #line 75 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } else { #line default #line hidden this.Write(" return this.process"); #line 76 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); #line default #line hidden this.Write("(response);\r\n"); #line 77 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" });\r\n }\r\n\r\n private process"); #line 81 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); #line default #line hidden this.Write("(response: Response) {\r\n return response.text().then((data) => {\r\n " + " const status = response.status.toString(); \r\n\r\n"); #line 85 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" foreach (var response in operation.Responses) { #line default #line hidden this.Write(" if (status === \""); #line 86 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write("\") {\r\n"); #line 87 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (response.HasType) { #line default #line hidden this.Write(" let result"); #line 88 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(": "); #line 88 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.Type)); #line default #line hidden this.Write(" = null; \r\n"); #line 89 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (response.IsDate) { #line default #line hidden this.Write(" result"); #line 90 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = new Date(data);\r\n"); #line 91 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } else { #line default #line hidden #line 92 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (response.UseDtoClass) { #line default #line hidden this.Write(" let resultData"); #line 93 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = data === \"\" ? null : JSON.parse(data, this.jsonParseReviver);\r\n " + " "); #line 94 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(response.DataConversionCode, 4))); #line default #line hidden this.Write("\r\n"); #line 95 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } else { #line default #line hidden this.Write(" result"); #line 96 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = data === \"\" ? null : <"); #line 96 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.Type)); #line default #line hidden this.Write(">JSON.parse(data, this.jsonParseReviver);\r\n"); #line 97 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 98 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 99 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (response.IsSuccess) { #line default #line hidden this.Write(" return result"); #line 100 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write("; \r\n"); #line 101 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } else { #line default #line hidden this.Write(" throw result"); #line 102 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write("; \r\n"); #line 103 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } } #line default #line hidden this.Write(" }\r\n else\r\n"); #line 107 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" {\r\n"); #line 108 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.HasDefaultResponse) { #line default #line hidden this.Write(" let result: "); #line 109 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.DefaultResponse.Type)); #line default #line hidden this.Write(" = null; \r\n"); #line 110 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.DefaultResponse.IsDate) { #line default #line hidden this.Write(" result = new Date(data);\r\n"); #line 112 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } else { #line default #line hidden #line 113 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.DefaultResponse.UseDtoClass) { #line default #line hidden this.Write(" let resultData = data === \"\" ? null : JSON.parse(data, this.jsonP" + "arseReviver);\r\n "); #line 115 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(operation.DefaultResponse.DataConversionCode, 3))); #line default #line hidden this.Write("\r\n"); #line 116 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } else { #line default #line hidden this.Write(" result = data === \"\" ? null : <"); #line 117 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.DefaultResponse.Type)); #line default #line hidden this.Write(">JSON.parse(data, this.jsonParseReviver);\r\n"); #line 118 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 119 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden #line 120 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" if (operation.DefaultResponse.IsSuccess) { #line default #line hidden this.Write(" return result; \r\n"); #line 122 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } else { #line default #line hidden this.Write(" throw result; \r\n"); #line 124 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } } else { #line default #line hidden this.Write(" throw new Error(\"error_no_callback_for_the_received_http_status\")" + "; \r\n"); #line 127 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write(" }\r\n });\r\n }\r\n"); #line 131 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write("}\r\n"); #line 132 "C:\Data\NSwag\src\NSwag.CodeGeneration\CodeGenerators\TypeScript\Templates\FetchClientTemplate.tt" } #line default #line hidden this.Write("\r\n"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 3 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" foreach (var response in Model.Responses) { #line default #line hidden this.Write("if (status === "); #line 4 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(") {\r\n"); #line 5 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (response.HasType) { #line default #line hidden this.Write(" let result"); #line 6 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(": "); #line 6 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.Type)); #line default #line hidden this.Write(" | null = null;\r\n"); #line 7 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (response.IsDate) { #line default #line hidden this.Write(" result"); #line 8 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = new Date(responseText);\r\n"); #line 9 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { if (response.UseDtoClass) { #line default #line hidden this.Write(" let resultData"); #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = responseText === \"\" ? null : JSON.parse(responseText, this.jsonParseReviver);\r" + "\n "); #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(response.DataConversionCode, 1))); #line default #line hidden this.Write("\r\n"); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" result"); #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(" = responseText === \"\" ? null : <"); #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.Type)); #line default #line hidden this.Write(">JSON.parse(responseText, this.jsonParseReviver);\r\n"); #line 15 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } } if (response.IsSuccess) { #line default #line hidden this.Write(" return result"); #line 18 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(";\r\n"); #line 19 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" this.throwException(\"A server error occurred.\", status, responseText, result"); #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(response.StatusCode)); #line default #line hidden this.Write(");\r\n"); #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } } else if (response.IsSuccess) { #line default #line hidden this.Write(" return null;\r\n"); #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" this.throwException(\"A server error occurred.\", status, responseText);\r\n"); #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write("} else "); #line 27 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } if (Model.HasDefaultResponse) { #line default #line hidden this.Write("{\r\n"); #line 29 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.DefaultResponse.HasType) { #line default #line hidden this.Write(" let result: "); #line 30 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DefaultResponse.Type)); #line default #line hidden this.Write(" | null = null;\r\n"); #line 31 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" if (Model.DefaultResponse.IsDate) { #line default #line hidden this.Write(" result = new Date(responseText);\r\n"); #line 33 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { if (Model.DefaultResponse.UseDtoClass) { #line default #line hidden this.Write(" let resultData = responseText === \"\" ? null : JSON.parse(responseText, this.j" + "sonParseReviver);\r\n "); #line 36 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.DefaultResponse.DataConversionCode, 1))); #line default #line hidden this.Write("\r\n"); #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" result = responseText === \"\" ? null : <"); #line 38 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DefaultResponse.Type)); #line default #line hidden this.Write(">JSON.parse(responseText, this.jsonParseReviver);\r\n"); #line 39 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } } if (!Model.HasSuccessResponse) { #line default #line hidden this.Write(" return result;\r\n"); #line 43 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" this.throwException(\"A server error occurred.\", status, responseText, result)" + ";\r\n"); #line 45 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } } else if (!Model.HasSuccessResponse) { #line default #line hidden this.Write(" return null;\r\n"); #line 48 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write(" this.throwException(\"A server error occurred.\", status, responseText);\r\n"); #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden this.Write("}"); #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } else { #line default #line hidden this.Write("if (status !== 200 && status !== 204) {\r\n this.throwException(\"An unexpected s" + "erver error occurred.\", status, responseText);\r\n}\r\nreturn null;\r\n"); #line 58 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\ProcessResponseTemplate.tt" } #line default #line hidden return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 2 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 2 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {"); #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" \r\n"); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.IsOptional) { #line default #line hidden this.Write("?"); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(": "); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden this.Write(" = "); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(";"); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" protected _discriminator: string;\r\n"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n constructor(data?: any) {\r\n"); #line 12 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super(data);\r\n"); #line 14 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 15 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden this.Write(" this._discriminator = \""); #line 16 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DiscriminatorName)); #line default #line hidden this.Write("\";\r\n"); #line 17 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" if (data !== undefined) {\r\n"); #line 19 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 20 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToClassCode, 3))); #line default #line hidden this.Write("\r\n"); #line 21 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n\r\n static fromJS(data: any): "); #line 25 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write(" {\r\n"); #line 26 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 28 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 28 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\")\r\n return new "); #line 29 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("(data);\r\n"); #line 30 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return new "); #line 31 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\r\n"); #line 32 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } else { #line default #line hidden this.Write(" return new "); #line 33 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\r\n"); #line 34 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n\r\n toJS(data?: any) {\r\n data = data === undefined ? {} : data;\r\n" + ""); #line 39 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" data[\""); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] = this._discriminator; \r\n"); #line 41 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 42 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 43 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToJavaScriptCode, 2))); #line default #line hidden this.Write("\r\n"); #line 44 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } if (Model.HasInheritance) { #line default #line hidden this.Write(" super.toJS(data);\r\n"); #line 46 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return data; \r\n }\r\n\r\n toJSON() {\r\n return JSON.stringify(thi" + "s.toJS());\r\n }\r\n\r\n clone() {\r\n const json = this.toJSON();\r\n " + " return new "); #line 56 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(JSON.parse(json));\r\n }\r\n}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("//----------------------\r\n// <auto-generated>\r\n// Generated using the NSwag t" + "oolchain v"); #line 8 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerService.ToolchainVersion)); #line default #line hidden this.Write(" (NJsonSchema v"); #line 8 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(JsonSchema4.ToolchainVersion)); #line default #line hidden this.Write(@") (http://NSwag.org) // </auto-generated> //---------------------- using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.IO; using System.Linq; "); #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.GenerateImplementation) { #line default #line hidden this.Write("using System.Net;\r\nusing System.Net.Http;\r\n"); #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write(@"using System.Reflection; using System.Runtime.Serialization; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using System.Text; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; "); #line 35 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" foreach (var usage in Model.NamespaceUsages) { #line default #line hidden this.Write("using "); #line 35 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(usage)); #line default #line hidden this.Write(";\r\n"); #line 36 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("\r\nnamespace "); #line 38 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Namespace)); #line default #line hidden this.Write("\r\n{\r\n #pragma warning disable // Disable all warnings\r\n\r\n "); #line 42 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Clients, 1))); #line default #line hidden this.Write("\r\n\r\n"); #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.GenerateContracts) { #line default #line hidden this.Write(" "); #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Classes, 1))); #line default #line hidden this.Write("\r\n\r\n\t"); #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.RequiresFileParameterType) { #line default #line hidden this.Write(" [GeneratedCode(\"NSwag\", \""); #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerService.ToolchainVersion)); #line default #line hidden this.Write(@""")] public class FileParameter { public FileParameter(Stream data) : this (data, null) { } public FileParameter(Stream data, string fileName) { Data = data; FileName = fileName; } public Stream Data { get; private set; } public string FileName { get; private set; } } " ); #line 66 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" foreach (var exceptionClassName in Model.ExceptionClassNames) { #line default #line hidden this.Write(" [GeneratedCode(\"NSwag\", \""); #line 69 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerService.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 70 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(" : Exception\r\n {\r\n public string StatusCode { get; private set; }\r\n\r\n " + " public byte[] ResponseData { get; private set; }\r\n\r\n public "); #line 76 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(@"(string message, string statusCode, byte[] responseData, Exception innerException) : base(message, innerException) { StatusCode = statusCode; ResponseData = responseData; } public override string ToString() { return string.Format(""HTTP Response: n{0}n{1}"", Encoding.UTF8.GetString(ResponseData, 0, ResponseData.Length), base.ToString()); } } [GeneratedCode(""NSwag"", """); #line 89 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerService.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 90 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("<TResponse> : "); #line 90 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("\r\n {\r\n public TResponse Response { get; private set; }\r\n\r\n publi" + "c "); #line 94 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("(string message, string statusCode, byte[] responseData, TResponse response, Exce" + "ption innerException) \r\n : base(message, statusCode, responseData, in" + "nerException)\r\n {\r\n Response = response;\r\n }\r\n }\r\n\r\n" + ""); #line 101 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 102 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 103 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.GenerateImplementation) { #line default #line hidden #line 104 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.RequiresJsonExceptionConverter) { #line default #line hidden this.Write(" "); #line 105 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.JsonExceptionConverterCode)); #line default #line hidden this.Write("\r\n"); #line 106 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 107 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("//----------------------\r\n// <auto-generated>\r\n// Generated using the NSwag t" + "oolchain v"); #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write(" (NJsonSchema v"); #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(JsonSchema4.ToolchainVersion)); #line default #line hidden this.Write(") (http://NSwag.org)\r\n// </auto-generated>\r\n//----------------------\r\n\r\n"); #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" foreach (var usage in Model.NamespaceUsages) { #line default #line hidden this.Write("using "); #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(usage)); #line default #line hidden this.Write(";\r\n"); #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("\r\nnamespace "); #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Namespace)); #line default #line hidden this.Write("\r\n{\r\n #pragma warning disable // Disable all warnings\r\n\r\n "); #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Clients, 1))); #line default #line hidden this.Write("\r\n\r\n"); #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" if (Model.GenerateContracts) { #line default #line hidden this.Write(" "); #line 19 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Classes, 1))); #line default #line hidden this.Write("\r\n\r\n"); #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" if (Model.RequiresFileParameterType) { #line default #line hidden this.Write(" [System.CodeDom.Compiler.GeneratedCode(\"NSwag\", \""); #line 22 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write(@""")] public class FileParameter { public FileParameter(System.IO.Stream data) : this (data, null) { } public FileParameter(System.IO.Stream data, string fileName) { Data = data; FileName = fileName; } public System.IO.Stream Data { get; private set; } public string FileName { get; private set; } } "); #line 41 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 42 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" if (Model.GenerateFileResponseClass) { #line default #line hidden this.Write(@" public class FileResponse : System.IDisposable { private System.IDisposable _client; private System.IDisposable _response; public string StatusCode { get; private set; } public System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; } public System.IO.Stream Stream { get; private set; } public bool IsPartial { get { return StatusCode == ""206""; } } public FileResponse(string statusCode, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.IO.Stream stream, System.IDisposable client, System.IDisposable response) { StatusCode = statusCode; Headers = headers; Stream = stream; _client = client; _response = response; } public void Dispose() { if (Stream != null) Stream.Dispose(); if (_response != null) _response.Dispose(); if (_client != null) _client.Dispose(); } } "); #line 79 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 80 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" if (Model.WrapResponses && Model.GenerateResponseClasses) { #line default #line hidden #line 81 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" foreach (var responseClassName in Model.ResponseClassNames) { #line default #line hidden this.Write(" [System.CodeDom.Compiler.GeneratedCode(\"NSwag\", \""); #line 82 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 83 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(responseClassName)); #line default #line hidden this.Write("\r\n {\r\n public string StatusCode { get; private set; }\r\n\r\n public" + " System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnume" + "rable<string>> Headers { get; private set; }\r\n \r\n public "); #line 89 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(responseClassName)); #line default #line hidden this.Write(@"(string statusCode, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers) { StatusCode = statusCode; Headers = headers; } } [System.CodeDom.Compiler.GeneratedCode(""NSwag"", """); #line 96 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 97 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(responseClassName)); #line default #line hidden this.Write("<TResult> : "); #line 97 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(responseClassName)); #line default #line hidden this.Write("\r\n {\r\n public TResult Result { get; private set; }\r\n \r\n p" + "ublic "); #line 101 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(responseClassName)); #line default #line hidden this.Write("(string statusCode, System.Collections.Generic.Dictionary<string, System.Collecti" + "ons.Generic.IEnumerable<string>> headers, TResult result) \r\n : base(s" + "tatusCode, headers)\r\n {\r\n Result = result;\r\n }\r\n }\r\n" + "\r\n"); #line 108 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 109 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 110 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" if (Model.GenerateExceptionClasses) { #line default #line hidden #line 111 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" foreach (var exceptionClassName in Model.ExceptionClassNames) { #line default #line hidden this.Write(" [System.CodeDom.Compiler.GeneratedCode(\"NSwag\", \""); #line 112 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 113 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(@" : System.Exception { public string StatusCode { get; private set; } public string Response { get; private set; } public System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; } public "); #line 121 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(@"(string message, string statusCode, string response, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.Exception innerException) : base(message, innerException) { StatusCode = statusCode; Response = response; Headers = headers; } public override string ToString() { return string.Format(""HTTP Response: \n\n{0}\n\n{1}"", Response, base.ToString()); } } [System.CodeDom.Compiler.GeneratedCode(""NSwag"", """); #line 135 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 136 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("<TResult> : "); #line 136 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("\r\n {\r\n public TResult Result { get; private set; }\r\n\r\n public "); #line 140 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(@"(string message, string statusCode, string response, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers, TResult result, System.Exception innerException) : base(message, statusCode, response, headers, innerException) { Result = result; } } "); #line 147 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 148 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 149 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 150 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" if (Model.GenerateImplementation) { #line default #line hidden #line 151 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" if (Model.RequiresJsonExceptionConverter) { #line default #line hidden this.Write(" "); #line 152 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.JsonExceptionConverterCode)); #line default #line hidden this.Write("\r\n"); #line 153 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 154 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {\r\n"); #line 6 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write(" = "); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsArray) { #line default #line hidden this.Write("ko.observableArray<"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.ArrayItemType)); #line default #line hidden this.Write(">()"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write("ko.observable<"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden this.Write(">("); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(";\r\n"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n constructor(data?: any) {\r\n"); #line 12 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super(data);\r\n"); #line 14 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" if (data !== undefined) {\r\n"); #line 16 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" var "); #line 17 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write(": "); #line 17 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden this.Write(" = null; \r\n "); #line 18 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.DataConversionCode, 3))); #line default #line hidden this.Write("\r\n this."); #line 19 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("("); #line 19 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write(");\r\n\r\n"); #line 21 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n}"); return(this.GenerationEnvironment.ToString()); }
/// <summary>Renders the URL generation code.</summary> /// <param name="operation">The operation.</param> /// <param name="tabCount">The tab count.</param> /// <returns>Rendered request body</returns> public static string Render(OperationModel operation, int tabCount = 0) { var tpl = new RequestUrlTemplate(operation); return(ConversionUtilities.Tab(tpl.Render(), tabCount)); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 2 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 2 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {\r\n"); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 6 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.IsOptional) { #line default #line hidden this.Write("?"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(": "); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.SupportsStrictNullChecks) { #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.IsNullable) { #line default #line hidden this.Write(" | null"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" | undefined"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden this.Write(" = "); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(";\r\n"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 10 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasIndexerProperty) { #line default #line hidden this.Write("\r\n [key: string]: "); #line 12 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.IndexerPropertyValueType)); #line default #line hidden this.Write("; \r\n"); #line 13 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 14 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write("\r\n protected _discriminator: string;\r\n"); #line 17 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n constructor(data?: any) {\r\n"); #line 20 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super(data);\r\n"); #line 22 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 23 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden this.Write(" this._discriminator = \""); #line 24 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DiscriminatorName)); #line default #line hidden this.Write("\";\r\n"); #line 25 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" if (data !== undefined) {\r\n"); #line 27 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasIndexerProperty) { #line default #line hidden this.Write(" for (var property in data) {\r\n if (data.hasOwnProperty" + "(property))\r\n this[property] = data[property];\r\n }" + "\r\n"); #line 32 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 33 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 34 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToClassCode, 3))); #line default #line hidden this.Write("\r\n"); #line 35 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n\r\n static fromJS(data: any): "); #line 39 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write(" {\r\n"); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 42 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 42 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\")\r\n return new "); #line 43 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("(data);\r\n"); #line 44 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return new "); #line 45 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\r\n"); #line 46 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } else { #line default #line hidden this.Write(" return new "); #line 47 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\r\n"); #line 48 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n\r\n toJS(data?: any) {\r\n data = data === undefined ? {} : data;\r\n" + ""); #line 53 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasIndexerProperty) { #line default #line hidden this.Write(" for (var property in this) {\r\n if (this.hasOwnProperty(propert" + "y))\r\n data[property] = this[property];\r\n }\r\n"); #line 58 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 59 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" data[\""); #line 60 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] = this._discriminator; \r\n"); #line 61 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 62 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 63 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToJavaScriptCode, 2))); #line default #line hidden this.Write("\r\n"); #line 64 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 65 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super.toJS(data);\r\n"); #line 67 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return data; \r\n }\r\n\r\n toJSON() {\r\n return JSON.stringify(thi" + "s.toJS());\r\n }\r\n\r\n clone() {\r\n const json = this.toJSON();\r\n " + " return new "); #line 77 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(JSON.parse(json));\r\n }\r\n}"); return(this.GenerationEnvironment.ToString()); }
/// <summary>Renders the reqeust body.</summary> /// <param name="model">The model.</param> /// <param name="tabCount">The tab count.</param> /// <returns>Rendered request body</returns> public static string Render(ParameterModel model, int tabCount = 0) { var tpl = new RequestBodyTemplate(model); return(ConversionUtilities.Tab(tpl.Render(), tabCount)); }