diff --git a/src/designer/elsa-workflows-designer/src/components/inputs/check-list.tsx b/src/designer/elsa-workflows-designer/src/components/inputs/check-list.tsx index 28b233692..134a2d49f 100644 --- a/src/designer/elsa-workflows-designer/src/components/inputs/check-list.tsx +++ b/src/designer/elsa-workflows-designer/src/components/inputs/check-list.tsx @@ -34,7 +34,7 @@ export class CheckList { const displayName = inputDescriptor.displayName; const hint = inputDescriptor.description; const input = getInputPropertyValue(inputContext); - const value = (input?.expression as LiteralExpression)?.value; // TODO: The "value" field is currently hardcoded, but we should be able to be more flexible and potentially have different fields for a given syntax. + const value = (input?.expression as JsonExpression)?.value; // TODO: The "value" field is currently hardcoded, but we should be able to be more flexible and potentially have different fields for a given syntax. const syntax = input?.expression?.type ?? inputDescriptor.defaultSyntax; const selectList = this.selectList; diff --git a/src/modules/Elsa.Expressions/Models/JsonLiteral.cs b/src/modules/Elsa.Expressions/Models/JsonLiteral.cs new file mode 100644 index 000000000..e38cf5836 --- /dev/null +++ b/src/modules/Elsa.Expressions/Models/JsonLiteral.cs @@ -0,0 +1,31 @@ +using System.Text.Json; + +namespace Elsa.Expressions.Models; + +public class JsonLiteral : MemoryBlockReference +{ + public JsonLiteral() + { + } + + public JsonLiteral(string? value) + { + Value = value; + } + + public string? Value { get; } + public override MemoryBlock Declare() => new(); + + public static JsonLiteral From(T value) => new JsonLiteral(value); +} + +public class JsonLiteral : JsonLiteral +{ + public JsonLiteral() + { + } + + public JsonLiteral(T value) : base(JsonSerializer.Serialize(value!)) + { + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions/Models/Literal.cs b/src/modules/Elsa.Expressions/Models/Literal.cs index fd5ce075e..768002e50 100644 --- a/src/modules/Elsa.Expressions/Models/Literal.cs +++ b/src/modules/Elsa.Expressions/Models/Literal.cs @@ -26,6 +26,4 @@ public class Literal : Literal public Literal(T value) : base(value!) { } - - //public new T? Get(ActivityExecutionContext context) => (T?)base.Get(context); } \ No newline at end of file diff --git a/src/modules/Elsa.Http/Activities/HttpEndpoint.cs b/src/modules/Elsa.Http/Activities/HttpEndpoint.cs index efb75454e..a3b7d6ae2 100644 --- a/src/modules/Elsa.Http/Activities/HttpEndpoint.cs +++ b/src/modules/Elsa.Http/Activities/HttpEndpoint.cs @@ -4,6 +4,7 @@ using Elsa.Extensions; using Elsa.Http.Models; using Elsa.Http.Services; using Elsa.Workflows.Core.Attributes; +using Elsa.Workflows.Core.Expressions; using Elsa.Workflows.Core.Models; using Elsa.Workflows.Management.Models; using Microsoft.AspNetCore.Http; @@ -40,7 +41,7 @@ public class HttpEndpoint : Trigger Description = "The HTTP methods to accept.", Options = new[] { "GET", "POST", "PUT", "HEAD", "DELETE" }, UIHint = InputUIHints.CheckList)] - public Input> SupportedMethods { get; set; } = new(new[] { HttpMethod.Get.Method }); + public Input> SupportedMethods { get; set; } = new(JsonLiteral.From(new[]{HttpMethods.Get})); /// /// Allow authenticated requests only. diff --git a/src/modules/Elsa.Workflows.Core/Expressions/JsonExpression.cs b/src/modules/Elsa.Workflows.Core/Expressions/JsonExpression.cs index ae18d5ac2..9412732c8 100644 --- a/src/modules/Elsa.Workflows.Core/Expressions/JsonExpression.cs +++ b/src/modules/Elsa.Workflows.Core/Expressions/JsonExpression.cs @@ -11,9 +11,9 @@ public class JsonExpression : IExpression public string? Value { get; } } -public class JsonExpression : LiteralExpression +public class JsonExpression : JsonExpression { - public JsonExpression(T? value) : base(value) + public JsonExpression(T? value) : base(JsonSerializer.Serialize(value)) { } } diff --git a/src/modules/Elsa.Workflows.Core/Models/Input.cs b/src/modules/Elsa.Workflows.Core/Models/Input.cs index 76ee4b4c2..03c0ea727 100644 --- a/src/modules/Elsa.Workflows.Core/Models/Input.cs +++ b/src/modules/Elsa.Workflows.Core/Models/Input.cs @@ -56,6 +56,14 @@ public class Input : Input public Input(Literal literal) : base(new LiteralExpression(literal.Value), literal, typeof(T)) { } + + public Input(JsonLiteral literal) : base(new JsonExpression(literal.Value), literal, typeof(T)) + { + } + + public Input(JsonLiteral literal) : base(new JsonExpression(literal.Value), literal, typeof(T)) + { + } public Input(DelegateBlockReference delegateBlockReference) : base(new DelegateExpression(delegateBlockReference), delegateBlockReference, typeof(T)) {