@@ -4,7 +4,7 @@ using namespace System.Collections
4
4
<#
5
5
. SYNOPSIS
6
6
Build the DSC schema files from the source YAML files.
7
-
7
+
8
8
. DESCRIPTION
9
9
This build script composes the JSON Schema files from the source YAML files, creating new
10
10
files in the specified output directory. It creates a schema registry to analyze the source
@@ -15,11 +15,11 @@ using namespace System.Collections
15
15
param (
16
16
[string ]
17
17
$OutputDirectory = " $PSScriptRoot " ,
18
-
18
+
19
19
[Parameter (ParameterSetName = ' ByPath' )]
20
20
[string []]
21
21
$ConfigFilePath ,
22
-
22
+
23
23
[string []]
24
24
[ValidateSet (' Json' , ' JsonVSCode' , ' Yaml' , ' YamlVSCode' )]
25
25
$OutputFormat = @ (
@@ -40,7 +40,7 @@ begin {
40
40
41
41
[Specialized.OrderedDictionary ]
42
42
$Map
43
-
43
+
44
44
[Generic.List [Specialized.OrderedDictionary ]]
45
45
$List
46
46
@@ -102,7 +102,7 @@ begin {
102
102
# Need to ensure single-item returns get correctly handled as arays,
103
103
# not munged into scalars.
104
104
if (
105
- ($MungedKeyValue.Count -eq 1 ) -or
105
+ ($MungedKeyValue.Count -eq 1 ) -or
106
106
($MungedKeyValue -is [Specialized.OrderedDictionary ])
107
107
) {
108
108
$MungedSchema.Add ($_.Key , [object []]$MungedKeyValue )
@@ -308,18 +308,18 @@ begin {
308
308
[Parameter (ParameterSetName = ' FromPath' , Mandatory )]
309
309
[string ]
310
310
$Path ,
311
-
311
+
312
312
[Parameter (ParameterSetName = ' FromSchema' , Mandatory )]
313
313
[Specialized.OrderedDictionary ]
314
314
$Schema ,
315
-
315
+
316
316
[Parameter (ParameterSetName = ' FromPreset' , Mandatory )]
317
317
[ValidateSet (' ConfigDocument' , ' ResourceManifest' )]
318
318
[string ]
319
319
$Preset ,
320
320
321
321
[LocalJsonSchemaRegistry ] $SchemaRegistry ,
322
-
322
+
323
323
[switch ]$ForVSCode ,
324
324
[switch ]$WithoutComments ,
325
325
[switch ]$WithoutExamples
@@ -379,9 +379,14 @@ begin {
379
379
continue
380
380
}
381
381
382
+ if ($ID -match " $Reference `$ " ) {
383
+ Write-Verbose " $ID `n`t Skipping adding self ($Reference ) to `$ defs"
384
+ continue
385
+ }
386
+
382
387
$ReferenceSegments = $Reference.Trim (' /' ) -split ' /'
383
388
$Working = $MergedSchema .' $defs'
384
-
389
+
385
390
for ($i = 0 ; $i -lt $ReferenceSegments.Count ; $i ++ ) {
386
391
$Segment = $ReferenceSegments [$i ]
387
392
@@ -390,7 +395,7 @@ begin {
390
395
$Working = $Working .$Segment
391
396
continue
392
397
}
393
-
398
+
394
399
# Add an empty dictionary for non-final segments
395
400
if ($i -ne ($ReferenceSegments.Count - 1 )) {
396
401
$Working.Add ($Segment , [Specialized.OrderedDictionary ]::new())
@@ -446,6 +451,11 @@ begin {
446
451
continue
447
452
}
448
453
454
+ if ($ID -match " $Reference `$ " ) {
455
+ Write-Verbose " $ID `n`t Skipping adding self ($Reference ) to `$ defs"
456
+ continue
457
+ }
458
+
449
459
if ($Reference -notin $Schema .' $defs' .Keys) {
450
460
Write-Verbose " $ID `n`t Adding reference to `$ defs: '$Reference '"
451
461
$MergedSchema .' $defs' .Add($ReferenceSchema .' $id' , $ReferenceSchema )
@@ -524,7 +534,7 @@ begin {
524
534
525
535
[string ]
526
536
$OutputDirectory = $PWD ,
527
-
537
+
528
538
[string []]
529
539
[ValidateSet (' Json' , ' JsonVSCode' , ' Yaml' , ' YamlVSCode' )]
530
540
$OutputFormat = @ (
@@ -567,7 +577,7 @@ begin {
567
577
Path = $ConfigFilePath
568
578
SchemaRegistry = $SchemaRegistry
569
579
}
570
-
580
+
571
581
if ($MergeForNormal ) {
572
582
$Bundled = Merge-JsonSchema @SharedMergeParams
573
583
| Set-BundledSchemaID - BundledName $Name
@@ -716,7 +726,7 @@ process {
716
726
foreach ($VSCodeKeyword in $VSCodeKeywords ) {
717
727
$SchemaData = Remove-JsonSchemaKey - Schema $SchemaData - KeyName $VSCodeKeyword
718
728
}
719
-
729
+
720
730
$SchemaData
721
731
| ConvertTo-Json - Depth 99
722
732
| ForEach-Object { $_ -replace ' \r\n' , " `n " }
0 commit comments