Skip to content

Commit 50463c5

Browse files
authored
Added domain name in IRI in entrypoints (#62)
* added full iri for entrypoint * added complete uri hydra:template * added base_url in hydra:template
1 parent c7da9dc commit 50463c5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

hydra_python_core/doc_writer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ def generate(self) -> Dict[str, Any]:
428428
def get(self) -> Dict[str, str]:
429429
"""Create the EntryPoint object to be returnd for the get function."""
430430
object_ = {
431-
"@context": "/{}/contexts/EntryPoint.jsonld".format(self.api),
432-
"@id": "/{}".format(self.api),
431+
"@context": "{}{}/contexts/EntryPoint.jsonld".format(self.url,self.api),
432+
"@id": "{}{}".format(self.url,self.api),
433433
"@type": "EntryPoint",
434434

435435
}
@@ -438,7 +438,7 @@ def get(self) -> Dict[str, str]:
438438
if item.generate() in self.collections:
439439
collection_returned = item.generate()
440440
collection_id = uri.replace(
441-
"{}EntryPoint".format(DocUrl.doc_url), "/{}".format(self.api))
441+
"{}EntryPoint".format(DocUrl.doc_url), "{}{}".format(self.url,self.api))
442442
collection_to_append = {
443443
"@id": collection_id,
444444
'title': collection_returned['hydra:title'],
@@ -454,7 +454,7 @@ def get(self) -> Dict[str, str]:
454454

455455
else:
456456
object_[item.name] = uri.replace(
457-
"{}EntryPoint".format(DocUrl.doc_url), "/{}".format(self.api))
457+
"{}EntryPoint".format(DocUrl.doc_url), "{}{}".format(self.url,self.api))
458458

459459
return object_
460460

@@ -639,9 +639,10 @@ def __init__(self,
639639

640640
def generate(self) -> Dict[str, Any]:
641641
"""Get IriTemplate as a python dict"""
642+
base_url = DocUrl.doc_url.rsplit('/',2)[0]
642643
iri_template = {
643644
"@type": "hydra:IriTemplate",
644-
"hydra:template": self.template,
645+
"hydra:template": "{}{}".format(base_url,self.template),
645646
"hydra:variableRepresentation": self.variable_rep,
646647
"hydra:mapping": [x.generate() for x in self.mapping]
647648
}

0 commit comments

Comments
 (0)