From 5048640a53ec1bfae31c37fb51fd823f3585ea84 Mon Sep 17 00:00:00 2001 From: MattMo Date: Thu, 20 Apr 2023 16:31:41 -0700 Subject: [PATCH] Bumped package version to 1.5.4, changed @method to use @function in client generator for javascript. Added blob support for requests. --- Rest.Net/Rest.Net.csproj | 2 +- Rest.Net/RestJavascriptClientGenerator.cs | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Rest.Net/Rest.Net.csproj b/Rest.Net/Rest.Net.csproj index b2a986c..9a31045 100644 --- a/Rest.Net/Rest.Net.csproj +++ b/Rest.Net/Rest.Net.csproj @@ -17,7 +17,7 @@ MontoyaTech.Rest.Net MontoyaTech.Rest.Net True - 1.5.3 + 1.5.4 Logo_Symbol_Black_Outline.png diff --git a/Rest.Net/RestJavascriptClientGenerator.cs b/Rest.Net/RestJavascriptClientGenerator.cs index 03e5d28..59a623e 100644 --- a/Rest.Net/RestJavascriptClientGenerator.cs +++ b/Rest.Net/RestJavascriptClientGenerator.cs @@ -170,6 +170,10 @@ namespace MontoyaTech.Rest.Net return builder.ToString(); } + else if (type.IsAssignableTo(typeof(Stream))) + { + return "Blob"; + } else if (typeCode == TypeCode.String || typeCode == TypeCode.Char) { return "string"; @@ -259,7 +263,7 @@ namespace MontoyaTech.Rest.Net if (!type.IsEnum) { writer.WriteBreak().WriteLine("/**").Indent(); - writer.WriteLine("@method"); + writer.WriteLine("@function"); foreach (var field in fields) writer.WriteLine($"@param {{{this.GetTypeFullyResolvedName(field.FieldType)}}} {field.Name}"); @@ -292,7 +296,7 @@ namespace MontoyaTech.Rest.Net { writer.WriteBreak().WriteLine("/**").Indent(); writer.WriteLine("Returns the names of this enums values in an array."); - writer.WriteLine("@method"); + writer.WriteLine("@function"); writer.WriteLine("@returns {Array}"); writer.Outdent().WriteLine("*/"); writer.WriteLine("static GetNames() {").Indent(); @@ -307,7 +311,7 @@ namespace MontoyaTech.Rest.Net writer.WriteBreak().WriteLine("/**").Indent(); writer.WriteLine("Returns the values of this enum in an arrray."); - writer.WriteLine("@method"); + writer.WriteLine("@function"); writer.WriteLine("@returns {Array}"); writer.Outdent().WriteLine("*/"); writer.WriteLine("static GetValues() {").Indent(); @@ -322,7 +326,7 @@ namespace MontoyaTech.Rest.Net writer.WriteBreak().WriteLine("/**").Indent(); writer.WriteLine("Returns the names and values of this enum in an array."); - writer.WriteLine("@method"); + writer.WriteLine("@function"); writer.WriteLine("@returns {Array} Where each element has a name and value key."); writer.Outdent().WriteLine("*/"); writer.WriteLine("static GetNamesValues() {").Indent(); @@ -399,7 +403,7 @@ namespace MontoyaTech.Rest.Net writer.WriteBreak(); writer.WriteLine("/**").Indent(); - writer.WriteLine("@method"); + writer.WriteLine("@function"); writer.WriteLine($"@param {{{this.ClientName}}} client"); writer.Outdent().WriteLine("*/"); @@ -440,7 +444,7 @@ namespace MontoyaTech.Rest.Net //Generate the function jsdoc tags writer.WriteLine("/**").Indent(); - writer.WriteLine("@method"); + writer.WriteLine("@function"); writer.WriteLine("@async"); writer.WriteLine($"@name {(routeName == null ? methodInfo.Name : routeName.Name)}"); @@ -540,10 +544,12 @@ namespace MontoyaTech.Rest.Net { if (routeRequest.RequestType.IsAssignableTo(typeof(Stream))) { - //TODO + writer.WriteLine("headers: new Headers({ 'Content-Type': 'application/octet-stream' }),"); + writer.WriteLine("body: request,"); } else if (routeRequest.Json) { + writer.WriteLine("body: JSON.stringify(request),"); } else