Skip to content

Commit

Permalink
fix!: fixes linkedIds to new format
Browse files Browse the repository at this point in the history
fixes #166

BREAKING CHANGE: changes the swagger definition to the format agreed in #166
  • Loading branch information
sennierer committed Aug 21, 2023
1 parent 5d8315e commit 43aa7f1
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions intavia_backend/models_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
"baseUrl": "http://ldf.fi/nbf/",
"regex_id": "nbf/([^\.]+)",
},
"GeoNames": {
"label": "GeoNames",
"baseUrl": "https://sws.geonames.org"
},
"GeoNamesHttp": {
"label": "GeoNames",
"baseUrl": "http://sws.geonames.org"
}
}


Expand Down Expand Up @@ -72,24 +80,17 @@ def pp_id_provider(field, item, data):
item = [item]
for it in item:
data = {}
test = False
# Test for query params and remove them
if re.search(r"\?[^/]+$", it["id"]):
it = "/".join(it["id"].split("/")[:-1])
else:
it = it["id"]
data["url"] = it
for k, v in linked_id_providers.items():
if v["baseUrl"] in it:
test = True
match = re.search(v["regex_id"], it)
if match:
data["id"] = match.group(1)
data["provider"] = LinkedIdProvider(**v)
break
else:
data["id"] = it
if not test:
data["id"] = it
data["label"] = v["label"]
if not "label" in data:
data["label"] = it
res.append(data)
return res

Expand Down Expand Up @@ -199,14 +200,9 @@ class Config:
RDF_utils_move_errors_to_top = True


class LinkedIdProvider(BaseModel):
label: str
baseUrl: HttpUrl


class LinkedId(BaseModel):
id: str
provider: LinkedIdProvider | None = None
label: str
url: HttpUrl


class InternationalizedLabel(IntaViaBackendBaseModel):
Expand Down

0 comments on commit 43aa7f1

Please sign in to comment.