Formatting of not-included to-many relationships

36 views
Skip to first unread message

Ken Goettler

unread,
Jun 16, 2021, 9:41:00 AMJun 16
to MBTA Developers
Hi,

I'm having a hard time parsing some responses in my application (Swift-based). I'm trying to parse a "routes" query with no includes, but the formatting of the to-many relationships appear to deviate from the JSON:API.

For instance, calling https://api-v3.mbta.com/routes/Red gives the following relationships:

"relationships":{
  "line":{
    "data":{
      "id":"line-Red",
      "type":"line"
    }
  },
  "route_patterns":{}
}

route_patterns is just an empty object which makes it appear as a to-one object. However, given that it is a to-many object I would expect the response to be:

"relationships":{
  "line":{
    "data":{
      "id":"line-Red",
      "type":"line"
    }
  },
  "route_patterns":{
    "data": []
  }
}

route_patterns here is an object with a "data" field containing an empty array. The spec says that a relationship object must contain at least one of either links, data, or meta. But here they contain nothing.

Am I misinterpreting the specification? Or is this a bug?

Thanks,

Ken

Developer at MBTA

unread,
Jun 28, 2021, 11:34:32 AMJun 28
to MBTA Developers
Hi Ken, thanks for bringing this to our attention. This is in fact a bug, and we will likely have a fix deployed sometime this week. Once this is done, not-included relationships should not appear at all in the response, instead of appearing with an empty object as the value. If you would like to follow the change on GitHub it is here, though note this change being merged does not mean it is deployed yet.

—Developer@MBTA

Developer at MBTA

unread,
Jun 30, 2021, 11:34:12 AMJun 30
to MBTA Developers
Quick update: this issue should now be resolved.

Ken Goettler

unread,
Jul 1, 2021, 11:08:32 AMJul 1
to MBTA Developers
Looks great - thanks for the fix!
Reply all
Reply to author
Forward
0 new messages