diff --git a/application/routers/entity.py b/application/routers/entity.py index 535359f1..ad7c5ad7 100644 --- a/application/routers/entity.py +++ b/application/routers/entity.py @@ -259,11 +259,20 @@ def search_entities( extension: Optional[SuffixEntity] = None, session: Session = Depends(get_session), ): + # Determine if we should use the query parameter or the path parameter extension - if request.query_params.get("extension"): - extension = None + path_extension = None + if "." in request.url.path: + path_extension = request.url.path.split(".")[-1] + + # Determine the final extension to use + if path_extension: + final_extension = SuffixEntity(path_extension) else: - extension = extension + if request.query_params.get("extension"): + final_extension = None + else: + final_extension = extension # get query_filters as a dict query_params = asdict(query_filters) @@ -286,7 +295,7 @@ def search_entities( query = request.url.query links = make_links(scheme, netloc, path, query, data) - if extension is not None and extension.value == "json": + if final_extension is not None and final_extension.value == "json": if params.get("field") is not None: include = set([to_snake(field) for field in params.get("field")]) entities = _get_entity_json(data["entities"], include=include) @@ -302,7 +311,7 @@ def search_entities( entities = _get_entity_json(data["entities"]) return {"entities": entities, "links": links, "count": data["count"]} - if extension is not None and extension.value == "geojson": + if final_extension is not None and final_extension.value == "geojson": if params.get("exclude_field") is not None: exclude_fields = set( [