< Summary - Kestrun — Combined Coverage

Information
Class: Public.OpenAPI.Add-KrOpenApiContact
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/Add-KrOpenApiContact.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 74
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/13) Total lines: 64 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd01/17/2026 - 18:18:02 Line coverage: 0% (0/6) Total lines: 74 Tag: Kestrun/Kestrun@8dd16f7908c0e15b594d16bb49be0240e2c7c018

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds contact information to the OpenAPI document.
 4.DESCRIPTION
 5    This function adds contact information to the OpenAPI Info section using the provided parameters in the specified Op
 6.PARAMETER Server
 7    The Kestrun server instance to which the OpenAPI contact information 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 contact information will be added. Default is 'default'.
 11.PARAMETER Name
 12    The name of the contact person/organization.
 13.PARAMETER Url
 14    The URL of the contact person/organization.
 15.PARAMETER Email
 16    The email address of the contact person/organization.
 17.PARAMETER Extensions
 18    A collection of OpenAPI extensions to add to the contact information.
 19.EXAMPLE
 20    # Add contact information to the default document
 21    Add-KrOpenApiContact -Name "John Doe" -Url "https://johndoe.com" -Email "john.doe@example.com"
 22    Adds contact information with the specified name, URL, and email to the default OpenAPI document.
 23.EXAMPLE
 24    # Add contact information to multiple documents
 25    Add-KrOpenApiContact -DocId @('Default', 'v2') -Name "API Support" -Email "support@example.com"
 26    Adds contact information with the specified name and email to both the 'Default' and 'v2' OpenAPI documents.
 27.EXAMPLE
 28    # Add contact information with extensions
 29    $extensions = [ordered]@{
 30        'x-contact-type' = 'technical'
 31        'x-timezone' = 'PST'
 32    }
 33    Add-KrOpenApiContact -Name "Tech Support" -Email "techsupport@example.com" -Extensions $extensions
 34    Adds contact information with the specified name, email, and extensions to the default OpenAPI document.
 35.NOTES
 36    This cmdlet is part of the OpenAPI module.
 37#>
 38function Add-KrOpenApiContact {
 39    [KestrunRuntimeApi('Definition')]
 40    param(
 41        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 42        [Kestrun.Hosting.KestrunHost]$Server,
 43
 44        [Parameter()]
 45        [string[]]$DocId = [Kestrun.OpenApi.OpenApiDocDescriptor]::DefaultDocumentationIds,
 46
 47        [Parameter()]
 48        [string]$Name,
 49
 50        [Parameter()]
 51        [Uri]$Url,
 52
 53        [Parameter()]
 54        [string]$Email,
 55
 56        [Parameter()]
 57        [System.Collections.IDictionary]$Extensions = $null
 58    )
 59    begin {
 60        # Ensure the server instance is resolved
 061        $Server = Resolve-KestrunServer -Server $Server
 62    }
 63    process {
 64        # Add the server to the specified OpenAPI documents
 065        foreach ($doc in $DocId) {
 066            $docDescriptor = $Server.GetOrCreateOpenApiDocument($doc)
 067            if ($null -eq $docDescriptor.Document.Info) {
 68                # Initialize the Info object if null
 069                $docDescriptor.Document.Info = [Microsoft.OpenApi.OpenApiInfo]::new()
 70            }
 071            $docDescriptor.Document.Info.Contact = $docDescriptor.CreateInfoContact($Name, $Url, $Email, $Extensions)
 72        }
 73    }
 74}

Methods/Properties

Add-KrOpenApiContact()