< Summary - Kestrun — Combined Coverage

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

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds or updates the OpenAPI Info section in the specified OpenAPI documents.
 4.DESCRIPTION
 5    This function adds or updates the OpenAPI Info section using the provided parameters in the specified OpenAPI docume
 6.PARAMETER Server
 7    The Kestrun server instance to which the OpenAPI Info 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 Info will be added. Default is 'default'.
 11.PARAMETER Title
 12    The title of the API.
 13.PARAMETER Version
 14    The version of the API.
 15.PARAMETER Summary
 16    A short summary of the API.
 17.PARAMETER Description
 18    A detailed description of the API.
 19.PARAMETER TermsOfService
 20    A URI to the Terms of Service for the API.
 21.EXAMPLE
 22    # Add or update the OpenAPI Info section in the default document
 23    Add-KrOpenApiInfo -Title 'My API' -Version '1.0.0' -Description 'This is my API.' `
 24        -Summary 'A brief summary of my API.' -TermsOfService 'https://example.com/terms'
 25.NOTES
 26    This cmdlet is part of the OpenAPI module.
 27#>
 28function Add-KrOpenApiInfo {
 29    [KestrunRuntimeApi('Everywhere')]
 30    param(
 31        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 32        [Kestrun.Hosting.KestrunHost]$Server,
 33        [Parameter()]
 34        [string[]]$DocId = [Kestrun.Authentication.IOpenApiAuthenticationOptions]::DefaultDocumentationIds,
 35        [Parameter(Mandatory)]
 36        [string]$Title,
 37        [Parameter(Mandatory)]
 38        [string]$Version,
 39        [Parameter()]
 40        [string]$Summary,
 41        [Parameter()]
 42        [string]$Description,
 43        [Parameter()]
 44        [uri]$TermsOfService
 45    )
 46    begin {
 47        # Ensure the server instance is resolved
 048        $Server = Resolve-KestrunServer -Server $Server
 49    }
 50    process {
 51        # Add the server to the specified OpenAPI documents
 052        foreach ($doc in $DocId) {
 053            $docDescriptor = $Server.GetOrCreateOpenApiDocument($doc)
 054            if ($null -eq $docDescriptor.Document.Info) {
 55                # Initialize the Info object if null
 056                $docDescriptor.Document.Info = [Microsoft.OpenApi.OpenApiInfo]::new()
 57            }
 058            if ($PsBoundParameters.ContainsKey('Title')) {
 059                $docDescriptor.Document.Info.Title = $Title
 60            }
 061            if ($PsBoundParameters.ContainsKey('Version')) {
 062                $docDescriptor.Document.Info.Version = $Version
 63            }
 064            if ($PsBoundParameters.ContainsKey('Summary')) {
 065                $docDescriptor.Document.Info.Summary = $Summary
 66            }
 067            if ($PsBoundParameters.ContainsKey('Description')) {
 068                $docDescriptor.Document.Info.Description = $Description
 69            }
 070            if ($PsBoundParameters.ContainsKey('TermsOfService')) {
 071                $docDescriptor.Document.Info.TermsOfService = $TermsOfService
 72            }
 73        }
 74    }
 75}

Methods/Properties

Add-KrOpenApiInfo()