< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.OpenApi.OpenApiSchemaDiscovery
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/OpenApi/OpenApiSchemaDiscovery.cs
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 69
Line coverage: 100%
Branch coverage
83%
Covered branches: 10
Total branches: 12
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 12/12/2025 - 17:27:19 Line coverage: 0% (0/26) Branch coverage: 0% (0/14) Total lines: 67 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/25/2025 - 19:20:44 Line coverage: 0% (0/24) Branch coverage: 0% (0/14) Total lines: 65 Tag: Kestrun/Kestrun@5251f12f253e29f8a1dfb77edc2ef50b90a4f26f01/02/2026 - 21:56:10 Line coverage: 0% (0/27) Branch coverage: 0% (0/16) Total lines: 69 Tag: Kestrun/Kestrun@f60326065ebb24cf70b241e459b37baf142e6ed601/12/2026 - 18:03:06 Line coverage: 100% (27/27) Branch coverage: 87.5% (14/16) Total lines: 69 Tag: Kestrun/Kestrun@956332ccc921363590dccd99d5707fb20b50966b01/18/2026 - 21:37:07 Line coverage: 100% (25/25) Branch coverage: 83.3% (10/12) Total lines: 69 Tag: Kestrun/Kestrun@99c4ae445e8e5afc8b7080e01d5d9cdf39f972b8 12/12/2025 - 17:27:19 Line coverage: 0% (0/26) Branch coverage: 0% (0/14) Total lines: 67 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/25/2025 - 19:20:44 Line coverage: 0% (0/24) Branch coverage: 0% (0/14) Total lines: 65 Tag: Kestrun/Kestrun@5251f12f253e29f8a1dfb77edc2ef50b90a4f26f01/02/2026 - 21:56:10 Line coverage: 0% (0/27) Branch coverage: 0% (0/16) Total lines: 69 Tag: Kestrun/Kestrun@f60326065ebb24cf70b241e459b37baf142e6ed601/12/2026 - 18:03:06 Line coverage: 100% (27/27) Branch coverage: 87.5% (14/16) Total lines: 69 Tag: Kestrun/Kestrun@956332ccc921363590dccd99d5707fb20b50966b01/18/2026 - 21:37:07 Line coverage: 100% (25/25) Branch coverage: 83.3% (10/12) Total lines: 69 Tag: Kestrun/Kestrun@99c4ae445e8e5afc8b7080e01d5d9cdf39f972b8

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetOpenApiTypesAuto()100%11100%
GetRelevantAssemblies()50%44100%
GetSchemaTypes(...)100%88100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/OpenApi/OpenApiSchemaDiscovery.cs

#LineLine coverage
 1// OpenApiSchemaDiscovery.cs
 2namespace Kestrun.OpenApi;
 3
 4/// <summary>
 5/// Helper to discover OpenAPI schema types in loaded assemblies.
 6/// </summary>
 7public static class OpenApiSchemaDiscovery
 8{
 9    /// <summary>
 10    /// Discover all OpenAPI component types from dynamic PowerShell classes.
 11    /// Scans all loaded assemblies for classes decorated with OpenApiModelKindAttribute
 12    /// or having any OpenApi* attributes.
 13    /// </summary>
 14    /// <returns> The discovered OpenAPI component types.</returns>
 15    public static OpenApiComponentSet GetOpenApiTypesAuto()
 16    {
 317        var assemblies = GetRelevantAssemblies();
 318        return new OpenApiComponentSet
 319        {
 320            SchemaTypes = GetSchemaTypes(assemblies),
 321#if EXTENDED_OPENAPI
 322            RequestBodyTypes = GetTypesWithAttribute(assemblies, typeof(OpenApiRequestBodyComponentAttribute)),
 323            ResponseTypes = GetTypesWithAttribute(assemblies, typeof(OpenApiResponseComponentAttribute)),
 324            ParameterTypes = GetTypesWithAttribute(assemblies, typeof(OpenApiParameterComponentAttribute)),
 325            HeaderTypes = GetTypesWithAttribute(assemblies, typeof(OpenApiHeaderAttribute)),
 326            SecuritySchemeTypes = GetTypesWithAttribute(assemblies, typeof(OpenApiSecuritySchemeComponent)),
 327            CallbackTypes = GetTypesWithKind(assemblies, OpenApiModelKind.Callback),
 328            PathItemTypes = GetTypesWithKind(assemblies, OpenApiModelKind.PathItem)
 329#endif
 330        };
 31    }
 32
 33    private static System.Reflection.Assembly[] GetRelevantAssemblies()
 34    {
 335        return [.. AppDomain.CurrentDomain.GetAssemblies()
 97236            .Where(a => a.FullName is not null &&
 97237                    (a.FullName.Contains("PowerShell Class Assembly") ||
 97238                        a.FullName.StartsWith("Kestrun")))];
 39    }
 40
 41    private static Type[] GetSchemaTypes(System.Reflection.Assembly[] assemblies)
 42    {
 343        var primitivesAssembly = typeof(OpenApiString).Assembly;
 44
 1245        return [.. assemblies.SelectMany(asm => asm.GetTypes())
 552946            .Where(t => t.IsClass && !t.IsAbstract &&
 552947                    t.IsDefined(typeof(OpenApiSchemaComponent), true) &&
 552948                    // Exclude built-in OpenApi* primitives from auto-discovered components,
 552949                    // but keep user-defined schema components that inherit those primitives.
 552950                    !(t.Assembly == primitivesAssembly && typeof(IOpenApiScalar).IsAssignableFrom(t)))];
 51    }
 52
 53#if EXTENDED_OPENAPI
 54
 55   private static Type[] GetTypesWithAttribute(System.Reflection.Assembly[] assemblies, Type attributeType)
 56    {
 57        return [.. assemblies.SelectMany(asm => asm.GetTypes())
 58            .Where(t => t.IsClass && !t.IsAbstract && t.IsDefined(attributeType, true))];
 59    }
 60    private static Type[] GetTypesWithKind(System.Reflection.Assembly[] assemblies, OpenApiModelKind kind)
 61    {
 62        return [.. assemblies.SelectMany(asm => asm.GetTypes())
 63            .Where(t => t.IsClass && !t.IsAbstract &&
 64                t.GetCustomAttributes(typeof(OpenApiModelKindAttribute), true)
 65                 .OfType<OpenApiModelKindAttribute>()
 66                 .Any(a => a.Kind == kind))];
 67    }
 68#endif
 69}