Private/Generator/ConvertTo-OpenApiGenManifest.ps1

function ConvertTo-OpenApiGenManifest {
    <#
    .SYNOPSIS
        Renders the module manifest (.psd1) of a generated module.

    .DESCRIPTION
        RequiredModules names tcs.openapi with the generator's version as the minimum version and
        FunctionsToExport lists every command (sorted, ordinal). The GUID is derived from the module
        name (a name-based UUID, version 5 layout, from SHA-1), so regenerating keeps it.
    #>

    [CmdletBinding()]
    [OutputType([string])]
    param(
        [Parameter(Mandatory = $true)]
        [object]$Option,

        [Parameter(Mandatory = $true)]
        [object]$Document,

        [Parameter(Mandatory = $true)]
        [AllowEmptyCollection()]
        [string[]]$FunctionName,

        [Parameter(Mandatory = $true)]
        [string]$Template
    )

    $sha1 = [System.Security.Cryptography.SHA1]::Create()
    try {
        $hash = $sha1.ComputeHash([System.Text.Encoding]::UTF8.GetBytes('tcs.openapi/' + $Option.ModuleName.ToLowerInvariant()))
    }
    finally {
        $sha1.Dispose()
    }
    $bytes = New-Object -TypeName 'byte[]' -ArgumentList 16
    [System.Array]::Copy($hash, $bytes, 16)
    $bytes[6] = ($bytes[6] -band 0x0F) -bor 0x50
    $bytes[8] = ($bytes[8] -band 0x3F) -bor 0x80
    $hex = -join ($bytes | ForEach-Object -Process { $_.ToString('x2', [System.Globalization.CultureInfo]::InvariantCulture) })
    $guid = '{0}-{1}-{2}-{3}-{4}' -f $hex.Substring(0, 8), $hex.Substring(8, 4), $hex.Substring(12, 4), $hex.Substring(16, 4), $hex.Substring(20, 12)

    $title = ([string]$Document.Title).Trim()
    if ($title -eq '') {
        $title = $Option.ModuleName
    }
    $description = "PowerShell commands for $title"
    if (-not [string]::IsNullOrWhiteSpace([string]$Document.Version)) {
        $description += " (API version $(([string]$Document.Version).Trim()))"
    }
    $description += ', generated by tcs.openapi.'

    $sorted = Get-OpenApiGenOrdinalSorted -InputObject $FunctionName
    $exportLines = @()
    for ($i = 0; $i -lt $sorted.Count; $i++) {
        $line = ' ' + (ConvertTo-OpenApiGenLiteral -Value $sorted[$i])
        if ($i -lt $sorted.Count - 1) {
            $line += ','
        }
        $exportLines += $line
    }

    return Expand-OpenApiGenTemplate -Template $Template -Value @{
        ModuleName         = $Option.ModuleName
        ModuleVersion      = $Option.ModuleVersion
        Guid               = $guid
        AuthorLiteral      = (ConvertTo-OpenApiGenLiteral -Value $Option.Author)
        CopyrightLiteral   = (ConvertTo-OpenApiGenLiteral -Value "(c) $($Option.Author). All rights reserved.")
        DescriptionLiteral = (ConvertTo-OpenApiGenLiteral -Value $description)
        GeneratorVersion   = $Option.GeneratorVersion
        FunctionsToExport  = ($exportLines -join "`n")
    }
}