From bf5f885ae5a15369efcca28b01b889919289ce53 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 11 Sep 2024 14:21:19 +0200 Subject: [PATCH] fix(Runner): Fixed the OpenApiCallProcessor to interpolate and evaluate the endpoint URI before performing the request Signed-off-by: Charles d'Avernas --- src/core/Synapse.Core/Synapse.Core.csproj | 2 +- .../Synapse.Runner/Services/Executors/OpenApiCallExecutor.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/Synapse.Core/Synapse.Core.csproj b/src/core/Synapse.Core/Synapse.Core.csproj index b9cb14f6b..905b585c2 100644 --- a/src/core/Synapse.Core/Synapse.Core.csproj +++ b/src/core/Synapse.Core/Synapse.Core.csproj @@ -15,7 +15,7 @@ Copyright © 2024-Present The Synapse Authors. All Rights Reserved. https://github.com/serverlessworkflow/synapse git - Synapse + Synapse.Sdk https://github.com/serverlessworkflow/synapse synapse core true diff --git a/src/runner/Synapse.Runner/Services/Executors/OpenApiCallExecutor.cs b/src/runner/Synapse.Runner/Services/Executors/OpenApiCallExecutor.cs index 8b96b2071..5558a938d 100644 --- a/src/runner/Synapse.Runner/Services/Executors/OpenApiCallExecutor.cs +++ b/src/runner/Synapse.Runner/Services/Executors/OpenApiCallExecutor.cs @@ -16,7 +16,6 @@ using Microsoft.OpenApi.Readers; using Neuroglia; using Neuroglia.Data.Expressions; -using Neuroglia.Data.Infrastructure.ResourceOriented; using System.Net.Mime; using System.Text; @@ -110,7 +109,9 @@ protected override async Task DoInitializeAsync(CancellationToken cancellationTo this.OpenApi = (OpenApiCallDefinition)this.JsonSerializer.Convert(this.Task.Definition.With, typeof(OpenApiCallDefinition))!; using var httpClient = this.HttpClientFactory.CreateClient(); await httpClient.ConfigureAuthenticationAsync(this.Task.Workflow.Definition, this.OpenApi.Document.Endpoint.Authentication, this.ServiceProvider, cancellationToken).ConfigureAwait(false); - using var request = new HttpRequestMessage(HttpMethod.Get, this.OpenApi.Document.EndpointUri); + var uri = StringFormatter.NamedFormat(this.OpenApi.Document.EndpointUri.OriginalString, this.Task.Input.ToDictionary()); + if (uri.IsRuntimeExpression()) uri = await this.Task.Workflow.Expressions.EvaluateAsync(uri, this.Task.Input, this.Task.Arguments, cancellationToken).ConfigureAwait(false); + using var request = new HttpRequestMessage(HttpMethod.Get, uri); using var response = await httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false); if (!response.IsSuccessStatusCode) {