Skip to content

Commit

Permalink
API tweaks for user search and access:
Browse files Browse the repository at this point in the history
- Run Pydantic validation in search-users endpoint

- Ensure creator ID is returned by `/items` endpoint within creators object
  • Loading branch information
ml-evs committed Nov 6, 2024
1 parent b49a3d9 commit dec22ff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pydatalab/src/pydatalab/routes/v0_1/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pydatalab.logger import LOGGER
from pydatalab.models import ITEM_MODELS
from pydatalab.models.items import Item
from pydatalab.models.people import Person
from pydatalab.models.relationships import RelationshipType
from pydatalab.models.utils import generate_unique_refcode
from pydatalab.mongo import flask_mongo
Expand Down Expand Up @@ -211,7 +212,7 @@ def creators_lookup() -> Dict:
},
}
},
{"$project": {"_id": 0, "display_name": 1, "contact_email": 1}},
{"$project": {"_id": 1, "display_name": 1, "contact_email": 1}},
],
"as": "creators",
}
Expand Down Expand Up @@ -922,5 +923,6 @@ def search_users():
},
]
)

return jsonify({"status": "success", "users": list(cursor)}), 200
return jsonify(
{"status": "success", "users": list(json.loads(Person(**d).json()) for d in cursor)}
), 200

0 comments on commit dec22ff

Please sign in to comment.