< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.ActivityDescriptorOptions.Get.Get
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/ActivityDescriptorOptions/Get/Endpoint.cs
Line coverage
44%
Covered lines: 8
Uncovered lines: 10
Coverable lines: 18
Total lines: 48
Line coverage: 44.4%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure()100%11100%
HandleAsync()0%4260%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/ActivityDescriptorOptions/Get/Endpoint.cs

#LineLine coverage
 1using Elsa.Authorization;
 2using Elsa.Abstractions;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Workflows.Api.Endpoints.ActivityDescriptorOptions.Get;
 6
 7[PublicAPI]
 8internal class Get : ElsaEndpoint<Request, Response>
 9{
 10    private readonly IServiceProvider _serviceProvider;
 11    private readonly IActivityRegistryLookupService _registryLookup;
 12    private readonly IPropertyUIHandlerResolver _optionsResolver;
 13
 14    /// <inheritdoc />
 315    public Get(IServiceProvider serviceProvider, IActivityRegistryLookupService registryLookup, IPropertyUIHandlerResolv
 16    {
 317        _serviceProvider = serviceProvider;
 318        _registryLookup = registryLookup;
 319        _optionsResolver = optionsResolver;
 320    }
 21
 22    /// <inheritdoc />
 23    public override void Configure()
 24    {
 325        Post("/descriptors/activities/{activityTypeName}/options/{propertyName}");
 326        RequirePermission(Elsa.Workflows.Api.Permissions.WorkflowPermissions.DescriptorsActivities, CoreVerbs.View);
 327    }
 28
 29    /// <inheritdoc />
 30    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 31    {
 032        var descriptor = request.Version == null ? await _registryLookup.FindAsync(request.ActivityTypeName) : await _re
 033        if (descriptor == null)
 034            await Send.NotFoundAsync(cancellationToken);
 35
 036        var propertyDescriptor =  descriptor!.Inputs.FirstOrDefault(x => x.Name == request.PropertyName);
 37
 038        if(propertyDescriptor == null)
 39        {
 040            await Send.NotFoundAsync(cancellationToken);
 041            return;
 42        }
 43
 044        var inputOptions = await _optionsResolver.GetUIPropertiesAsync(propertyDescriptor.PropertyInfo!, request.Context
 45
 046        await Send.OkAsync(new Response(inputOptions), cancellationToken);
 047    }
 48}