< 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@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
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/13) Total lines: 64 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

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.EXAMPLE
 18    # Add contact information to the default document
 19    Add-KrOpenApiContact -Name "John Doe" -Url "https://johndoe.com" -Email "john.doe@example.com"
 20.NOTES
 21    This cmdlet is part of the OpenAPI module.
 22#>
 23function Add-KrOpenApiContact {
 24    [KestrunRuntimeApi('Everywhere')]
 25    param(
 26        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 27        [Kestrun.Hosting.KestrunHost]$Server,
 28        [Parameter()]
 29        [string[]]$DocId = [Kestrun.Authentication.IOpenApiAuthenticationOptions]::DefaultDocumentationIds,
 30        [Parameter()]
 31        [string]$Name,
 32        [Parameter()]
 33        [Uri]$Url,
 34        [Parameter()]
 35        [string]$Email
 36    )
 37    begin {
 38        # Ensure the server instance is resolved
 039        $Server = Resolve-KestrunServer -Server $Server
 40    }
 41    process {
 42        # Add the server to the specified OpenAPI documents
 043        foreach ($doc in $DocId) {
 044            $docDescriptor = $Server.GetOrCreateOpenApiDocument($doc)
 045            if ($null -eq $docDescriptor.Document.Info) {
 46                # Initialize the Info object if null
 047                $docDescriptor.Document.Info = [Microsoft.OpenApi.OpenApiInfo]::new()
 48            }
 049            if ($null -eq $docDescriptor.Document.Info.Contact) {
 50                # Initialize the Contact object if null
 051                $docDescriptor.Document.Info.Contact = [Microsoft.OpenApi.OpenApiContact]::new()
 52            }
 053            if ($PsBoundParameters.ContainsKey('Name')) {
 054                $docDescriptor.Document.Info.Contact.Name = $Name
 55            }
 056            if ($PsBoundParameters.ContainsKey('Url')) {
 057                $docDescriptor.Document.Info.Contact.Url = $Url
 58            }
 059            if ($PsBoundParameters.ContainsKey('Email')) {
 060                $docDescriptor.Document.Info.Contact.Email = $Email
 61            }
 62        }
 63    }
 64}

Methods/Properties

Add-KrOpenApiContact()