< Summary - Kestrun — Combined Coverage

Information
Class: Public.OpenAPI.Set-KrOpenApiErrorSchema
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/Set-KrOpenApiErrorSchema.ps1
Tag: Kestrun/Kestrun@8aa46e1988031758b311143cd39bf5749fbcd39e
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 58
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 02/18/2026 - 08:33:07 Line coverage: 0% (0/7) Total lines: 58 Tag: Kestrun/Kestrun@bf8a937cfb7e8936c225b9df4608f8ddd85558b1

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/OpenAPI/Set-KrOpenApiErrorSchema.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Sets the schema name used for autogenerated OpenAPI client-error responses.
 4.DESCRIPTION
 5    Configures the OpenAPI descriptor to use a custom schema component name for
 6    autogenerated client-error responses (for example 400, 406, 415, 422).
 7.PARAMETER DocId
 8    One or more OpenAPI document IDs to configure. Defaults to the default document IDs.
 9.PARAMETER Name
 10    Schema component name to use for autogenerated client-error responses.
 11.PARAMETER ContentType
 12    One or more content types to use for autogenerated client-error responses.
 13    Defaults to application/problem+json.
 14.PARAMETER WhatIf
 15    Shows what would happen if the cmdlet runs. The cmdlet is not run.
 16.PARAMETER Confirm
 17    Prompts you for confirmation before running the cmdlet.
 18.EXAMPLE
 19    Set-KrOpenApiErrorSchema -Name 'ApiError'
 20
 21    Uses 'ApiError' for autogenerated client-error response schemas in the default OpenAPI document.
 22.EXAMPLE
 23    Set-KrOpenApiErrorSchema -DocId @('Default','v2') -Name 'ApiError'
 24
 25    Uses 'ApiError' for both Default and v2 OpenAPI documents.
 26.EXAMPLE
 27    Set-KrOpenApiErrorSchema -Name 'ApiError' -ContentType @('application/json','application/problem+json')
 28
 29    Uses 'ApiError' and emits autogenerated client-error responses for both JSON media types.
 30.NOTES
 31    Set this before building/exporting OpenAPI output for predictable component naming.
 32#>
 33function Set-KrOpenApiErrorSchema {
 34    [KestrunRuntimeApi('Definition')]
 35    [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')]
 36    param(
 37        [Parameter()]
 38        [string[]]$DocId = [Kestrun.OpenApi.OpenApiDocDescriptor]::DefaultDocumentationIds,
 39
 40        [Parameter(Mandatory)]
 41        [ValidateNotNullOrEmpty()]
 42        [string]$Name,
 43
 44        [Parameter()]
 45        [ValidateNotNullOrEmpty()]
 046        [string[]]$ContentType = @([Kestrun.OpenApi.OpenApiDocDescriptor]::DefaultAutoErrorResponseContentType)
 47    )
 48
 049    $Server = Resolve-KestrunServer
 50
 051    foreach ($doc in $DocId) {
 052        if ($PSCmdlet.ShouldProcess("OpenAPI document '$doc'", "Set auto error schema '$Name' with content types: $($Con
 053            $descriptor = $Server.GetOrCreateOpenApiDocument($doc)
 054            $descriptor.AutoErrorResponseSchemaId = $Name
 055            $descriptor.AutoErrorResponseContentTypes = $ContentType
 56        }
 57    }
 58}

Methods/Properties

Set-KrOpenApiErrorSchema()