Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial responses #3

Open
nickevansuk opened this issue Jul 16, 2018 · 1 comment
Open

Partial responses #3

nickevansuk opened this issue Jul 16, 2018 · 1 comment

Comments

@nickevansuk
Copy link
Contributor

nickevansuk commented Jul 16, 2018

Use Case

For mobile device usecases, a restricted number of fields returned enables the implementer to minimise data transfer.

References

Proposal

The fields keyword is reserved to allow for the restriction of properties returned in the response.

/sessions?fields=name,startDate,subEvent[1].startDate,subEvent[1].endDate

  • A list of properties to be included, using dot notation
  • Add limits to the number of items returned for properties where an array is available (note the limits are per-field, to allow the first item to contain more fields than subsequent items).
  • If an object is specified without specific fields (e.g. location.address) return the whole object.

Examples

/sessions?fields=name,activity,location.address,offers.name,offers.price,offers.priceCurrency

  "items": [
    {
      "name": "Example Leisure Centre Table Tennis",
      "activity": "Table Tennis",
      "location": {
        "address": {
          "type": "PostalAddress",
          "streetAddress": "1 High Street",
          "addressLocality": "Bristol",
          "postalCode": "BS1 4SD"
        }
      },
      "offers": [
        {
          "name": "30 minute hire",
          "price": "10",
          "priceCurrency": "GBP"
        },
        {
          "name": "60 minute hire",
          "price": "10",
          "priceCurrency": "GBP"
        }
      ]
   }
 ]

/sessions?fields=name,activity,location.address.postalCode,offers[1].price,offers[1].priceCurrency,offers[2].name

  "items": [
    {
      "name": "Example Leisure Centre Table Tennis",
      "activity": "Table Tennis",
      "location": {
        "address": {
          "postalCode": "BS1 4SD"
        }
      },
      "offers": [
        {
          "name": "30 minute hire",
          "price": "10",
          "priceCurrency": "GBP"
        },
        {
          "name": "60 minute hire"
        }
      ]
   }
 ]
@lukehesluke
Copy link

@nickevansuk this looks good to me but have the following thoughts:

  • For accessing across the items of an array, could use e.g. offers[].price (same syntax as in JQ https://stedolan.github.io/jq/manual/#Array/ObjectValueIterator:.[] )
  • Comma separation of multiple terms should be consistent with strategy we go for in Filtering issue (Filtering #1) w.r.t. multiple terms. e.g. it could be fields=name,activity, fields=name&fields=activity, fields[]=name&fields[]=activity, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants