< Summary - Kestrun — Combined Coverage

Information
Class: Public.OpenAPI.Add-KrOpenApiExternalDoc
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/Add-KrOpenApiExternalDoc.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 51
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 12/12/2025 - 17:27:19 Line coverage: 0% (0/8) Total lines: 51 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds external documentation to the OpenAPI document.
 4.DESCRIPTION
 5    This function adds external documentation to the OpenAPI document using the provided parameters in the specified Ope
 6.PARAMETER Server
 7    The Kestrun server instance to which the OpenAPI external documentation 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 external documentation will be added. Default is 'default'.
 11.PARAMETER Description
 12    A description of the external documentation.
 13.PARAMETER Url
 14    A URI to the external documentation.
 15.EXAMPLE
 16    # Add external documentation to the default document
 17    Add-KrOpenApiExternalDoc -Description 'Find out more about our API here.' -Url 'https://example.com/api-docs'
 18.NOTES
 19    This cmdlet is part of the OpenAPI module.
 20#>
 21function Add-KrOpenApiExternalDoc {
 22    [KestrunRuntimeApi('Everywhere')]
 23    param(
 24        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 25        [Kestrun.Hosting.KestrunHost]$Server,
 26        [Parameter()]
 27        [string[]]$DocId = [Kestrun.Authentication.IOpenApiAuthenticationOptions]::DefaultDocumentationIds,
 28        [Parameter(Mandatory = $true)]
 29        [string]$Description,
 30        [Parameter(Mandatory = $true)]
 31        [Uri]$Url
 32    )
 33    begin {
 34        # Ensure the server instance is resolved
 035        $Server = Resolve-KestrunServer -Server $Server
 36    }
 37    process {
 38        # Add the server to the specified OpenAPI documents
 039        foreach ($doc in $DocId) {
 040            $docDescriptor = $Server.GetOrCreateOpenApiDocument($doc)
 041            $docDescriptor.Document.ExternalDocs = [Microsoft.OpenApi.OpenApiExternalDocs]::new()
 42
 043            if ($PsBoundParameters.ContainsKey('Description')) {
 044                $docDescriptor.Document.ExternalDocs.Description = $Description
 45            }
 046            if ($PsBoundParameters.ContainsKey('Url')) {
 047                $docDescriptor.Document.ExternalDocs.Url = $Url
 48            }
 49        }
 50    }
 51}

Methods/Properties

Add-KrOpenApiExternalDoc()