< Summary - Kestrun — Combined Coverage

Information
Class: Public.OpenAPI.New-KrOpenApiHeader
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/New-KrOpenApiHeader.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 129
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/25/2025 - 19:20:44 Line coverage: 0% (0/17) Total lines: 149 Tag: Kestrun/Kestrun@5251f12f253e29f8a1dfb77edc2ef50b90a4f26f12/26/2025 - 04:28:42 Line coverage: 0% (0/7) Total lines: 126 Tag: Kestrun/Kestrun@078efbc0494329762e193e7b43b6ce82e494276401/18/2026 - 21:37:07 Line coverage: 0% (0/7) Total lines: 129 Tag: Kestrun/Kestrun@99c4ae445e8e5afc8b7080e01d5d9cdf39f972b8

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Creates a new OpenAPI Header object.
 4.DESCRIPTION
 5    This cmdlet creates a new OpenAPI Header object that can be used in OpenAPI specifications.
 6.PARAMETER Server
 7    The Kestrun server instance to use. If not specified, the default server instance is used.
 8.PARAMETER Description
 9    A brief description of the header.
 10.PARAMETER Required
 11    Indicates whether the header is required.
 12.PARAMETER Deprecated
 13    Indicates whether the header is deprecated.
 14.PARAMETER AllowEmptyValue
 15    Indicates whether the header allows empty values.
 16.PARAMETER Explode
 17    Indicates whether the header should be exploded.
 18.PARAMETER AllowReserved
 19    Indicates whether the header allows reserved characters.
 20.PARAMETER Style
 21    The style of the header (e.g., simple, matrix, label, etc.).
 22.PARAMETER Example
 23    A single example of the header value.
 24.PARAMETER Examples
 25    A dictionary of multiple examples for the header.
 26.PARAMETER Schema
 27    The schema defining the type of the header value. This can be a .NET type literal (e.g., [string], [int], etc.).
 28.PARAMETER Content
 29    A dictionary representing the content of the header, mapping media types to OpenAPI MediaType objects.
 30.PARAMETER Extensions
 31    A dictionary of OpenAPI extensions to add to the header.
 32.OUTPUTS
 33    Microsoft.OpenApi.OpenApiHeader object.
 34.EXAMPLE
 35    $header = New-KrOpenApiHeader -Description "Custom Header" -Required -Schema [string]
 36    This example creates a new OpenAPI Header object with a description, marks it as required, and sets its schema to st
 37.EXAMPLE
 38    $content = @{
 39        "application/json" = New-KrOpenApiMediaType -Schema [hashtable]
 40    }
 41    $header = New-KrOpenApiHeader -Description "JSON Header" -Content $content
 42    This example creates a new OpenAPI Header object with a description and sets its content to application/json with a 
 43.EXAMPLE
 44    $examples = @{
 45        "example1" = New-KrOpenApiExample -Summary "Example 1" -Value "Value1"
 46        "example2" = New-KrOpenApiExample -Summary "Example 2" -Value "Value2"
 47    }
 48    $header = New-KrOpenApiHeader -Description "Header with Examples" -Examples $examples -Schema [string]
 49    This example creates a new OpenAPI Header object with a description, multiple examples, and sets its schema to strin
 50.OUTPUTS
 51    Microsoft.OpenApi.OpenApiHeader object.
 52.NOTES
 53    This function is part of the Kestrun PowerShell module for working with OpenAPI specifications.
 54 #>
 55function New-KrOpenApiHeader {
 56    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 57    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression', '')]
 58    [KestrunRuntimeApi('Definition')]
 59    [CmdletBinding(defaultParameterSetName = 'Schema')]
 60    [OutputType([Microsoft.OpenApi.OpenApiHeader])]
 61    param(
 62        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 63        [Kestrun.Hosting.KestrunHost]$Server,
 64
 65        [Parameter()]
 66        [string]$Description,
 67
 68        [Parameter()]
 69        [switch]$Required,
 70
 71        [Parameter()]
 72        [switch]$Deprecated,
 73
 74        [Parameter()]
 75        [switch]$AllowEmptyValue,
 76
 77        [Parameter()]
 78        [switch]$Explode,
 79
 80        [Parameter()]
 81        [switch]$AllowReserved,
 82
 83        [Parameter()]
 84        [System.Nullable[Microsoft.OpenApi.ParameterStyle]]$Style = $null,
 85
 86        [Parameter()]
 87        [object]$Example,
 88
 89        [Parameter()]
 90        [hashtable]$Examples,
 91
 92        [Parameter(ParameterSetName = 'Schema')]
 93        [object]$Schema,
 94
 95        [Parameter(ParameterSetName = 'Content')]
 96        [System.Collections.IDictionary]$Content,
 97
 98        [Parameter()]
 99        [System.Collections.IDictionary]$Extensions
 100    )
 101    begin {
 102        # Ensure the server instance is resolved
 0103        $Server = Resolve-KestrunServer -Server $Server
 0104        if ($PSCmdlet.ParameterSetName -eq 'Schema' -and $null -ne $Schema) {
 0105            $Schema = Resolve-KrSchemaTypeLiteral -Schema $Schema
 106        }
 107    }
 108    process {
 109        # Create header for the specified OpenAPI document
 0110        if ($Server.OpenApiDocumentDescriptor.Count -gt 0 ) {
 0111            $docDescriptor = $Server.DefaultOpenApiDocumentDescriptor
 0112            $header = $docDescriptor.NewOpenApiHeader(
 113                $Description,
 114                $Required.IsPresent,
 115                $Deprecated.IsPresent,
 116                $AllowEmptyValue.IsPresent,
 117                $Style,
 118                $Explode.IsPresent,
 119                $AllowReserved.IsPresent,
 120                $Example,
 121                $Examples,
 122                $Schema,
 123                $Content,
 124                $Extensions
 125            )
 0126            return $header
 127        }
 128    }
 129}

Methods/Properties

New-KrOpenApiHeader()