Skip to content

Commit

Permalink
remove error msg for 'include=+all'
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaxxl committed Nov 19, 2024
1 parent ea8f1d5 commit 443c1e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion safrs/jsonapi_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ def create_query(cls):
if not safrs.SAFRS.OPTIMIZED_LOADING:
return query
included_csv = request.args.get("include", safrs.SAFRS.DEFAULT_INCLUDED)
if included_csv == safrs.SAFRS.INCLUDE_ALL:
included_list = cls._s_relationships.keys()
included_list = [inc for inc in included_csv.split(",") if inc]

for inc in included_list:
current_cls = cls
options = None
for inc_rel_name in inc.split("."):
if inc_rel_name == safrs.SAFRS.INCLUDE_ALL:
continue
if inc_rel_name not in current_cls._s_relationships:
safrs.log.error(f"Invalid relationship : {current_cls}.{inc_rel_name}")
safrs.log.warning(f"Invalid relationship : {current_cls}.{inc_rel_name}")
break
inc_rel = getattr(current_cls, inc_rel_name) # == current_cls._s_relationships[inc_rel_name]
if not hasattr(inc_rel, "lazy") or inc_rel.lazy not in ["select", "joined", "subquery", "selectin"]:
Expand Down
6 changes: 5 additions & 1 deletion safrs/safrs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ class Class_API(SAFRSRestAPI):
api_class = api_decorator(type(api_class_name + "_i", (rest_api,), properties), swagger_decorator)
self.add_resource(api_class, url, endpoint=endpoint, methods=["GET", "PATCH", "DELETE"])

object_doc = parse_object_doc(safrs_object)
try:
object_doc = parse_object_doc(safrs_object)
except Exception as exc:
log.error(f"Failed to parse docstring {e}")
object_doc = {}
object_doc["name"] = safrs_object._s_collection_name
self._swagger_object["tags"].append(object_doc)

Expand Down

0 comments on commit 443c1e2

Please sign in to comment.