Skip to content

Object relationships in API responses are inconsistent and unexpected #145

Description

@longhotsummer

We don't explicitly detail what should be returned by the API ito object relationships. This means that when you ask for https://api.pmg.org.za/committee/77/ for example, you get tabled committee reports and events nested, but not other nested relationships. This is both confusing and, at times, annoying if you don't want all that extra data.

Our serialisation code is home-grown and has weird edge cases like loops.

I'd like us to re-explore how we do serialisation in the API and be more explicit about it, with these goals:

  • we're explicit and consistent about returning nested relationships vs links.
  • use a 3rd party serialisation/schema package like marshmallow which has adapters for Flask and SQLAlchemy
  • allow the caller to specify what fields they want ala JSONAPI's sparse fieldsets. This is useful when we, say, want to load titles, dates and ids of all committee meetings for a particular committee, but don't want the summary and body (which are big). Marshmallow has rich support for this
  • version the new api under /v2/ or similar.

I've looked at Flask Restless but it's undergoing a major rewrite and there are a few others but nothing is very promising. So, rather than totally rewriting, I think we should focus on achieving the changes above which have benefit to us in the short term.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions