Skip to content

Commit

Permalink
[Javascript] v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
gideruette committed Sep 6, 2024
1 parent 6ce6def commit 0a87527
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
16 changes: 8 additions & 8 deletions TopModel.Generator.Javascript/AngularApiClientGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,14 @@ private void WriteEndpoint(Endpoint endpoint, FileWriter fw)
fw.WriteLine();
}

if (returnType == "string" || returnType == "Blob" || returnType == "ArrayBuffer")
var needResponseType = returnType == "string" || returnType == "Blob" || returnType == "ArrayBuffer";
var getter = $"this.http.{endpoint.Method.ToLower()}<{returnType}>";
if (needResponseType)
{
fw.Write(2, $@"return {(Config.ApiMode == TargetFramework.ANGULAR_PROMISE ? "lastValueFrom(" : string.Empty)}this.http.{endpoint.Method.ToLower()}(`/{fullRoute}`");
}
else
{
fw.Write(2, $@"return {(Config.ApiMode == TargetFramework.ANGULAR_PROMISE ? "lastValueFrom(" : string.Empty)}this.http.{endpoint.Method.ToLower()}<{returnType}>(`/{fullRoute}`");
getter = $"{endpoint.Method.ToLower()}(`/{fullRoute}`";
}

fw.Write(2, $@"return {(Config.ApiMode == TargetFramework.ANGULAR_PROMISE ? "lastValueFrom(" : string.Empty)}this.http.{getter}(`/{fullRoute}`");
if (endpoint.GetJsonBodyParam() != null)
{
fw.Write($", {endpoint.GetJsonBodyParam()!.GetParamName()}");
Expand All @@ -228,9 +227,10 @@ private void WriteEndpoint(Endpoint endpoint, FileWriter fw)
fw.Write(", {}");
}

if (returnType == "string" || returnType == "Blob" || returnType == "ArrayBuffer")
if (needResponseType)
{
fw.Write($", {{responseType: '{returnType.ToLower()}'}}");
var responseType = returnType == "string" ? "text" : returnType.ToLower();
fw.Write($", {{responseType: '{returnType.ToLower()}'}}");
}

if (endpoint.GetQueryParams().Any())
Expand Down
4 changes: 4 additions & 0 deletions TopModel.Generator.Javascript/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

## 1.0.5

- [#389](https://github.com/klee-contrib/topmodel/pull/389) - Prise en compte des returnType Blob et ArrayBuffer Hot fix

## 1.0.4

- [#389](https://github.com/klee-contrib/topmodel/pull/389) - Prise en compte des returnType Blob et ArrayBuffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PropertyGroup>
<PackageOutputPath>../.nupkg</PackageOutputPath>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>JabX;gideruette</Authors>
<Description>Générateurs JS/TS pour TopModel</Description>
Expand Down

0 comments on commit 0a87527

Please sign in to comment.