Skip to content

Commit fcea29b

Browse files
authored
Fix type of projects setting in schema (#1771)
Schema for _projects_ setting should be an array of strings
1 parent 1509190 commit fcea29b

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

Actions/settings.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"projects": {
2020
"type": "array",
2121
"items": {
22-
"type": "object"
22+
"type": "string"
2323
},
2424
"description": "An array of AL-Go projects. See https://aka.ms/ALGoSettings#projects"
2525
},

RELEASENOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Issues
2+
3+
- Issue 1770: Wrong type of _projects_ setting in settings schema
4+
15
## v7.2
26

37
### Removed functionality

Tests/AL-Go-Helper.Test.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,31 @@ Describe "ReadSettings" {
429429
$_.Exception.Message | Should -Be "The JSON is not valid with the schema: The string value is not a match for the indicated regular expression at '/shell'"
430430
}
431431
}
432+
433+
It 'Projects setting is an array of strings' {
434+
# If the projects setting is not an array, it should throw an error
435+
$defaultSettings = GetDefaultSettings
436+
$defaultSettings.projects = "not an array"
437+
try {
438+
Test-Json -json (ConvertTo-Json $defaultSettings) -schema $schema
439+
}
440+
catch {
441+
$_.Exception.Message | Should -Be "The JSON is not valid with the schema: Value is `"string`" but should be `"array`" at '/projects'"
442+
}
443+
444+
# If the projects setting is an array, but contains non-string values, it should throw an error
445+
$defaultSettings.projects = @("project1", 42)
446+
try {
447+
Test-Json -json (ConvertTo-Json $defaultSettings) -schema $schema
448+
}
449+
catch {
450+
$_.Exception.Message | Should -Be "The JSON is not valid with the schema: Value is `"integer`" but should be `"string`" at '/projects/1'"
451+
}
452+
453+
# If the projects setting is an array of strings, it should pass the schema validation
454+
$defaultSettings.projects = @("project1")
455+
Test-Json -json (ConvertTo-Json $defaultSettings) -schema $schema | Should -Be $true
456+
$defaultSettings.projects = @("project1", "project2")
457+
Test-Json -json (ConvertTo-Json $defaultSettings) -schema $schema | Should -Be $true
458+
}
432459
}

0 commit comments

Comments
 (0)