Allow schema annotations in manifest schemas

This commit is contained in:
Dandaedre 2026-11-20 08:19:50 +01:00
parent f7bafbc88f
commit 948b8892cd
3 changed files with 20 additions and 0 deletions

View File

@ -6,6 +6,7 @@
"additionalProperties": false,
"required": ["schemaVersion", "name", "profiles"],
"properties": {
"$schema": { "type": "string" },
"schemaVersion": { "const": 1 },
"name": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
"profiles": {

View File

@ -9,6 +9,7 @@
"name"
],
"properties": {
"$schema": { "type": "string" },
"schemaVersion": {
"const": 1
},

18
tests/Schema.Tests.ps1 Normal file
View File

@ -0,0 +1,18 @@
Describe 'Published manifest schemas' {
It 'accepts schema annotations in checked-in profiles' {
foreach ($profile in Get-ChildItem "$PSScriptRoot/../profiles/*.json") {
Get-Content $profile.FullName -Raw | Test-Json -SchemaFile "$PSScriptRoot/../schemas/profile.schema.json" | Should -BeTrue
}
}
It 'requires the portable checksum and forbids portable machine scope' {
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @(
[ordered]@{ id = 'app'; provider = 'portable'; source = 'example'; version = '1.0'; update = 'pinned'; url = 'https://example.org/app.zip'; executable = 'app.exe' }
) }
$schema = "$PSScriptRoot/../schemas/profile.schema.json"
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
$profile.packages[0].sha256 = 'a' * 64
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
$profile.packages[0].scope = 'machine'
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
}
}