Skip to content

Commit d6cb34c

Browse files
Merge pull request #2 from SchemaModule/issue-1
Added code to reference help documents and pipeline handling
2 parents 4be4244 + 755b269 commit d6cb34c

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

schema/schema.psm1

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
function Get-Document {
2+
[CmdletBinding(
3+
HelpURI = 'https://github.com/SchemaModule/PowerShell/blob/master/docs/Get-SchemaDocument.md#get-schemadocument',
4+
PositionalBinding = $true)]
5+
[OutputType([Object])]
26
param (
7+
[Parameter(ValueFromPipeline)]
38
[string]$Path
49
)
510

6-
try {
7-
$ErrorActionPreference = 'Stop';
8-
$Error.Clear();
11+
process {
12+
try {
13+
$ErrorActionPreference = 'Stop';
14+
$Error.Clear();
915

10-
$Schema = [System.UriBuilder]::new($Path);
16+
$Schema = [System.UriBuilder]::new($Path);
1117

12-
switch ($Schema.Scheme) {
13-
'file' {
14-
Get-Content -Path $Path | ConvertFrom-Json
15-
}
16-
'https' {
17-
Invoke-WebRequest -UseBasicParsing -Uri $Path | Select-Object -ExpandProperty Content | ConvertFrom-Json
18-
}
19-
'http' {
20-
Invoke-WebRequest -UseBasicParsing -Uri $Path | Select-Object -ExpandProperty Content | ConvertFrom-Json
18+
switch ($Schema.Scheme) {
19+
'file' {
20+
Get-Content -Path $Path | ConvertFrom-Json;
21+
}
22+
'https' {
23+
Invoke-WebRequest -UseBasicParsing -Uri $Path | Select-Object -ExpandProperty Content | ConvertFrom-Json;
24+
}
25+
'http' {
26+
Invoke-WebRequest -UseBasicParsing -Uri $Path | Select-Object -ExpandProperty Content | ConvertFrom-Json;
27+
}
2128
}
2229
}
23-
}
24-
catch {
25-
throw $_
30+
catch {
31+
throw $_;
32+
}
2633
}
2734
}
2835
function Get-Object {

0 commit comments

Comments
 (0)