Skip to content

Commit 1893ac7

Browse files
committed
dev(WoRMS): fix an endpoint returning nothing valid
1 parent 9a820a4 commit 1893ac7

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

openapi.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5925,7 +5925,7 @@
59255925
"Taxonomy Tree"
59265926
],
59275927
"summary":"Add Worms Taxon",
5928-
"description":"Add worms taxon with or without lineage information",
5928+
"description":"Add worms taxon by its aphia_id",
59295929
"operationId":"add_worms_taxon",
59305930
"requestBody":{
59315931
"content":{
@@ -5939,7 +5939,14 @@
59395939
},
59405940
"responses":{
59415941
"200":{
5942-
"description":"Successful Response"
5942+
"description":"Successful Response",
5943+
"content":{
5944+
"application/json":{
5945+
"schema":{
5946+
"title":"Response Add Worms Taxon Addworms Post"
5947+
}
5948+
}
5949+
}
59435950
},
59445951
"422":{
59455952
"description":"Validation Error",

py/API_operations/TaxoManager.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from helpers.DynamicLogs import get_logger
2424
from providers.EcoTaxoServer import EcoTaxoServerClient
2525
from .helpers.Service import Service
26-
from API_models.taxonomy import TaxoWormsModel
2726

2827
logger = get_logger(__name__)
2928

@@ -78,7 +77,7 @@ def get_taxon_by_id(self, taxon_id: int) -> str:
7877
ret = self.client.call("/gettaxon/", {"filtertype": "id", "id": taxon_id})
7978
return ret.json()
8079

81-
def add_taxon(self, current_user_id: UserIDT, taxon_params: Dict) -> str:
80+
def add_taxon(self, current_user_id: UserIDT, taxon_params: Dict) -> Any:
8281
# Security barrier, user must be admin or manager in any project
8382
# creation_datetime: str, =
8483
_user = RightsBO.user_can_add_taxonomy(self.ro_session, current_user_id)
@@ -99,12 +98,12 @@ def add_worms_taxon(
9998
self,
10099
aphia_id: int,
101100
current_user_id: UserIDT,
102-
) -> Dict:
101+
) -> Any:
103102
_user = RightsBO.user_can_add_taxonomy(self.ro_session, current_user_id)
104103
current_user: User = self.session.query(User).get(current_user_id)
105104
taxon = {"aphia_id": aphia_id, "creator_email": current_user.email}
106105
ret = self.client.call("/addwormstaxon/", taxon)
107-
return ret
106+
return ret.json()
108107

109108
def push_stats(self) -> Any:
110109
"""

py/main.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3518,20 +3518,18 @@ def search_worms_name(
35183518
"/addworms/",
35193519
operation_id="add_worms_taxon",
35203520
tags=["Taxonomy Tree"],
3521-
response_class=Response,
3521+
response_model=Any,
35223522
)
35233523
def add_worms_taxon(
35243524
taxon: AddWormsTaxonModel = Body(...),
35253525
_current_user: Optional[int] = Depends(get_optional_current_user),
3526-
) -> Response:
3526+
) -> Any:
35273527
"""
3528-
Add worms taxon with or without lineage information
3528+
Add worms taxon by its aphia_id
35293529
"""
35303530
with CentralTaxonomyService() as sce:
3531-
ret = sce.add_worms_taxon(taxon.aphia_id, _current_user)
3532-
response = Response(json.dumps(ret.json()), media_type="application/json")
3533-
response.status_code = ret.status_code
3534-
return response
3531+
with RightsThrower():
3532+
return sce.add_worms_taxon(taxon.aphia_id, _current_user)
35353533

35363534

35373535
# ######################## END OF TAXA_REF

0 commit comments

Comments
 (0)