< Summary - Kestrun — Combined Coverage

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

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds a tag to the OpenAPI document.
 4.DESCRIPTION
 5    This function adds a tag to the OpenAPI document using the provided parameters in the specified OpenAPI documents in
 6.PARAMETER Server
 7    The Kestrun server instance to which the OpenAPI tag 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 tag will be added. Default is 'default'.
 11.PARAMETER Name
 12    The name of the tag.
 13.PARAMETER Description
 14    A description of the tag.
 15.PARAMETER ExternalDocs
 16    An OpenAPI External Documentation object associated with the tag.
 17.EXAMPLE
 18    # Add a tag to the default document
 19    Add-KrOpenApiTag -Name 'MyTag' -Description 'This is my tag.' `
 20        -ExternalDocs (New-KrOpenApiExternalDoc -Description 'More info' -Url 'https://example.com/tag-info')
 21.NOTES
 22    This cmdlet is part of the OpenAPI module.
 23#>
 24function Add-KrOpenApiTag {
 25    [KestrunRuntimeApi('Everywhere')]
 26    param(
 27        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 28        [Kestrun.Hosting.KestrunHost]$Server,
 29        [Parameter()]
 30        [string[]]$DocId = [Kestrun.Authentication.IOpenApiAuthenticationOptions]::DefaultDocumentationIds,
 31        [Parameter(Mandatory = $true)]
 32        [string]$Name,
 33        [Parameter()]
 34        [string]$Description,
 35        [Parameter()]
 36        [Microsoft.OpenApi.OpenApiExternalDocs]$ExternalDocs
 37    )
 38    begin {
 39        # Ensure the server instance is resolved
 040        $Server = Resolve-KestrunServer -Server $Server
 41    }
 42    process {
 43        # Add the server to the specified OpenAPI documents
 044        foreach ($doc in $DocId) {
 045            $docDescriptor = $Server.GetOrCreateOpenApiDocument($doc)
 046            if ($null -eq $docDescriptor.Document.Tags) {
 47                # Initialize the Tags collection if null
 048                $docDescriptor.Document.Tags = [System.Collections.Generic.HashSet[Microsoft.OpenApi.OpenApiTag]]::new()
 49            }
 050            $tag = [Microsoft.OpenApi.OpenApiTag]::new()
 051            $tag.Name = $Name
 052            if ($PsBoundParameters.ContainsKey('Description')) {
 053                $tag.Description = $Description
 54            }
 055            if ($PsBoundParameters.ContainsKey('ExternalDocs')) {
 056                $tag.ExternalDocs = $ExternalDocs
 57            }
 058            $docDescriptor.Document.Tags.Add($tag) | Out-Null
 59        }
 60    }
 61}

Methods/Properties

Add-KrOpenApiTag()