Exemplo n.º 1
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
            if (Model.HasOperations)
            {
            #line default
            #line hidden

            #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("export interface I");

            #line 7 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

            #line default
            #line hidden
                    this.Write(" {\r\n");

            #line 8 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    foreach (var operation in Model.Operations)
                    {
            #line default
            #line hidden

            #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (operation.HasDocumentation)
                        {
            #line default
            #line hidden
                            this.Write("    /**\r\n");

            #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (operation.HasSummary)
                            {
            #line default
            #line hidden
                                this.Write("     * ");

            #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            foreach (var parameter in operation.Parameters)
                            {
            #line default
            #line hidden

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                if (parameter.HasDescription)
                                {
            #line default
            #line hidden
                                    this.Write("     * @");

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                    this.Write("\r\n");

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                }

            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (operation.HasResultDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @return ");

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (operation.IsDeprecated)
                            {
            #line default
            #line hidden
                                this.Write("     * @deprecated\r\n");

            #line 15 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden
                            this.Write("     */\r\n");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.MethodAccessModifier));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (Model.GenerateOptionalParameters && parameter.IsOptional)
                            {
            #line default
            #line hidden
                                this.Write("?");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.TypePostfix));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (!parameter.IsLast)
                            {
            #line default
            #line hidden
                                this.Write(", ");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("): ng.IPromise<");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                        this.Write(">;\r\n");

            #line 17 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("}\r\n");

            #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\nexport class ");

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.HasBaseClass)
                {
            #line default
            #line hidden
                    this.Write("extends ");

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseClass));

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

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("implements I");

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("{\r\n    private baseUrl: string");

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write(" | undefined");

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined; \r\n    private http: ng.IHttpService; \r\n    private q: ng.IQService;" +
                           " \r\n    protected jsonParseReviver: ");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write("((key: string, value: any) => any) | undefined");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }
                else
                {
            #line default
            #line hidden
                    this.Write("(key: string, value: any) => any");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined;\r\n\r\n");

            #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (!Model.HasExtendedConstructor)
                {
            #line default
            #line hidden
                    this.Write("    constructor(");

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.HasConfigurationClass)
                    {
            #line default
            #line hidden
                        this.Write("configuration: ");

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(Model.ConfigurationClass));

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

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("$http: ng.IHttpService, $q: ng.IQService, baseUrl?: string) {\r\n");

            #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.HasBaseClass)
                    {
            #line default
            #line hidden
                        this.Write("        super(");

            #line 29 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (Model.HasConfigurationClass)
                        {
            #line default
            #line hidden
                            this.Write("configuration");

            #line 29 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write(");\r\n");

            #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        this.http = $http;\r\n        this.q = $q;\r\n");

            #line 33 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseGetBaseUrlMethod)
                    {
            #line default
            #line hidden
                        this.Write("        this.baseUrl = baseUrl ? baseUrl : this.getBaseUrl(\"");

            #line 34 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrl));

            #line default
            #line hidden
                        this.Write("\");\r\n");

            #line 35 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("        this.baseUrl = baseUrl ? baseUrl : \"");

            #line 36 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrl));

            #line default
            #line hidden
                        this.Write("\";\r\n");

            #line 37 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("    }\r\n");

            #line 39 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 40 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.HasExtensionCode)
                {
            #line default
            #line hidden
                    this.Write("    ");

            #line 41 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCode));

            #line default
            #line hidden
                    this.Write("\r\n    \r\n");

            #line 43 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                foreach (var operation in Model.Operations)
                {
            #line default
            #line hidden
                    this.Write("\r\n");

            #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (operation.HasDocumentation)
                    {
            #line default
            #line hidden
                        this.Write("    /**\r\n");

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (operation.HasSummary)
                        {
            #line default
            #line hidden
                            this.Write("     * ");

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (parameter.HasDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @");

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (operation.HasResultDescription)
                        {
            #line default
            #line hidden
                            this.Write("     * @return ");

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (operation.IsDeprecated)
                        {
            #line default
            #line hidden
                            this.Write("     * @deprecated\r\n");

            #line 52 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("     */\r\n");

            #line 53 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

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

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.MethodAccessModifier));

            #line default
            #line hidden

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (Model.GenerateOptionalParameters && parameter.IsOptional)
                        {
            #line default
            #line hidden
                            this.Write("?");

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

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

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.TypePostfix));

            #line default
            #line hidden

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (!parameter.IsLast)
                        {
            #line default
            #line hidden
                            this.Write(", ");

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("): ng.IPromise<");

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        ");

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n");

            #line 57 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (operation.HasBody)
                    {
            #line default
            #line hidden
                        this.Write("        ");

            #line 58 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2)));

            #line default
            #line hidden
                        this.Write("\r\n");

            #line 59 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("\r\n        var options_ = <ng.IRequestConfig>{\r\n            url: url_,\r\n          " +
                               "  method: \"");

            #line 63 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodUpper.ToUpperInvariant()));

            #line default
            #line hidden
                    this.Write("\",\r\n");

            #line 64 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (operation.IsFile)
                    {
            #line default
            #line hidden
                        this.Write("            responseType: \"arraybuffer\",\r\n");

            #line 66 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 67 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (operation.HasBody)
                    {
            #line default
            #line hidden
                        this.Write("            data: content_,\r\n");

            #line 69 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            transformResponse: [], \r\n            headers: {\r\n");

            #line 72 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    foreach (var parameter in operation.HeaderParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"");

            #line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));

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

            #line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden
                        this.Write(", \r\n");

            #line 74 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 75 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (!operation.HasFormParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"Content-Type\": \"");

            #line 76 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes));

            #line default
            #line hidden
                        this.Write("\", \r\n");

            #line 77 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 78 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (operation.HasResultType && !operation.HasAcceptHeaderParameterParameter)
                    {
            #line default
            #line hidden
                        this.Write("                \"Accept\": \"");

            #line 79 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces));

            #line default
            #line hidden
                        this.Write("\"\r\n");

            #line 80 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            }\r\n        };\r\n\r\n");

            #line 84 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("        return this.transformOptions(options_).then(transformedOptions_ => {\r\n   " +
                                   "         return this.http(transformedOptions_);\r\n        }).then((_response) => " +
                                   "{\r\n");

            #line 88 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("        return this.http(options_).then((_response) => {\r\n");

            #line 90 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 91 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("            return this.transformResult(url_, _response, (_response) => this.proc" +
                                   "ess");

            #line 92 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(_response));\r\n");

            #line 93 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            return this.process");

            #line 94 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(_response);\r\n");

            #line 95 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        }, (_response) => {\r\n            if (_response.status)\r\n");

            #line 98 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("                return this.transformResult(url_, _response, (_response) => this." +
                                   "process");

            #line 99 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(_response));\r\n");

            #line 100 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("                return this.process");

            #line 101 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(_response);\r\n");

            #line 102 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            throw _response;\r\n        });\r\n    }\r\n\r\n    protected process");

            #line 107 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("(response: any): ng.IPromise<");

            #line 107 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        const status = response.status; \r\n\r\n        ");

            #line 110 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n    }\r\n");

            #line 112 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("}\r\n");

            #line 114 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
            if (Model.HasOperations)
            {
            #line default
            #line hidden

            #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("export interface I");

            #line 7 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

            #line default
            #line hidden
                    this.Write(" {\r\n");

            #line 8 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    foreach (var operation in Model.Operations)
                    {
            #line default
            #line hidden

            #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        if (operation.HasDocumentation)
                        {
            #line default
            #line hidden
                            this.Write("    /**\r\n");

            #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            if (operation.HasSummary)
                            {
            #line default
            #line hidden
                                this.Write("     * ");

            #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            foreach (var parameter in operation.Parameters)
                            {
            #line default
            #line hidden

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                                if (parameter.HasDescription)
                                {
            #line default
            #line hidden
                                    this.Write("     * @");

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                    this.Write("\r\n");

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                                }

            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            if (operation.HasResultDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @return ");

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            if (operation.IsDeprecated)
                            {
            #line default
            #line hidden
                                this.Write("     * @deprecated\r\n");

            #line 15 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            }

            #line default
            #line hidden
                            this.Write("     */\r\n");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.MethodAccessModifier));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            if (Model.GenerateOptionalParameters && parameter.IsOptional)
                            {
            #line default
            #line hidden
                                this.Write("?");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            }

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            if (!parameter.IsLast)
                            {
            #line default
            #line hidden
                                this.Write(", ");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("): Observable<");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                        this.Write(">;\r\n");

            #line 17 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("}\r\n");

            #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n@Injectable()\r\nexport class ");

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("extends ");

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClientBaseClass));

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

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("implements I");

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("{\r\n    private http: Http;\r\n    private baseUrl: string;\r\n    protected jsonParse" +
                           "Reviver: ");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write("((key: string, value: any) => any) | undefined");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                }
                else
                {
            #line default
            #line hidden
                    this.Write("(key: string, value: any) => any");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined;\r\n\r\n");

            #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                if (!Model.HasExtendedConstructor)
                {
            #line default
            #line hidden
                    this.Write("    constructor(");

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (Model.HasConfigurationClass)
                    {
            #line default
            #line hidden
                        this.Write("@Inject(");

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(Model.ConfigurationClass));

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

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(Model.ConfigurationClass));

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

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("@Inject(Http) http: Http, @Optional() @Inject(");

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrlTokenName));

            #line default
            #line hidden
                    this.Write(") baseUrl?: string) {\r\n");

            #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (Model.HasClientBaseClass)
                    {
            #line default
            #line hidden
                        this.Write("        super(");

            #line 29 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        if (Model.HasConfigurationClass)
                        {
            #line default
            #line hidden
                            this.Write("configuration");

            #line 29 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write(");\r\n");

            #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        this.http = http;\r\n        this.baseUrl = baseUrl ? baseUrl : \"");

            #line 32 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrl));

            #line default
            #line hidden
                    this.Write("\";\r\n    }\r\n");

            #line 34 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 35 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                if (Model.HasExtensionCode)
                {
            #line default
            #line hidden
                    this.Write("    ");

            #line 36 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCode));

            #line default
            #line hidden
                    this.Write("\r\n    \r\n");

            #line 38 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 39 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                foreach (var operation in Model.Operations)
                {
            #line default
            #line hidden
                    this.Write("\r\n");

            #line 41 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (operation.HasDocumentation)
                    {
            #line default
            #line hidden
                        this.Write("    /**\r\n");

            #line 42 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        if (operation.HasSummary)
                        {
            #line default
            #line hidden
                            this.Write("     * ");

            #line 42 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 43 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 43 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            if (parameter.HasDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @");

            #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        if (operation.HasResultDescription)
                        {
            #line default
            #line hidden
                            this.Write("     * @return ");

            #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        if (operation.IsDeprecated)
                        {
            #line default
            #line hidden
                            this.Write("     * @deprecated\r\n");

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("     */\r\n");

            #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

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

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.MethodAccessModifier));

            #line default
            #line hidden

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        if (Model.GenerateOptionalParameters && parameter.IsOptional)
                        {
            #line default
            #line hidden
                            this.Write("?");

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

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

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        if (!parameter.IsLast)
                        {
            #line default
            #line hidden
                            this.Write(", ");

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("): Observable<");

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        ");

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n        ");

            #line 52 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n        \r\n        let options_ = {\r\n            body: content_,\r\n            me" +
                               "thod: \"");

            #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodLower));

            #line default
            #line hidden
                    this.Write("\",\r\n");

            #line 57 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (operation.IsFile)
                    {
            #line default
            #line hidden
                        this.Write("            responseType: ResponseContentType.Blob,\r\n");

            #line 59 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            headers: new Headers({\r\n");

            #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    foreach (var parameter in operation.HeaderParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"");

            #line 62 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));

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

            #line 62 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden
                        this.Write(", \r\n");

            #line 63 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 64 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (!operation.HasFormParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"Content-Type\": \"");

            #line 65 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes));

            #line default
            #line hidden
                        this.Write("\", \r\n");

            #line 66 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 67 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (operation.HasResultType && !operation.HasAcceptHeaderParameterParameter)
                    {
            #line default
            #line hidden
                        this.Write("                \"Accept\": \"");

            #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces));

            #line default
            #line hidden
                        this.Write("\"\r\n");

            #line 69 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            })\r\n        };\r\n\r\n");

            #line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("        return Observable.fromPromise(this.transformOptions(options_)).flatMap(tr" +
                                   "ansformedOptions_ => {\r\n            return this.http.request(url_, transformedOp" +
                                   "tions_);\r\n        }).flatMap((response_) => {\r\n");

            #line 77 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("        return this.http.request(url_, options_).flatMap((response_) => {\r\n");

            #line 79 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 80 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("            return this.transformResult(url_, response_, (r) => this.process");

            #line 81 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(r));\r\n");

            #line 82 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            return this.process");

            #line 83 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response_);\r\n");

            #line 84 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        }).catch((response_: any) => {\r\n            if (response_ instanceof Resp" +
                               "onse) {\r\n                try {\r\n");

            #line 88 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("                    return this.transformResult(url_, response_, (r) => this.proc" +
                                   "ess");

            #line 89 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(r));\r\n");

            #line 90 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("                    return this.process");

            #line 91 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response_);\r\n");

            #line 92 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("                } catch (e) {\r\n                    return <Observable<");

            #line 94 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.UnwrappedResultType));

            #line default
            #line hidden
                    this.Write(">><any>Observable.throw(e);\r\n                }\r\n            } else\r\n             " +
                               "   return <Observable<");

            #line 97 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.UnwrappedResultType));

            #line default
            #line hidden
                    this.Write(">><any>Observable.throw(response_);\r\n        });\r\n    }\r\n\r\n    protected process");

            #line 101 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("(response: Response): Observable<");

            #line 101 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        const status = response.status; \r\n\r\n        ");

            #line 104 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n    }\r\n");

            #line 106 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("}\r\n");

            #line 108 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("/* tslint:disable */\r\n//----------------------\r\n// <auto-generated>\r\n//     Gener" +
                       "ated using the NSwag toolchain v");

            #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion));

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

            #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\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 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCodeImport));

            #line default
            #line hidden
            this.Write("\r\n");

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.ImportRequiredTypes)
            {
            #line default
            #line hidden

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsAngular)
                {
            #line default
            #line hidden
                    this.Write(@"
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/catch';

import { Observable } from 'rxjs/Observable';
import { Injectable, Inject, Optional, OpaqueToken } from '@angular/core';
import { Http, Headers, ResponseContentType, Response");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write(", RequestOptionsArgs");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write(" } from \'@angular/http\';\r\n");

            #line 25 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsAurelia)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport { inject } from \'aurelia-framework\';\r\nimport { HttpClient, RequestInit }" +
                               " from \'aurelia-fetch-client\';\r\n");

            #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 31 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsAngularJS)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport * as ng from \'angular\';\r\n");

            #line 34 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 35 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsKnockout)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport * as ko from \'knockout\';\r\n");

            #line 38 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 39 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsJQuery)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport * as jQuery from \'jquery\';\r\n");

            #line 42 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 43 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.RequiresMomentJS)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport * as moment from \'moment\';\r\n");

            #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n");

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.HasModuleName)
            {
            #line default
            #line hidden
                this.Write("module ");

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.ModuleName));

            #line default
            #line hidden
                this.Write(" {\r\n");

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }
            if (Model.HasNamespace)
            {
            #line default
            #line hidden
                this.Write("namespace ");

            #line 53 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Namespace));

            #line default
            #line hidden
                this.Write(" {\r\n");

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.GenerateClientClasses && Model.IsAngular)
            {
            #line default
            #line hidden
                this.Write("export const ");

            #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrlTokenName));

            #line default
            #line hidden
                this.Write(" = new OpaqueToken(\'");

            #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrlTokenName));

            #line default
            #line hidden
                this.Write("\');\r\n\r\n");

            #line 58 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 59 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCodeTop));

            #line default
            #line hidden
            this.Write("\r\n\r\n");

            #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.Clients));

            #line default
            #line hidden
            this.Write("\r\n\r\n");

            #line 63 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.Types));

            #line default
            #line hidden
            this.Write("\r\n\r\n");

            #line 65 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.RequiresFileParameterInterface)
            {
            #line default
            #line hidden
                this.Write("export interface FileParameter {\r\n    data: any;\r\n    fileName: string;\r\n}\r\n\r\n");

            #line 71 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 72 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.RequiresSwaggerExceptionClass)
            {
            #line default
            #line hidden
                this.Write(@"export class SwaggerException extends Error {
    message: string;
    status: number; 
    response: string; 
    result: any; 

    constructor(message: string, status: number, response: string, result: any) {
        super();

        this.message = message;
        this.status = status;
        this.response = response;
        this.result = result;
    }
}

");

            #line 89 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 90 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.GenerateClientClasses)
            {
            #line default
            #line hidden

            #line 91 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderClientMethodsCode(Model, 0)));

            #line default
            #line hidden
                this.Write("\r\n\r\n");

            #line 93 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.HandleReferences)
                {
            #line default
            #line hidden

            #line 94 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ReferenceHandlingCode));

            #line default
            #line hidden
                    this.Write("\r\n");

            #line 95 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 96 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 97 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCodeBottom));

            #line default
            #line hidden
            this.Write("\r\n");

            #line 98 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.HasNamespace)
            {
            #line default
            #line hidden
                this.Write("}\r\n");

            #line 100 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }
            if (Model.HasModuleName)
            {
            #line default
            #line hidden
                this.Write("}\r\n");

            #line 103 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 5 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
            if (Model.HasOperations)
            {
            #line default
            #line hidden

            #line 6 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("export interface I");

            #line 7 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

            #line default
            #line hidden
                    this.Write(" {\r\n");

            #line 8 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    foreach (var operation in Model.Operations)
                    {
            #line default
            #line hidden

            #line 9 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        if (operation.HasDocumentation)
                        {
            #line default
            #line hidden
                            this.Write("    /**\r\n");

            #line 10 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            if (operation.HasSummary)
                            {
            #line default
            #line hidden
                                this.Write("     * ");

            #line 10 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 11 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 11 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            foreach (var parameter in operation.Parameters)
                            {
            #line default
            #line hidden

            #line 12 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                if (parameter.HasDescriptionOrIsOptional)
                                {
            #line default
            #line hidden
                                    this.Write("     * @");

            #line 12 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 12 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                    if (parameter.IsOptional)
                                    {
            #line default
            #line hidden
                                        this.Write(" (optional)");

            #line 12 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                    }

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

            #line 12 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                    this.Write("\r\n");

            #line 13 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                }

            #line default
            #line hidden

            #line 13 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 13 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            if (operation.HasResultDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @return ");

            #line 13 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 14 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 14 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            if (operation.IsDeprecated)
                            {
            #line default
            #line hidden
                                this.Write("     * @deprecated\r\n");

            #line 15 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            }

            #line default
            #line hidden
                            this.Write("     */\r\n");

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        }

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

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.MethodAccessModifier));

            #line default
            #line hidden

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            if (Model.GenerateOptionalParameters && parameter.IsOptional)
                            {
            #line default
            #line hidden
                                this.Write("?");

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            }

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

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

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

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("onSuccess?: (");

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        if (operation.HasResultType)
                        {
            #line default
            #line hidden
                            this.Write("result: ");

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write(") => void, onFail?: (exception: ");

            #line 16 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ExceptionType));

            #line default
            #line hidden
                        this.Write(", reason: string) => void): JQueryXHR;\r\n");

            #line 17 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("}\r\n");

            #line 18 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\nexport class ");

            #line 20 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 20 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("extends ");

            #line 20 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClientBaseClass));

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

            #line 20 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 20 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("implements I");

            #line 20 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 20 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("{\r\n    baseUrl: string;\r\n    beforeSend: any = undefined;\r\n    protected jsonPars" +
                           "eReviver: ");

            #line 23 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write("((key: string, value: any) => any) | undefined");

            #line 23 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                }
                else
                {
            #line default
            #line hidden
                    this.Write("(key: string, value: any) => any");

            #line 23 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined;\r\n\r\n");

            #line 25 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                if (!Model.HasExtendedConstructor)
                {
            #line default
            #line hidden
                    this.Write("    constructor(baseUrl?: string) {\r\n");

            #line 27 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    if (Model.HasClientBaseClass)
                    {
            #line default
            #line hidden
                        this.Write("        super();\r\n");

            #line 29 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        this.baseUrl = baseUrl ? baseUrl : \"");

            #line 30 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrl));

            #line default
            #line hidden
                    this.Write("\";\r\n    }\r\n");

            #line 32 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 33 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                if (Model.HasExtensionCode)
                {
            #line default
            #line hidden
                    this.Write("    ");

            #line 34 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCode));

            #line default
            #line hidden
                    this.Write("\r\n    \r\n");

            #line 36 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 37 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                foreach (var operation in Model.Operations)
                {
            #line default
            #line hidden
                    this.Write("\r\n");

            #line 39 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    if (operation.HasDocumentation)
                    {
            #line default
            #line hidden
                        this.Write("    /**\r\n");

            #line 40 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        if (operation.HasSummary)
                        {
            #line default
            #line hidden
                            this.Write("     * ");

            #line 40 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 41 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 41 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 42 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            if (parameter.HasDescriptionOrIsOptional)
                            {
            #line default
            #line hidden
                                this.Write("     * @");

            #line 42 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 42 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                if (parameter.IsOptional)
                                {
            #line default
            #line hidden
                                    this.Write(" (optional)");

            #line 42 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                }

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

            #line 42 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 43 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 43 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 43 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        if (operation.HasResultDescription)
                        {
            #line default
            #line hidden
                            this.Write("     * @return ");

            #line 43 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 44 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 44 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        if (operation.IsDeprecated)
                        {
            #line default
            #line hidden
                            this.Write("     * @deprecated\r\n");

            #line 45 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("     */\r\n");

            #line 46 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

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

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.MethodAccessModifier));

            #line default
            #line hidden

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        if (Model.GenerateOptionalParameters && parameter.IsOptional)
                        {
            #line default
            #line hidden
                            this.Write("?");

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        }

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

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

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

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("onSuccess?: (");

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    if (operation.HasResultType)
                    {
            #line default
            #line hidden
                        this.Write("result: ");

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write(") => void, onFail?: (exception: ");

            #line 47 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ExceptionType));

            #line default
            #line hidden
                    this.Write(", reason: string) => void): JQueryXHR {\r\n        ");

            #line 48 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n        ");

            #line 50 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n        let jqXhr = jQuery.ajax(");

            #line 52 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("this.transformOptions(");

            #line 52 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("{\r\n            url: url_,\r\n            beforeSend: this.beforeSend,\r\n            " +
                               "type: \"");

            #line 55 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodLower));

            #line default
            #line hidden
                    this.Write("\",\r\n            data: content_,\r\n");

            #line 57 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    if (operation.HasFormParameters)
                    {
            #line default
            #line hidden
                        this.Write("            mimeType: \"multipart/form-data\",\r\n            contentType: false,\r\n");

            #line 60 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            dataType: \"text\",\r\n");

            #line 62 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            headers: {\r\n");

            #line 64 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    foreach (var parameter in operation.HeaderParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"");

            #line 65 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));

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

            #line 65 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden
                        this.Write(", \r\n");

            #line 66 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("                \"Content-Type\": \"");

            #line 67 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes));

            #line default
            #line hidden
                    this.Write("; charset=UTF-8\",\r\n");

            #line 68 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    if (!operation.IsFile)
                    {
            #line default
            #line hidden
                        this.Write("                \"Accept\": \"");

            #line 69 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces));

            #line default
            #line hidden
                        this.Write("; charset=UTF-8\"\r\n");

            #line 70 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            }\r\n        }");

            #line 72 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write(")");

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

            #line default
            #line hidden
                    this.Write("); \r\n        \r\n        jqXhr.done((_data, _textStatus, xhr) => {\r\n            thi" +
                               "s.process");

            #line 75 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("WithCallbacks(url_, xhr, onSuccess, onFail);\r\n        }).fail((xhr) => {\r\n       " +
                               "     this.process");

            #line 77 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("WithCallbacks(url_, xhr, onSuccess, onFail);\r\n        });\r\n\r\n        return jqXhr" +
                               ";\r\n    }\r\n\r\n    private process");

            #line 83 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("WithCallbacks(_url: string, xhr: any, onSuccess?: any, onFail?: any): void {\r\n   " +
                               "     try {\r\n");

            #line 85 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("            let result = this.transformResult(_url, xhr, (xhr) => this.process");

            #line 86 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(xhr));\r\n");

            #line 87 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            let result = this.process");

            #line 88 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(xhr);\r\n");

            #line 89 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            if (onSuccess !== undefined)\r\n                onSuccess(result);\r\n   " +
                               "     } catch (e) {\r\n            if (onFail !== undefined)\r\n                onFai" +
                               "l(e, \"http_service_exception\");\r\n        }\r\n    }\r\n\r\n    protected process");

            #line 98 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("(xhr: any): ");

            #line 98 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write(" {\r\n        const status = xhr.status;\r\n\r\n        ");

            #line 101 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n    }\r\n");

            #line 103 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("}\r\n");

            #line 105 "C:\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryCallbacksClientTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 5 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
            if (Model.HasOperations)
            {
            #line default
            #line hidden

            #line 6 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("export interface I");

            #line 7 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

            #line default
            #line hidden
                    this.Write(" {\r\n");

            #line 8 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    foreach (var operation in Model.Operations)
                    {
            #line default
            #line hidden

            #line 9 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        if (operation.HasDocumentation)
                        {
            #line default
            #line hidden
                            this.Write("    /**\r\n");

            #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            if (operation.HasSummary)
                            {
            #line default
            #line hidden
                                this.Write("     * ");

            #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            foreach (var parameter in operation.Parameters)
                            {
            #line default
            #line hidden

            #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                                if (parameter.HasDescription)
                                {
            #line default
            #line hidden
                                    this.Write("     * @");

            #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                    this.Write("\r\n");

            #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                                }

            #line default
            #line hidden

            #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            if (operation.HasResultDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @return ");

            #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            if (operation.IsDeprecated)
                            {
            #line default
            #line hidden
                                this.Write("     * @deprecated\r\n");

            #line 15 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            }

            #line default
            #line hidden
                            this.Write("     */\r\n");

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        }

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

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            if (!parameter.IsLast)
                            {
            #line default
            #line hidden
                                this.Write(", ");

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("): Observable<");

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                        this.Write(">;\r\n");

            #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("}\r\n");

            #line 18 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n@Injectable()\r\nexport class ");

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("extends ");

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClientBaseClass));

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

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("implements I");

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("{\r\n    private http: Http = null; \r\n    private baseUrl: string");

            #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write(" | undefined");

            #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined; \r\n    protected jsonParseReviver: ");

            #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write("((key: string, value: any) => any) | undefined");

            #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }
                else
                {
            #line default
            #line hidden
                    this.Write("(key: string, value: any) => any");

            #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined;\r\n\r\n    constructor(");

            #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                if (Model.HasConfigurationClass)
                {
            #line default
            #line hidden
                    this.Write("@Inject(");

            #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ConfigurationClass));

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

            #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ConfigurationClass));

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

            #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {\r\n" +
                           "");

            #line 27 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("        super(");

            #line 28 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    if (Model.HasConfigurationClass)
                    {
            #line default
            #line hidden
                        this.Write("configuration");

            #line 28 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write(");\r\n");

            #line 29 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("        this.http = http; \r\n        this.baseUrl = baseUrl ? baseUrl : \"");

            #line 31 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrl));

            #line default
            #line hidden
                this.Write("\"; \r\n    }\r\n");

            #line 33 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                if (Model.HasExtensionClass && !Model.HasClientBaseClass)
                {
            #line default
            #line hidden

            #line 34 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("\r\n    protected transformOptions(options: RequestOptionsArgs) {\r\n        return P" +
                                   "romise.resolve(options); \r\n    }\r\n");

            #line 39 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 40 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("\r\n    protected transformResult(url: string, response: Response, processor: (resp" +
                                   "onse: Response) => any) {\r\n        return processor(response);\r\n    }\r\n");

            #line 45 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 46 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 47 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                foreach (var operation in Model.Operations)
                {
            #line default
            #line hidden
                    this.Write("\r\n");

            #line 49 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    if (operation.HasDocumentation)
                    {
            #line default
            #line hidden
                        this.Write("    /**\r\n");

            #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        if (operation.HasSummary)
                        {
            #line default
            #line hidden
                            this.Write("     * ");

            #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            if (parameter.HasDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @");

            #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 53 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 53 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 53 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        if (operation.HasResultDescription)
                        {
            #line default
            #line hidden
                            this.Write("     * @return ");

            #line 53 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        if (operation.IsDeprecated)
                        {
            #line default
            #line hidden
                            this.Write("     * @deprecated\r\n");

            #line 55 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("     */\r\n");

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

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

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        if (!parameter.IsLast)
                        {
            #line default
            #line hidden
                            this.Write(", ");

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("): Observable<");

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        ");

            #line 57 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n        ");

            #line 59 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n        \r\n        let options_ = {\r\n            body: content_,\r\n            me" +
                               "thod: \"");

            #line 63 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodLower));

            #line default
            #line hidden
                    this.Write("\",\r\n            headers: new Headers({\r\n");

            #line 65 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    foreach (var parameter in operation.HeaderParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"");

            #line 66 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));

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

            #line 66 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden
                        this.Write(", \r\n");

            #line 67 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 68 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    if (operation.HasFormParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \'Content-Type\': undefined, \r\n");

            #line 69 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("                \"Content-Type\": \"");

            #line 70 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes));

            #line default
            #line hidden
                        this.Write("; charset=UTF-8\", \r\n                \"Accept\": \"");

            #line 71 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces));

            #line default
            #line hidden
                        this.Write("; charset=UTF-8\"\r\n");

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

            #line default
            #line hidden
                    this.Write("            })\r\n        };\r\n\r\n");

            #line 76 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("        return Observable.fromPromise(this.transformOptions(options_)).concatMap(" +
                                   "transformedOptions_ => {\r\n            return this.http.request(url_, transformed" +
                                   "Options_);\r\n        }).map((response) => {\r\n");

            #line 80 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("        return this.http.request(url_, options_).map((response) => {\r\n");

            #line 82 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 83 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("            return this.transformResult(url_, response, (response) => this.proces" +
                                   "s");

            #line 84 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response));\r\n");

            #line 85 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            return this.process");

            #line 86 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response);\r\n");

            #line 87 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        }).catch((response: any) => {\r\n            if (response instanceof Respon" +
                               "se) {\r\n                try {\r\n");

            #line 91 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("                    return Observable.of(this.transformResult(url_, response, (re" +
                                   "sponse) => this.process");

            #line 92 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response)));\r\n");

            #line 93 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("                    return Observable.of(this.process");

            #line 94 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response));\r\n");

            #line 95 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("                } catch (e) {\r\n                    return <Observable<");

            #line 97 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write(">><any>Observable.throw(e);\r\n                }\r\n            } else\r\n             " +
                               "   return <Observable<");

            #line 100 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write(">><any>Observable.throw(response);\r\n        });\r\n    }\r\n\r\n    protected process");

            #line 104 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("(response: Response): ");

            #line 104 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write(" {\r\n        const responseText = response.text();\r\n        const status = respons" +
                               "e.status; \r\n\r\n        ");

            #line 108 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n    }\r\n");

            #line 110 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n    ");

            #line 112 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderClientMethodsCode(Model, 1)));

            #line default
            #line hidden
                this.Write("\r\n}\r\n");

            #line 114 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\Angular2ClientTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
            if (Model.HasOperations)
            {
            #line default
            #line hidden

            #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("export interface I");

            #line 7 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

            #line default
            #line hidden
                    this.Write(" {\r\n");

            #line 8 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    foreach (var operation in Model.Operations)
                    {
            #line default
            #line hidden

            #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        if (operation.HasDocumentation)
                        {
            #line default
            #line hidden
                            this.Write("    /**\r\n");

            #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            if (operation.HasSummary)
                            {
            #line default
            #line hidden
                                this.Write("     * ");

            #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            foreach (var parameter in operation.Parameters)
                            {
            #line default
            #line hidden

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                                if (parameter.HasDescription)
                                {
            #line default
            #line hidden
                                    this.Write("     * @");

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                    this.Write("\r\n");

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                                }

            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            if (operation.HasResultDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @return ");

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            if (operation.IsDeprecated)
                            {
            #line default
            #line hidden
                                this.Write("     * @deprecated\r\n");

            #line 15 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            }

            #line default
            #line hidden
                            this.Write("     */\r\n");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        }

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.MethodAccessModifier));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            if (Model.GenerateOptionalParameters && parameter.IsOptional)
                            {
            #line default
            #line hidden
                                this.Write("?");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            }

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            if (!parameter.IsLast)
                            {
            #line default
            #line hidden
                                this.Write(", ");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("): Promise<");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                        this.Write(">;\r\n");

            #line 17 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("}\r\n");

            #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n");

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                if (Model.UseAureliaHttpInjection)
                {
            #line default
            #line hidden
                    this.Write("@inject(String, HttpClient)\r\n");

            #line 22 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }

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

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("extends ");

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClientBaseClass));

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

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("implements I");

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("{\r\n    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Respo" +
                           "nse> };\r\n    private baseUrl: string;\r\n    protected jsonParseReviver: ");

            #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write("((key: string, value: any) => any) | undefined");

            #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }
                else
                {
            #line default
            #line hidden
                    this.Write("(key: string, value: any) => any");

            #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined;\r\n\r\n");

            #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                if (!Model.HasExtendedConstructor)
                {
            #line default
            #line hidden
                    this.Write("    constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: Request" +
                               "Init): Promise<Response> }) {\r\n");

            #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    if (Model.HasClientBaseClass)
                    {
            #line default
            #line hidden
                        this.Write("        super();\r\n");

            #line 32 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        this.baseUrl = baseUrl ? baseUrl : \"\";\r\n        this.http = http ? http :" +
                               " <any>window;\r\n    }\r\n");

            #line 36 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 37 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                if (Model.HasExtensionCode)
                {
            #line default
            #line hidden
                    this.Write("    ");

            #line 38 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCode));

            #line default
            #line hidden
                    this.Write("\r\n\t\r\n");

            #line 40 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 41 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                foreach (var operation in Model.Operations)
                {
            #line default
            #line hidden
                    this.Write("\r\n");

            #line 43 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    if (operation.HasDocumentation)
                    {
            #line default
            #line hidden
                        this.Write("    /**\r\n");

            #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        if (operation.HasSummary)
                        {
            #line default
            #line hidden
                            this.Write("     * ");

            #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            if (parameter.HasDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @");

            #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        if (operation.HasResultDescription)
                        {
            #line default
            #line hidden
                            this.Write("     * @return ");

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        if (operation.IsDeprecated)
                        {
            #line default
            #line hidden
                            this.Write("     * @deprecated\r\n");

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("     */\r\n");

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

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

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.MethodAccessModifier));

            #line default
            #line hidden

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        if (Model.GenerateOptionalParameters && parameter.IsOptional)
                        {
            #line default
            #line hidden
                            this.Write("?");

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        }

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

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        if (!parameter.IsLast)
                        {
            #line default
            #line hidden
                            this.Write(", ");

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("): Promise<");

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        ");

            #line 52 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n");

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    if (!operation.IsGetOrHead)
                    {
            #line default
            #line hidden
                        this.Write("        ");

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2)));

            #line default
            #line hidden
                        this.Write("\r\n");

            #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("\r\n        let options_ = <RequestInit>{\r\n");

            #line 59 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    if (!operation.IsGetOrHead)
                    {
            #line default
            #line hidden
                        this.Write("            body: content_,\r\n");

            #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            method: \"");

            #line 62 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodUpper.ToUpperInvariant()));

            #line default
            #line hidden
                    this.Write("\",\r\n            headers: {\r\n");

            #line 64 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    foreach (var parameter in operation.HeaderParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"");

            #line 65 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));

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

            #line 65 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden
                        this.Write(", \r\n");

            #line 66 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 67 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    if (!operation.HasFormParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"Content-Type\": \"");

            #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes));

            #line default
            #line hidden
                        this.Write("; charset=UTF-8\", \r\n");

            #line 69 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 70 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    if (!operation.IsFile)
                    {
            #line default
            #line hidden
                        this.Write("                \"Accept\": \"");

            #line 71 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces));

            #line default
            #line hidden
                        this.Write("; charset=UTF-8\"\r\n");

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

            #line default
            #line hidden
                    this.Write("            }\r\n        };\r\n\r\n");

            #line 76 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("        return this.transformOptions(options_).then(transformedOptions_ => {\r\n   " +
                                   "         return this.http.fetch(url_, transformedOptions_);\r\n        }).then((re" +
                                   "sponse: Response) => {\r\n");

            #line 80 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("        return this.http.fetch(url_, options_).then((response: Response) => {\r\n");

            #line 82 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 83 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("            return this.transformResult(url_, response, (response: Response) => t" +
                                   "his.process");

            #line 84 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response));\r\n");

            #line 85 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            return this.process");

            #line 86 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response);\r\n");

            #line 87 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        });\r\n    }\r\n\r\n    protected process");

            #line 91 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("(response: Response): Promise<");

            #line 91 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        return response.text().then((responseText) => {\r\n            const s" +
                               "tatus = response.status; \r\n\r\n            ");

            #line 95 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 3)));

            #line default
            #line hidden
                    this.Write("\r\n        });\r\n    }\r\n");

            #line 98 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n    ");

            #line 100 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderClientMethodsCode(Model, 1)));

            #line default
            #line hidden
                this.Write("\r\n}\r\n");

            #line 102 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FetchClientTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
            if (Model.HasOperations)
            {
            #line default
            #line hidden

            #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("export interface I");

            #line 7 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

            #line default
            #line hidden
                    this.Write(" {\r\n");

            #line 8 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    foreach (var operation in Model.Operations)
                    {
            #line default
            #line hidden

            #line 9 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (operation.HasDocumentation)
                        {
            #line default
            #line hidden
                            this.Write("    /**\r\n");

            #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (operation.HasSummary)
                            {
            #line default
            #line hidden
                                this.Write("     * ");

            #line 10 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            foreach (var parameter in operation.Parameters)
                            {
            #line default
            #line hidden

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                if (parameter.HasDescription)
                                {
            #line default
            #line hidden
                                    this.Write("     * @");

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                    this.Write("\r\n");

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                }

            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (operation.HasResultDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @return ");

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 14 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (operation.IsDeprecated)
                            {
            #line default
            #line hidden
                                this.Write("     * @deprecated\r\n");

            #line 15 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden
                            this.Write("     */\r\n");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (Model.GenerateOptionalParameters && parameter.IsOptional)
                            {
            #line default
            #line hidden
                                this.Write("?");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

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

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (!parameter.IsLast)
                            {
            #line default
            #line hidden
                                this.Write(", ");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("): ng.IPromise<");

            #line 16 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                        this.Write(">;\r\n");

            #line 17 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("}\r\n");

            #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\nexport class ");

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("extends ");

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClientBaseClass));

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

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("implements I");

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 20 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("{\r\n    private baseUrl: string");

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write(" | undefined");

            #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined; \r\n    private http: ng.IHttpService | null = null; \r\n    protected " +
                           "jsonParseReviver: ");

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write("((key: string, value: any) => any) | undefined");

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }
                else
                {
            #line default
            #line hidden
                    this.Write("(key: string, value: any) => any");

            #line 23 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined;\r\n\r\n    constructor($http: ng.IHttpService, baseUrl?: string) {\r\n");

            #line 26 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("        super();\r\n");

            #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("        this.http = $http; \r\n        this.baseUrl = baseUrl !== undefined ? baseU" +
                           "rl : \"");

            #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrl));

            #line default
            #line hidden
                this.Write("\"; \r\n    }\r\n");

            #line 32 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                if (Model.HasExtensionClass && !Model.HasClientBaseClass)
                {
            #line default
            #line hidden

            #line 33 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("\r\n    protected transformOptions(options: any) {\r\n        throw new Error(\"transf" +
                                   "ormOptions is not implemented.\");\r\n    }\r\n");

            #line 38 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 39 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("\r\n    protected transformResult(url: string, response: any, processor: (response:" +
                                   " any) => any) {\r\n        return processor(response);\r\n    }\r\n");

            #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 46 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                foreach (var operation in Model.Operations)
                {
            #line default
            #line hidden
                    this.Write("\r\n");

            #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (operation.HasDocumentation)
                    {
            #line default
            #line hidden
                        this.Write("    /**\r\n");

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (operation.HasSummary)
                        {
            #line default
            #line hidden
                            this.Write("     * ");

            #line 49 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 50 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            if (parameter.HasDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @");

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 52 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 52 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 52 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (operation.HasResultDescription)
                        {
            #line default
            #line hidden
                            this.Write("     * @return ");

            #line 52 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 53 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 53 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (operation.IsDeprecated)
                        {
            #line default
            #line hidden
                            this.Write("     * @deprecated\r\n");

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("     */\r\n");

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

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

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (Model.GenerateOptionalParameters && parameter.IsOptional)
                        {
            #line default
            #line hidden
                            this.Write("?");

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

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

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        if (!parameter.IsLast)
                        {
            #line default
            #line hidden
                            this.Write(", ");

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("): ng.IPromise<");

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        ");

            #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n        ");

            #line 58 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n        var options_ = <ng.IRequestConfig>{\r\n            url: url_,\r\n        " +
                               "    method: \"");

            #line 62 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodUpper.ToUpperInvariant()));

            #line default
            #line hidden
                    this.Write("\",\r\n            data: content_,\r\n            transformResponse: [], \r\n           " +
                               " headers: {\r\n");

            #line 66 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    foreach (var parameter in operation.HeaderParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"");

            #line 67 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));

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

            #line 67 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden
                        this.Write(", \r\n");

            #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 69 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (operation.HasFormParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \'Content-Type\': undefined, \r\n");

            #line 70 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("                \"Content-Type\": \"");

            #line 71 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes));

            #line default
            #line hidden
                        this.Write("; charset=UTF-8\", \r\n");

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

            #line default
            #line hidden
                    this.Write("                \"Accept\": \"");

            #line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces));

            #line default
            #line hidden
                    this.Write("; charset=UTF-8\"\r\n            }\r\n        };\r\n\r\n");

            #line 77 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("        return this.transformOptions(options_).then(transformedOptions_ => {\r\n   " +
                                   "         return this.http(transformedOptions_);\r\n        }).then((response) => {" +
                                   "\r\n");

            #line 81 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("        return this.http(options_).then((response) => {\r\n");

            #line 83 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 84 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("            return this.transformResult(url_, response, (response) => this.proces" +
                                   "s");

            #line 85 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response));\r\n");

            #line 86 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            return this.process");

            #line 87 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response);\r\n");

            #line 88 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("        }, (response) => {\r\n            if (response.status)\r\n");

            #line 91 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("                return this.transformResult(url_, response, (response) => this.pr" +
                                   "ocess");

            #line 92 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response));\r\n");

            #line 93 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("                return this.process");

            #line 94 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(response);\r\n");

            #line 95 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            throw response;\r\n        });\r\n    }\r\n\r\n    protected process");

            #line 100 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("(response: any): ");

            #line 100 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write(" {\r\n        const responseText = response.data;\r\n        const status = response." +
                               "status; \r\n\r\n        ");

            #line 104 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n    }\r\n");

            #line 106 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n    ");

            #line 108 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderClientMethodsCode(Model, 1)));

            #line default
            #line hidden
                this.Write("\r\n}\r\n");

            #line 110 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularJSClientTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 5 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
            if (Model.HasOperations)
            {
            #line default
            #line hidden

            #line 6 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("export interface I");

            #line 7 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

            #line default
            #line hidden
                    this.Write(" {\r\n");

            #line 8 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    foreach (var operation in Model.Operations)
                    {
            #line default
            #line hidden

            #line 9 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        if (operation.HasDocumentation)
                        {
            #line default
            #line hidden
                            this.Write("    /**\r\n");

            #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            if (operation.HasSummary)
                            {
            #line default
            #line hidden
                                this.Write("     * ");

            #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            foreach (var parameter in operation.Parameters)
                            {
            #line default
            #line hidden

            #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                if (parameter.HasDescriptionOrIsOptional)
                                {
            #line default
            #line hidden
                                    this.Write("     * @");

            #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                    if (parameter.IsOptional)
                                    {
            #line default
            #line hidden
                                        this.Write(" (optional)");

            #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                    }

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

            #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                    this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                    this.Write("\r\n");

            #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                }

            #line default
            #line hidden

            #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            if (operation.HasResultDescription)
                            {
            #line default
            #line hidden
                                this.Write("     * @return ");

            #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 14 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            if (operation.IsDeprecated)
                            {
            #line default
            #line hidden
                                this.Write("     * @deprecated\r\n");

            #line 15 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            }

            #line default
            #line hidden
                            this.Write("     */\r\n");

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        }

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

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            if (!parameter.IsLast)
                            {
            #line default
            #line hidden
                                this.Write(", ");

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        }

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

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(Model.PromiseType));

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

            #line 16 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                        this.Write(">;\r\n");

            #line 17 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("}\r\n");

            #line 18 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\nexport class ");

            #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("extends ");

            #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClientBaseClass));

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

            #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                if (Model.GenerateClientInterfaces)
                {
            #line default
            #line hidden
                    this.Write("implements I");

            #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class));

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

            #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("{\r\n    baseUrl: string");

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write(" | undefined");

            #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined; \r\n    beforeSend: any = undefined; \r\n    protected jsonParseReviver" +
                           ": ");

            #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                if (Model.SupportsStrictNullChecks)
                {
            #line default
            #line hidden
                    this.Write("((key: string, value: any) => any) | undefined");

            #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }
                else
                {
            #line default
            #line hidden
                    this.Write("(key: string, value: any) => any");

            #line 23 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write(" = undefined;\r\n\r\n    constructor(baseUrl?: string) {\r\n");

            #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                if (Model.HasClientBaseClass)
                {
            #line default
            #line hidden
                    this.Write("        super();\r\n");

            #line 28 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("        this.baseUrl = baseUrl !== undefined ? baseUrl : \"");

            #line 29 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrl));

            #line default
            #line hidden
                this.Write("\"; \r\n    }\r\n");

            #line 31 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                if (Model.HasExtensionClass && !Model.HasClientBaseClass)
                {
            #line default
            #line hidden

            #line 32 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("\r\n    protected transformOptions(options: any) {\r\n        return options; \r\n    }" +
                                   "\r\n");

            #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 38 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("\r\n    protected transformResult(url: string, xhr: any, processor: (xhr: any) => a" +
                                   "ny) {\r\n        return processor(xhr);\r\n    }\r\n");

            #line 43 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden

            #line 44 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }

            #line default
            #line hidden

            #line 45 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                foreach (var operation in Model.Operations)
                {
            #line default
            #line hidden
                    this.Write("\r\n");

            #line 47 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    if (operation.HasDocumentation)
                    {
            #line default
            #line hidden
                        this.Write("    /**\r\n");

            #line 48 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        if (operation.HasSummary)
                        {
            #line default
            #line hidden
                            this.Write("     * ");

            #line 48 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.Summary));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 49 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 49 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        foreach (var parameter in operation.Parameters)
                        {
            #line default
            #line hidden

            #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            if (parameter.HasDescriptionOrIsOptional)
                            {
            #line default
            #line hidden
                                this.Write("     * @");

            #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden

            #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                if (parameter.IsOptional)
                                {
            #line default
            #line hidden
                                    this.Write(" (optional)");

            #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                }

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

            #line 50 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                                this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Description ?? ""));

            #line default
            #line hidden
                                this.Write("\r\n");

            #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            }

            #line default
            #line hidden

            #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        if (operation.HasResultDescription)
                        {
            #line default
            #line hidden
                            this.Write("     * @return ");

            #line 51 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                            this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultDescription));

            #line default
            #line hidden
                            this.Write("\r\n");

            #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 52 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        if (operation.IsDeprecated)
                        {
            #line default
            #line hidden
                            this.Write("     * @deprecated\r\n");

            #line 53 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write("     */\r\n");

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

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

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

            #line default
            #line hidden

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        if (!parameter.IsLast)
                        {
            #line default
            #line hidden
                            this.Write(", ");

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        }

            #line default
            #line hidden

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

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

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.PromiseType));

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

            #line 54 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write("> {\r\n        return ");

            #line 55 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.PromiseConstructor));

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

            #line 55 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write(">((resolve, reject) => {\r\n            this.");

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 56 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("(result) => resolve(result), (exception, reason) => reject(exception));\r\n        " +
                               "});\r\n    }\r\n    \r\n    private ");

            #line 60 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationName));

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

            #line 60 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    foreach (var parameter in operation.Parameters)
                    {
            #line default
            #line hidden

            #line 60 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

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

            #line 60 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type));

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

            #line 60 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("onSuccess?: (result: ");

            #line 60 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write(") => void, onFail?: (exception: ");

            #line 60 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ExceptionType));

            #line default
            #line hidden
                    this.Write(", reason: string) => void) {\r\n        ");

            #line 61 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestUrlCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n        ");

            #line 63 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderRequestBodyCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n\r\n        jQuery.ajax(");

            #line 65 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write("this.transformOptions(");

            #line 65 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("{\r\n            url: url_,\r\n            beforeSend: this.beforeSend,\r\n            " +
                               "type: \"");

            #line 68 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodLower));

            #line default
            #line hidden
                    this.Write("\",\r\n            data: content_,\r\n");

            #line 70 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    if (operation.HasFormParameters)
                    {
            #line default
            #line hidden
                        this.Write("            mimeType: \"multipart/form-data\",\r\n            contentType: false,\r\n");

            #line 73 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            dataType: \"text\",\r\n");

            #line 75 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            headers: {\r\n");

            #line 77 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    foreach (var parameter in operation.HeaderParameters)
                    {
            #line default
            #line hidden
                        this.Write("                \"");

            #line 78 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Name));

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

            #line 78 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName));

            #line default
            #line hidden
                        this.Write(", \r\n");

            #line 79 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("                \"Content-Type\": \"");

            #line 79 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.Consumes));

            #line default
            #line hidden
                    this.Write("; charset=UTF-8\",\r\n\t\t\t\t\"Accept\": \"");

            #line 80 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.Produces));

            #line default
            #line hidden
                    this.Write("; charset=UTF-8\"\r\n            }\r\n        }");

            #line 82 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    if (Model.UseTransformOptionsMethod)
                    {
            #line default
            #line hidden
                        this.Write(")");

            #line 82 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write(").done((data, textStatus, xhr) => {\r\n            this.process");

            #line 83 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("WithCallbacks(url_, xhr, onSuccess, onFail);\r\n        }).fail((xhr) => {\r\n       " +
                               "     this.process");

            #line 85 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("WithCallbacks(url_, xhr, onSuccess, onFail);\r\n        });\r\n    }\r\n\r\n    private p" +
                               "rocess");

            #line 89 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("WithCallbacks(url: string, xhr: any, onSuccess?: any, onFail?: any): void {\r\n    " +
                               "    try {\r\n");

            #line 91 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    if (Model.UseTransformResultMethod)
                    {
            #line default
            #line hidden
                        this.Write("            let result = this.transformResult(url, xhr, (xhr) => this.process");

            #line 92 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(xhr));\r\n");

            #line 93 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("            let result = this.process");

            #line 94 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                        this.Write("(xhr);\r\n");

            #line 95 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("            if (onSuccess !== undefined)\r\n                onSuccess(result);\r\n   " +
                               "     } catch (e) {\r\n            if (onFail !== undefined)\r\n                onFai" +
                               "l(e, \"http_service_exception\");\r\n        }\r\n    }\r\n\r\n    protected process");

            #line 104 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ActualOperationNameUpper));

            #line default
            #line hidden
                    this.Write("(xhr: any): ");

            #line 104 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType));

            #line default
            #line hidden
                    this.Write(" {\r\n        const responseText = xhr.responseText; \r\n        const status = xhr.s" +
                               "tatus; \r\n\r\n        ");

            #line 108 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderProcessResponseCode(operation, 2)));

            #line default
            #line hidden
                    this.Write("\r\n    }\r\n");

            #line 110 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n    ");

            #line 112 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderClientMethodsCode(Model, 1)));

            #line default
            #line hidden
                this.Write("\r\n}\r\n");

            #line 114 "C:\Data\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\JQueryPromisesClientTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
Exemplo n.º 9
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("/* tslint:disable */\r\n//----------------------\r\n// <auto-generated>\r\n//     Gener" +
                       "ated using the NSwag toolchain v");

            #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion));

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

            #line 6 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\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// ReSharpe" +
                       "r disable InconsistentNaming\r\n\r\n");

            #line 11 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCodeImport));

            #line default
            #line hidden
            this.Write("\r\n");

            #line 12 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.ImportRequiredTypes)
            {
            #line default
            #line hidden

            #line 13 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsAngular)
                {
            #line default
            #line hidden
                    this.Write(@"
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/catch';

import { Observable } from 'rxjs/Observable';
import { Injectable, Inject, Optional, ");

            #line 24 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.InjectionTokenType));

            #line default
            #line hidden
                    this.Write(" } from \'@angular/core\';\r\n");

            #line 25 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    if (Model.UseAngularHttpClient)
                    {
            #line default
            #line hidden
                        this.Write("import { HttpClient, HttpHeaders, HttpResponse, HttpParams } from \'@angular/commo" +
                                   "n/http\';\r\n");

            #line 27 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("import { Http, Headers, ResponseContentType, Response");

            #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                        if (Model.UseTransformOptionsMethod)
                        {
            #line default
            #line hidden
                            this.Write(", RequestOptionsArgs");

            #line 28 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                        }

            #line default
            #line hidden
                        this.Write(" } from \'@angular/http\';\r\n");

            #line 29 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    }

            #line default
            #line hidden

            #line 30 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 31 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsAurelia)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport { inject } from \'aurelia-framework\';\r\nimport { HttpClient, RequestInit }" +
                               " from \'aurelia-fetch-client\';\r\n");

            #line 35 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 36 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsAngularJS)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport * as ng from \'angular\';\r\n");

            #line 39 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 40 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsKnockout)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport * as ko from \'knockout\';\r\n");

            #line 43 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.IsJQuery)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport * as jQuery from \'jquery\';\r\n");

            #line 47 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 48 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.RequiresMomentJS)
                {
            #line default
            #line hidden
                    this.Write("\r\nimport * as moment from \'moment\';\r\n");

            #line 51 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 52 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n");

            #line 54 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.HasModuleName)
            {
            #line default
            #line hidden
                this.Write("module ");

            #line 55 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.ModuleName));

            #line default
            #line hidden
                this.Write(" {\r\n");

            #line 56 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }
            if (Model.HasNamespace)
            {
            #line default
            #line hidden
                this.Write("namespace ");

            #line 58 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.Namespace));

            #line default
            #line hidden
                this.Write(" {\r\n");

            #line 59 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 60 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.GenerateClientClasses && Model.IsAngular)
            {
            #line default
            #line hidden
                this.Write("export const ");

            #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrlTokenName));

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

            #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.InjectionTokenType));

            #line default
            #line hidden

            #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.InjectionTokenType == "InjectionToken")
                {
            #line default
            #line hidden
                    this.Write("<string>");

            #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

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

            #line 61 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseUrlTokenName));

            #line default
            #line hidden
                this.Write("\');\r\n\r\n");

            #line 63 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 64 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCodeTop));

            #line default
            #line hidden
            this.Write("\r\n\r\n");

            #line 66 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.Clients));

            #line default
            #line hidden
            this.Write("\r\n\r\n");

            #line 68 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.Types));

            #line default
            #line hidden
            this.Write("\r\n\r\n");

            #line 70 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.WrapResponses && Model.GenerateResponseClasses)
            {
            #line default
            #line hidden

            #line 71 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                foreach (var responseClassName in Model.ResponseClassNames)
                {
            #line default
            #line hidden
                    this.Write("export class ");

            #line 72 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(responseClassName));

            #line default
            #line hidden
                    this.Write(@"<TResult> {
    status: number;
    headers: { [key: string]: any; };
    result: TResult;
        
    constructor(status: number, headers: { [key: string]: any; }, result: TResult) 
    {
        this.status = status;
        this.headers = headers;
        this.result = result;
    }
}

");

            #line 85 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 86 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 87 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.RequiresFileParameterInterface)
            {
            #line default
            #line hidden
                this.Write("export interface FileParameter {\r\n    data: any;\r\n    fileName: string;\r\n}\r\n\r\n");

            #line 93 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 94 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.RequiresFileResponseInterface)
            {
            #line default
            #line hidden
                this.Write("export interface FileResponse {\r\n    data: Blob;\r\n    status: number;\r\n    fileNa" +
                           "me?: string;\r\n    headers?: { [name: string]: any };\r\n}\r\n\r\n");

            #line 102 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 103 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.RequiresSwaggerExceptionClass)
            {
            #line default
            #line hidden
                this.Write(@"export class SwaggerException extends Error {
    message: string;
    status: number; 
    response: string; 
    headers: { [key: string]: any; };
    result: any; 

    constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) {
        super();

        this.message = message;
        this.status = status;
        this.response = response;
        this.headers = headers;
        this.result = result;
    }

    protected isSwaggerException = true;

    static isSwaggerException(obj: any): obj is SwaggerException {
        return obj.isSwaggerException === true;
    }
}

");

            #line 128 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 129 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.GenerateClientClasses)
            {
            #line default
            #line hidden

            #line 130 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeScriptTemplatePartGenerator.RenderClientMethodsCode(Model, 0)));

            #line default
            #line hidden
                this.Write("\r\n\r\n");

            #line 132 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                if (Model.HandleReferences)
                {
            #line default
            #line hidden

            #line 133 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(Model.ReferenceHandlingCode));

            #line default
            #line hidden
                    this.Write("\r\n");

            #line 134 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
                }

            #line default
            #line hidden

            #line 135 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden

            #line 136 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Model.ExtensionCodeBottom));

            #line default
            #line hidden
            this.Write("\r\n");

            #line 137 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            if (Model.HasNamespace)
            {
            #line default
            #line hidden
                this.Write("}\r\n");

            #line 139 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }
            if (Model.HasModuleName)
            {
            #line default
            #line hidden
                this.Write("}\r\n");

            #line 142 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\FileTemplate.tt"
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }