Skip to content

Commit 5eff6a1

Browse files
feat: application/ld+json.GetLexicon() ( Fixes #22 )
1 parent 33dc0d8 commit 5eff6a1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Types/JsonLD/GetLexicon.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
param($graph = $this)
3+
4+
$jsonSchema = $this.GetJsonSchema($graph)
5+
if (-not $jsonSchema.'$id') {
6+
throw "Missing $jsonSchema.$id"
7+
return
8+
}
9+
10+
$domain, $relativePath = $jsonSchema.'$id' -replace '^$' -split '/'
11+
if (-not $domain) { return}
12+
if (-not $relativePath ) { return }
13+
$domain = @($domain -split '\.')
14+
[Array]::Reverse($domain)
15+
$nsid = $domain, $relativePath -join '.'
16+
17+
18+
$jsonSchema.psobject.properties.Remove('$id')
19+
20+
[Ordered]@{
21+
lexicon = 1
22+
id = $nsid
23+
defs = [Ordered]@{
24+
main = [Ordered]@{
25+
type = 'record'
26+
description = $jsonSchema.description
27+
record = $jsonSchema
28+
}
29+
}
30+
}
31+
32+

0 commit comments

Comments
 (0)