< Summary - Kestrun — Combined Coverage

Information
Class: Public.OpenAPI.Add-KrOpenApiLicense
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/Add-KrOpenApiLicense.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
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/12) Total lines: 64 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds license information to the OpenAPI document.
 4.DESCRIPTION
 5    This function adds license 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 license 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 license information will be added. Default is 'default'.
 11.PARAMETER Name
 12    The name of the license.
 13.PARAMETER Url
 14    The URL of the license.
 15.PARAMETER Identifier
 16    The SPDX identifier of the license.
 17.EXAMPLE
 18    # Add license information to the default document
 19    Add-KrOpenApiLicense -Name 'MIT License' -Url 'https://opensource.org/licenses/MIT' -Identifier 'MIT'
 20.NOTES
 21    This cmdlet is part of the OpenAPI module.
 22#>
 23function Add-KrOpenApiLicense {
 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(Mandatory)]
 31        [string]$Name,
 32        [Parameter()]
 33        [Uri]$Url,
 34        [Parameter()]
 35        [string]$Identifier
 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.License) {
 50                # Initialize the License object if null
 051                $docDescriptor.Document.Info.License = [Microsoft.OpenApi.OpenApiLicense]::new()
 52            }
 53            # Set the license information
 054            $docDescriptor.Document.Info.License.Name = $Name
 55            # Set optional properties if provided
 056            if ($PsBoundParameters.ContainsKey('Url')) {
 057                $docDescriptor.Document.Info.License.Url = $Url
 58            }
 059            if ($PsBoundParameters.ContainsKey('Identifier')) {
 060                $docDescriptor.Document.Info.License.Identifier = $Identifier
 61            }
 62        }
 63    }
 64}

Methods/Properties

Add-KrOpenApiLicense()