< 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@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 64
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@826bf9dcf9db118c5de4c78a3259bce9549f0dcd01/11/2026 - 19:55:44 Line coverage: 0% (0/4) Total lines: 64 Tag: Kestrun/Kestrun@53c97a4806941d5aa8d4dcc6779071adf1ae5376

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds an OpenAPI External Documentation object to specified OpenAPI documents.
 4.DESCRIPTION
 5    This function adds an OpenAPI External Documentation object to the specified OpenAPI documents in the Kestrun server
 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 Url
 12    A URI to the external documentation.
 13.PARAMETER Description
 14    A description of the external documentation.
 15.PARAMETER Extensions
 16    A collection of OpenAPI extensions to add to the external documentation.
 17.EXAMPLE
 18    # Add external documentation to the default document
 19    Add-KrOpenApiExternalDoc -Description 'Find out more about our API here.' -Url 'https://example.com/api-docs'
 20    Adds external documentation with the specified description and URL to the default OpenAPI document.
 21.EXAMPLE
 22    # Add external documentation to multiple documents
 23    Add-KrOpenApiExternalDoc -DocId @('Default', 'v2') -Description 'API Docs' -Url 'https://example.com/docs'
 24    Adds external documentation with the specified description and URL to both the 'Default' and 'v2' OpenAPI documents.
 25.EXAMPLE
 26    # Add external documentation with extensions
 27    $extensions = [ordered]@{
 28        'x-doc-type' = 'comprehensive'
 29        'x-contact' = 'Admin Team'
 30    }
 31    Add-KrOpenApiExternalDoc -Description 'Comprehensive API docs' -Url 'https://example.com/full-api-docs' -Extensions 
 32    Adds external documentation with the specified description, URL, and extensions to the default OpenAPI document.
 33.NOTES
 34    This cmdlet is part of the OpenAPI module.
 35#>
 36function Add-KrOpenApiExternalDoc {
 37    [KestrunRuntimeApi('Definition')]
 38    param(
 39        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 40        [Kestrun.Hosting.KestrunHost]$Server,
 41        [Parameter()]
 42        [string[]]$DocId = [Kestrun.OpenApi.OpenApiDocDescriptor]::DefaultDocumentationIds,
 43
 44        [Parameter(Mandatory = $true)]
 45        [Uri]$Url,
 46
 47        [Parameter(Mandatory = $false)]
 48        [string]$Description,
 49
 50        [Parameter()]
 51        [System.Collections.Specialized.OrderedDictionary]$Extensions
 52    )
 53    begin {
 54        # Ensure the server instance is resolved
 055        $Server = Resolve-KestrunServer -Server $Server
 56    }
 57    process {
 58        # Add the external documentation to the specified OpenAPI documents
 059        foreach ($doc in $DocId) {
 060            $docDescriptor = $Server.GetOrCreateOpenApiDocument($doc)
 061            $docDescriptor.Document.ExternalDocs = $docDescriptor.CreateExternalDocs($Url, $Description, $Extensions)
 62        }
 63    }
 64}

Methods/Properties

Add-KrOpenApiExternalDoc()