Skip to content

Commit ee928c4

Browse files
Added the code to test for byte arrays
1 parent 7c7dd8d commit ee928c4

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

schema/schema.psm1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ function Get-Document {
2727
}
2828
'https' {
2929
Write-Verbose "Incoming HTTPs path";
30-
Invoke-WebRequest -UseBasicParsing -Uri $Path | Select-Object -ExpandProperty Content | ConvertFrom-Json;
30+
$Response = Invoke-WebRequest -UseBasicParsing -Uri $Path;
3131
}
3232
'http' {
3333
Write-Verbose "Incoming HTTP path";
34-
Invoke-WebRequest -UseBasicParsing -Uri $Path | Select-Object -ExpandProperty Content | ConvertFrom-Json;
34+
$Response = Invoke-WebRequest -UseBasicParsing -Uri $Path;
3535
}
3636
}
37+
if ($Response.Content.GetType().Name -eq 'Byte[]') {
38+
[string]::new($Response.Content) | ConvertFrom-Json;
39+
}
40+
else {
41+
$Response.Content | ConvertFrom-Json
42+
}
3743
}
3844
catch {
3945
throw $_;
@@ -51,7 +57,7 @@ function Get-Object {
5157
)
5258

5359
process {
54-
Write-Verbose ($SchemaDocument |Out-String);
60+
Write-Verbose ($SchemaDocument | Out-String);
5561
$Properties = $SchemaDocument.properties | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name;
5662
Write-Verbose "Setting up output object";
5763
$Members = @{};
@@ -99,7 +105,7 @@ function Get-Array {
99105
)
100106

101107
process {
102-
Write-Verbose ($SchemaDocument |Out-String);
108+
Write-Verbose ($SchemaDocument | Out-String);
103109
$Properties = $SchemaDocument.items.anyOf.properties | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name;
104110
Write-Verbose "Setting up output object";
105111
$Members = @{};
@@ -148,7 +154,7 @@ function Get-Property {
148154
)
149155

150156
process {
151-
Write-Verbose ($SchemaDocument |Out-String);
157+
Write-Verbose ($SchemaDocument | Out-String);
152158
Write-Verbose $Name;
153159
if ($Name) {
154160
Write-Verbose "Return specific Property";

0 commit comments

Comments
 (0)