Skip to content

Commit 82da0ce

Browse files
UserStory-51 : Added a switch to ConvertTo-Element to force a SchemaDocument on the first pass.
1 parent df769a4 commit 82da0ce

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

schema/schema.psm1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,15 @@ function Get-Document {
317317
switch ($Schema.Scheme) {
318318
'file' {
319319
Write-Verbose "Incoming Filepath";
320-
Return (ConvertTo-SchemaElement -object (Get-Content -Path $Path | ConvertFrom-Json));
320+
Return (ConvertTo-SchemaElement -object (Get-Content -Path $Path | ConvertFrom-Json) -IsRootSchema);
321321
}
322322
'https' {
323323
Write-Verbose "Incoming HTTPs path";
324-
Return (ConvertTo-SchemaElement -object (Invoke-WebRequest -UseBasicParsing -Uri $Path | ConvertFrom-Json));
324+
Return (ConvertTo-SchemaElement -object (Invoke-WebRequest -UseBasicParsing -Uri $Path | ConvertFrom-Json) -IsRootSchema);
325325
}
326326
'http' {
327327
Write-Verbose "Incoming HTTP path";
328-
Return (ConvertTo-SchemaElement -object (Invoke-WebRequest -UseBasicParsing -Uri $Path | ConvertFrom-Json));
328+
Return (ConvertTo-SchemaElement -object (Invoke-WebRequest -UseBasicParsing -Uri $Path | ConvertFrom-Json) -IsRootSchema);
329329
}
330330
}
331331
}
@@ -704,7 +704,8 @@ function ConvertTo-Element {
704704
[OutputType([schemaDocument], [schemaString], [schemaInteger], [schemaNumber], [schemaBoolean], [schemaObject], [schemaArray])]
705705
param (
706706
[parameter(Mandatory = $true, Position = 0)]
707-
[object]$Object
707+
[object]$Object,
708+
[switch]$IsRootSchema
708709
)
709710
write-verbose ($Object | Out-String)
710711
switch ($Object.type) {
@@ -759,7 +760,7 @@ function ConvertTo-Element {
759760
}
760761
}
761762
'object' {
762-
if ($Object.psobject.properties.name.Contains('$schema')) {
763+
if ($Object.psobject.properties.name.Contains('$schema') -or $IsRootSchema) {
763764
write-verbose "Creating schemaDcoument object"
764765
$Result = New-SchemaElement -Type document
765766
}

0 commit comments

Comments
 (0)