{"id":13879832,"url":"https://github.com/4xposed/grape-sideload","last_synced_at":"2025-07-02T19:33:34.679Z","repository":{"id":56875149,"uuid":"76801713","full_name":"4xposed/grape-sideload","owner":"4xposed","description":"Add support for sideload JSON in your Grape API","archived":false,"fork":false,"pushed_at":"2018-10-01T15:09:23.000Z","size":13,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-13T05:37:00.893Z","etag":null,"topics":["grape","grape-api","ruby","sideload"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/4xposed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-18T19:18:26.000Z","updated_at":"2023-11-20T08:11:51.000Z","dependencies_parsed_at":"2022-08-20T22:30:47.211Z","dependency_job_id":null,"html_url":"https://github.com/4xposed/grape-sideload","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4xposed%2Fgrape-sideload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4xposed%2Fgrape-sideload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4xposed%2Fgrape-sideload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4xposed%2Fgrape-sideload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4xposed","download_url":"https://codeload.github.com/4xposed/grape-sideload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252596323,"owners_count":21773842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grape","grape-api","ruby","sideload"],"created_at":"2024-08-06T08:02:34.993Z","updated_at":"2025-05-05T23:44:34.194Z","avatar_url":"https://github.com/4xposed.png","language":"Ruby","readme":"# Grape::Sideload\n[![Gem Version](https://badge.fury.io/rb/grape-sideload.svg)](https://badge.fury.io/rb/grape-sideload)\n[![Build Status](https://travis-ci.org/4xposed/grape-sideload.svg?branch=master)](https://travis-ci.org/4xposed/grape-sideload)\n[![Dependency Status](https://gemnasium.com/badges/github.com/4xposed/grape-sideload.svg)](https://gemnasium.com/github.com/4xposed/grape-sideload)\n[![Code Climate](https://codeclimate.com/github/4xposed/grape-sideload/badges/gpa.svg)](https://codeclimate.com/github/4xposed/grape-sideload)\n\nAdd JSON sideloading support to your Grape API so you can deliver multiple resources under one endpoint.\n\n## Table of Contents\n\n- [What is Grape?](#what-is-grape)\n- [What is Sideloading JSON?](#what-is-sideloading-json)\n- [Why do I need this gem?](#why-do-i-need-this-gem)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Contributing](#contributing)\n- [License](#license)\n\n## What is Grape?\nGrape is a ruby framework for creating APIs\n[grape](https://github.com/ruby-grape/grape)\n\n## What is Sideloading JSON?\nSideloading allows you to deliver related records as part of a single request.\n\nFor example, normally a request to `/tickets.json` returns ticket resources with a structure similar to:\n```\n{\n  \"tickets\": [\n    {\n      \"requester_id\": 7,\n      ...\n    },\n    ...\n  ]\n}\n```\nTo fetch the requester's data, your consumer then needs to make another request to `/users/7.json`.\n\nUsing sideloading, you can deliver a the user resource along with the ticket in a single request.\n\nThe response will include a top-level array of associated data under the appropriate resource key.\n```\n{\n  \"tickets\": [\n    {\n      \"requester_id\": 7,\n      ...\n    },\n    ...\n  ],\n  \"users\": [\n    {\n      \"id\": 7,\n      \"name\": \"Bob Bobberson\",\n      ...\n    }\n  ]\n}\n```\n\n## Why do I need this gem?\nThe Grape framework doesn't offer support for sideloading the resources you deliver with your API's\nresponse, this gem will help you doing exactly that in a simple manner.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'grape-sideload'\n```\n\nthen execute:\n\n    $ bundle\n\nAnd add to your `app.rb`\n\n```ruby\nrequire 'grape-sideload'\n```\n\n\n## Usage\n\nexample for sideloading with `present_many`:\n\n```ruby\nresources :tickets do\n  get do\n    present_many({ present: current_user.tickets, with: Ticket::Entity },\n                 { present: current_user, with: User::Entity})\n  end\nend\n```\n\nexample for sideloading with `merge_payloads` to sideload using grape's present syntax:\n\n```ruby\nresource :tickets do\n  get do\n    merge_payloads(present(current_user.tickets, with: Ticket::Entity),\n                   present(current_user, with: User::Entity))\n\n  end\nend\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/4xposed/grape-sideload. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4xposed%2Fgrape-sideload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4xposed%2Fgrape-sideload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4xposed%2Fgrape-sideload/lists"}