From a4750883f5341e4aaccac6cec8ab7102530a574f Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 20 Sep 2023 22:02:37 +0200 Subject: [PATCH] Fix HTTP Endpoint activity --- src/modules/Elsa.Http/Activities/HttpEndpoint.cs | 6 +++--- .../Elsa.Workflows.Core/Attributes/OutputAttribute.cs | 7 ++++++- src/modules/Elsa.Workflows.Core/Models/Argument.cs | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/modules/Elsa.Http/Activities/HttpEndpoint.cs b/src/modules/Elsa.Http/Activities/HttpEndpoint.cs index 5fd74177e..e674b0266 100644 --- a/src/modules/Elsa.Http/Activities/HttpEndpoint.cs +++ b/src/modules/Elsa.Http/Activities/HttpEndpoint.cs @@ -3,7 +3,6 @@ using Elsa.Expressions.Models; using Elsa.Extensions; using Elsa.Http.Bookmarks; using Elsa.Http.Contracts; -using Elsa.Http.Models; using Elsa.Workflows.Core; using Elsa.Workflows.Core.Attributes; using Elsa.Workflows.Core.Models; @@ -19,6 +18,7 @@ namespace Elsa.Http; /// Wait for an inbound HTTP request that matches the specified path and methods. /// [Activity("Elsa", "HTTP", "Wait for an inbound HTTP request that matches the specified path and methods.", DisplayName = "HTTP Endpoint")] +[Output(IsSerializable = false)] public class HttpEndpoint : Trigger { internal const string HttpContextInputKey = "HttpContext"; @@ -101,7 +101,7 @@ public class HttpEndpoint : Trigger /// /// The uploaded files, if any. /// - [Output(Description = "The uploaded files, if any.")] + [Output(Description = "The uploaded files, if any.", IsSerializable = false)] public Output Files { get; set; } = default!; /// @@ -212,7 +212,7 @@ public class HttpEndpoint : Trigger private IFormFileCollection ReadFilesAsync(ActivityExecutionContext context, HttpRequest request) { - return request.Form.Files; + return request.HasFormContentType ? request.Form.Files : new FormFileCollection(); } private async Task ValidateFileSizesAsync(ActivityExecutionContext context, HttpContext httpContext, IFormFileCollection files) diff --git a/src/modules/Elsa.Workflows.Core/Attributes/OutputAttribute.cs b/src/modules/Elsa.Workflows.Core/Attributes/OutputAttribute.cs index 1a1ba265d..c35fe8d79 100644 --- a/src/modules/Elsa.Workflows.Core/Attributes/OutputAttribute.cs +++ b/src/modules/Elsa.Workflows.Core/Attributes/OutputAttribute.cs @@ -1,6 +1,6 @@ namespace Elsa.Workflows.Core.Attributes; -[AttributeUsage(AttributeTargets.Property)] +[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)] public class OutputAttribute : Attribute { /// @@ -22,4 +22,9 @@ public class OutputAttribute : Attribute /// A value indicating whether this property should be visible. /// public bool IsBrowsable { get; set; } = true; + + /// + /// A value indicating whether this output can be serialized. + /// + public bool IsSerializable { get; set; } = true; } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/Models/Argument.cs b/src/modules/Elsa.Workflows.Core/Models/Argument.cs index 8176c0732..eaf543968 100644 --- a/src/modules/Elsa.Workflows.Core/Models/Argument.cs +++ b/src/modules/Elsa.Workflows.Core/Models/Argument.cs @@ -19,7 +19,7 @@ public abstract class Argument protected Argument(MemoryBlockReference memoryBlockReference) : this(() => memoryBlockReference) { } - + /// /// Initializes a new instance of the class. /// @@ -32,5 +32,6 @@ public abstract class Argument /// /// Gets or sets the memory block reference. /// - [JsonIgnore] public Func MemoryBlockReference { get; set; } = default!; + [JsonIgnore] + public Func MemoryBlockReference { get; set; } = default!; } \ No newline at end of file