avniproject / avni-server

Backend APIs for Avni
https://avniproject.org
GNU Affero General Public License v3.0
7 stars 25 forks source link

Subject type not available in /api/subjects #712

Closed vinayvenu closed 5 months ago

vinayvenu commented 5 months ago

The value of "Subject type" is available only when it is requested in the url, and not present when it is not requested in the url.

eg:

Request https://app.rwb.avniproject.org/api/subjects?subjectType=Farmer Response

{
    "content": [
        {
            "Subject type": "Farmer",
            "ID": "a6caa3d2-3d95-45c7-b439-15dc0a59467e",
...

Request https://app.rwb.avniproject.org/api/subjects Response

{
    "content": [
        {
            ~~"Subject type": "Farmer",~~
            "ID": "a6caa3d2-3d95-45c7-b439-15dc0a59467e",
...
himeshr commented 5 months ago

This change could cause issues for other External API consumers, as they might rely on the field to determine the subjectType amongst the returned entities, when invoking GET ALL Subjects.

If a change is to be done, i would recommend retaining the subjectType Name details always irrespective of "subjectType=" filter being specified.

vinayvenu commented 5 months ago

@himeshr this was a recent break in functionality. I doubt if any existing consumers will be affected by it.

vinayvenu commented 5 months ago

Relevant commit fb31d5c0636c1fb704f5dbd30821bfe830c8f714