< Summary - Kestrun — Combined Coverage

Information
Class: Public.OpenAPI.Add-KrOpenApiInline
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/Add-KrOpenApiInline.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 71
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/23/2025 - 19:23:04 Line coverage: 0% (0/9) Total lines: 67 Tag: Kestrun/Kestrun@d062f281460e6c123c372aef61f8d957bbb6c90101/17/2026 - 04:33:35 Line coverage: 0% (0/11) Total lines: 71 Tag: Kestrun/Kestrun@aca34ea8d284564e2f9f6616dc937668dce926ba

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds an inline OpenAPI element (Example or Link) to the specified OpenAPI document(s).
 4.DESCRIPTION
 5    This cmdlet adds an inline OpenAPI element, either an Example or a Link, to one or more OpenAPI documents managed by
 6.PARAMETER Server
 7    The Kestrun server instance where the OpenAPI documents are managed. If not specified, the default server instance i
 8.PARAMETER DocId
 9    An array of OpenAPI document IDs to which the element will be added. Defaults to the standard documentation IDs.
 10.PARAMETER Name
 11    The name of the inline element to be added. This can be provided via the pipeline or as a parameter.
 12.PARAMETER Element
 13    The OpenAPI inline element object to be added. This can be an OpenApiExample or OpenApiLink object.
 14.PARAMETER IfExists
 15    Specifies the conflict resolution strategy if an element with the same name already exists in the document. Options 
 16.EXAMPLE
 17    $example = New-KrOpenApiExample -Summary "User Example" -Description "An example of a user object." -Value @{ id = 1
 18    Add-KrOpenApiInline -Name "UserExample" -Element $example -DocId "MyApiDoc"
 19    This example creates a new OpenAPI Inline Example and adds it to the "MyApiDoc" OpenAPI document.
 20.EXAMPLE
 21    $link = New-KrOpenApiLink -OperationId "getUser" -Description "Link to get user details" -Parameters @{ "userId" = "
 22    Add-KrOpenApiInline -Name "GetUserLink" -Element $link -DocId "MyApiDoc"
 23    This example creates a new OpenAPI Inline Link and adds it to the "MyApiDoc" OpenAPI document.
 24#>
 25function Add-KrOpenApiInline {
 26    [KestrunRuntimeApi('Definition')]
 27    [CmdletBinding()]
 28    param(
 29        [Parameter(Mandatory = $false )]
 30        [Kestrun.Hosting.KestrunHost]$Server,
 31
 32        [Parameter()]
 33        [string[]]$DocId = [Kestrun.OpenApi.OpenApiDocDescriptor]::DefaultDocumentationIds,
 34
 35        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
 36        [Alias('Key', 'Id')]
 37        [ValidatePattern('^[A-Za-z0-9\.\-_]+$')]
 38        [string] $Name,
 39
 40        [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
 41        [object] $Element,
 42
 43        [Parameter()]
 44        [Kestrun.OpenApi.OpenApiComponentConflictResolution] $IfExists = [Kestrun.OpenApi.OpenApiComponentConflictResolu
 45    )
 46    begin {
 47        # Ensure the server instance is resolved
 048        $Server = Resolve-KestrunServer -Server $Server
 49    }
 50    process {
 051        if ($Server.IsConfigured) {
 052            Write-KrError -ErrorMessage 'The Kestrun server configuration is already set. Please add components before e
 53            return
 54        }
 55        # Add the server to the specified OpenAPI documents
 056        foreach ($doc in $DocId) {
 057            $docDescriptor = $Server.GetOrCreateOpenApiDocument($doc)
 58
 059            if ($Element -is [Microsoft.OpenApi.OpenApiExample]) {
 060                $docDescriptor.AddInlineExample($Name, $Element, $IfExists)
 061            } elseif ($Element -is [Microsoft.OpenApi.OpenApiLink]) {
 062                $docDescriptor.AddInlineLink($Name, $Element, $IfExists)
 63            } else {
 064                throw [System.ArgumentException]::new(
 065                    "Unsupported inline element type: $($Element.GetType().FullName). Supported: OpenApiExample, OpenApi
 66                    'Element'
 67                )
 68            }
 69        }
 70    }
 71}

Methods/Properties

Add-KrOpenApiInline()