< Summary - Kestrun — Combined Coverage

Information
Class: Public.OpenAPI.New-KrOpenApiServerVariable
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/New-KrOpenApiServerVariable.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 66
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/11) Total lines: 64 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/28/2025 - 21:05:19 Line coverage: 0% (0/11) Total lines: 66 Tag: Kestrun/Kestrun@1f86b77fc2bddfa8444a4bce466be6fec80b6db7

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/New-KrOpenApiServerVariable.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Creates a new OpenAPI server variable.
 4.DESCRIPTION
 5    This function creates a new OpenAPI server variable using the provided parameters.
 6.PARAMETER Variables
 7    An optional OrderedDictionary to accumulate server variables.
 8.PARAMETER Name
 9    The name of the server variable.
 10.PARAMETER Default
 11    The default value for the server variable.
 12.PARAMETER Enum
 13    An array of possible values for the server variable.
 14.PARAMETER Description
 15    A description of the server variable.
 16.EXAMPLE
 17    $variable = New-KrOpenApiServerVariable -Default 'dev' -Enum @('dev', 'staging', 'prod') -Description 'Environment n
 18.OUTPUTS
 19    Microsoft.OpenApi.OpenApiServerVariable
 20#>
 21function New-KrOpenApiServerVariable {
 22    [Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')]
 23    [KestrunRuntimeApi('Definition')]
 24    [CmdletBinding()]
 25    param(
 26        [Parameter(ValueFromPipeline = $true, Position = 0)]
 27        [System.Collections.Specialized.OrderedDictionary] $Variables,
 28
 29        [Parameter(Mandatory = $true)]
 30        [string] $Name,
 31
 32        [Parameter()]
 33        [string] $Default,
 34
 35        [Parameter()]
 36        [string[]] $Enum,
 37
 38        [Parameter()]
 39        [string] $Description
 40    )
 41
 42    begin {
 043        $dict = $null
 44    }
 45
 46    process {
 47        # Adopt or create the accumulator dictionary
 048        if ($PSBoundParameters.ContainsKey('Variables') -and $Variables) {
 049            if (-not $dict) { $dict = $Variables }
 50        }
 051        if (-not $dict) {
 052            $dict = [ordered]@{}
 53        }
 054        $dict[$Name] = [Microsoft.OpenApi.OpenApiServerVariable]::new()
 55    }
 56    end {
 057        if ($PSBoundParameters.ContainsKey('Default')) { $dict[$Name].default = $Default }
 058        if ($PSBoundParameters.ContainsKey('Description')) { $dict[$Name].description = $Description }
 059        if ($PSBoundParameters.ContainsKey('Enum') -and $Enum) {
 060            $dict[$Name].enum = $Enum
 61        }
 62
 63        # Always emit an OrderedDictionary
 064        return $dict
 65    }
 66}

Methods/Properties

New-KrOpenApiServerVariable()