< Summary

Information
Class: Elsa.Api.Client.RefitSettingsHelper
Assembly: Elsa.Api.Client
File(s): /home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/Helpers/RefitSettingsHelper.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 44
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CreateRefitSettings(...)100%11100%
CreateJsonSerializerOptions(...)50%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/Helpers/RefitSettingsHelper.cs

#LineLine coverage
 1using System.Text.Json;
 2using System.Text.Json.Serialization;
 3using Elsa.Api.Client.Converters;
 4using Refit;
 5
 6namespace Elsa.Api.Client;
 7
 8/// <summary>
 9/// Contains helper methods for configuring Refit settings.
 10/// </summary>
 11public static class RefitSettingsHelper
 12{
 13    /// <summary>
 14    /// Creates a <see cref="RefitSettings"/> instance configured for Elsa.
 15    /// </summary>
 16    public static RefitSettings CreateRefitSettings(IServiceProvider serviceProvider, Action<IServiceProvider, JsonSeria
 17    {
 1418        var settings = new RefitSettings
 1419        {
 1420            ContentSerializer = new SystemTextJsonContentSerializer(CreateJsonSerializerOptions(serviceProvider, configu
 1421        };
 22
 1423        return settings;
 24    }
 25
 26    /// <summary>
 27    /// Creates a <see cref="JsonSerializerOptions"/> instance configured for Elsa.
 28    /// </summary>
 29    public static JsonSerializerOptions CreateJsonSerializerOptions(IServiceProvider serviceProvider, Action<IServicePro
 30    {
 2531        var options = new JsonSerializerOptions
 2532        {
 2533            PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
 2534        };
 35
 2536        options.Converters.Add(new JsonStringEnumConverter());
 2537        options.Converters.Add(new VersionOptionsJsonConverter());
 2538        options.Converters.Add(new TypeJsonConverter());
 39
 2540        configureJsonSerializerOptions?.Invoke(serviceProvider, options);
 41
 2542        return options;
 43    }
 44}