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

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('Everywhere')]
 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        [Parameter()]
 35        [string[]] $Enum,
 36        [Parameter()]
 37        [string] $Description
 38    )
 39
 40    begin {
 041        $dict = $null
 42    }
 43
 44    process {
 45        # Adopt or create the accumulator dictionary
 046        if ($PSBoundParameters.ContainsKey('Variables') -and $Variables) {
 047            if (-not $dict) { $dict = $Variables }
 48        }
 049        if (-not $dict) {
 050            $dict = [ordered]@{}
 51        }
 052        $dict[$Name] = [Microsoft.OpenApi.OpenApiServerVariable]::new()
 53    }
 54    end {
 055        if ($PSBoundParameters.ContainsKey('Default')) { $dict[$Name].default = $Default }
 056        if ($PSBoundParameters.ContainsKey('Description')) { $dict[$Name].description = $Description }
 057        if ($PSBoundParameters.ContainsKey('Enum') -and $Enum) {
 058            $dict[$Name].enum = $Enum
 59        }
 60
 61        # Always emit an OrderedDictionary
 062        return $dict
 63    }
 64}

Methods/Properties

New-KrOpenApiServerVariable()