< Summary - Kestrun — Combined Coverage

Information
Class: Public.OpenAPI.Add-KrOpenApiExtension
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/Add-KrOpenApiExtension.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 57
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 01/18/2026 - 06:40:41 Line coverage: 0% (0/4) Total lines: 57 Tag: Kestrun/Kestrun@99e92690d0fd95f6f4896f3410d2c024350a9794

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/Add-KrOpenApiExtension.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds an OpenAPI extension to specified OpenAPI documents.
 4.DESCRIPTION
 5    This function adds an OpenAPI extension to the specified OpenAPI documents in the Kestrun server.
 6.PARAMETER Server
 7    The Kestrun server instance to which the OpenAPI extension will be added.
 8    If not specified, the function will attempt to resolve the current server context.
 9.PARAMETER DocId
 10    An array of OpenAPI document IDs to which the extension will be added. Default is 'default'.
 11.PARAMETER Extensions
 12    A collection of OpenAPI extensions to add.
 13.EXAMPLE
 14    # Add an extension to the default document
 15    $extensions = [ordered]@{
 16        'x-logo' = @{
 17            'url' = 'https://example.com/logo.png'
 18            'backgroundColor' = '#FFFFFF'
 19            'altText' = 'Company Logo'
 20        }
 21    }
 22    Add-KrOpenApiExtension -Extensions $extensions
 23    Adds the specified extension to the default OpenAPI document.
 24.EXAMPLE
 25    # Add an extension to multiple documents
 26    $extensions = [ordered]@{
 27        'x-api-status' = 'beta'
 28    }
 29    Add-KrOpenApiExtension -DocId @('Default', 'v2') -Extensions $extensions
 30    Adds the specified extension to both the 'Default' and 'v2' OpenAPI documents.
 31 .NOTES
 32    This cmdlet is part of the OpenAPI module.
 33#>
 34function Add-KrOpenApiExtension {
 35    [KestrunRuntimeApi('Definition')]
 36    param(
 37        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 38        [Kestrun.Hosting.KestrunHost]$Server,
 39
 40        [Parameter()]
 41        [string[]]$DocId = [Kestrun.OpenApi.OpenApiDocDescriptor]::DefaultDocumentationIds,
 42
 43        [Parameter(Mandatory = $true)]
 44        [System.Collections.IDictionary]$Extensions
 45    )
 46    begin {
 47        # Ensure the server instance is resolved
 048        $Server = Resolve-KestrunServer -Server $Server
 49    }
 50    process {
 51        # Add the extension to the specified OpenAPI documents
 052        foreach ($doc in $DocId) {
 053            $docDescriptor = $Server.GetOrCreateOpenApiDocument($doc)
 054            $docDescriptor.AddOpenApiExtension($Extensions)
 55        }
 56    }
 57}

Methods/Properties

Add-KrOpenApiExtension()