Skip to content

Commit 22d8c6b

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: application/ld+json.GetLexicon() ( Fixes #22 )
1 parent 5eff6a1 commit 22d8c6b

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

JSON-LD.types.ps1xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,44 @@ foreach ($rdfProperty in $graphTypes['rdf:property']) {
102102
$jsonSchema
103103

104104

105+
</Script>
106+
</ScriptMethod>
107+
<ScriptMethod>
108+
<Name>GetLexicon</Name>
109+
<Script>
110+
111+
param($graph = $this)
112+
113+
$jsonSchema = $this.GetJsonSchema($graph)
114+
if (-not $jsonSchema.'$id') {
115+
throw "Missing $jsonSchema.$id"
116+
return
117+
}
118+
119+
$domain, $relativePath = $jsonSchema.'$id' -replace '^$' -split '/'
120+
if (-not $domain) { return}
121+
if (-not $relativePath ) { return }
122+
$domain = @($domain -split '\.')
123+
[Array]::Reverse($domain)
124+
$nsid = $domain, $relativePath -join '.'
125+
126+
127+
$jsonSchema.psobject.properties.Remove('$id')
128+
129+
[Ordered]@{
130+
lexicon = 1
131+
id = $nsid
132+
defs = [Ordered]@{
133+
main = [Ordered]@{
134+
type = 'record'
135+
description = $jsonSchema.description
136+
record = $jsonSchema
137+
}
138+
}
139+
}
140+
141+
142+
105143
</Script>
106144
</ScriptMethod>
107145
</Members>

0 commit comments

Comments
 (0)