{"id":14969823,"url":"https://github.com/emcousin/grape-jsonapi","last_synced_at":"2026-02-13T03:21:14.988Z","repository":{"id":39699552,"uuid":"123280943","full_name":"EmCousin/grape-jsonapi","owner":"EmCousin","description":"Use jsonapi-serializer with Grape","archived":false,"fork":false,"pushed_at":"2025-08-14T00:14:51.000Z","size":130,"stargazers_count":40,"open_issues_count":6,"forks_count":18,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T03:44:54.443Z","etag":null,"topics":["fast-jsonapi","fastjsonapi","gem","grape","grape-api","jsonapi","model-parser","netflix","rails","ruby","ruby-on-rails","swagger"],"latest_commit_sha":null,"homepage":"","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/EmCousin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-02-28T12:18:42.000Z","updated_at":"2025-07-09T09:58:27.000Z","dependencies_parsed_at":"2023-02-10T23:30:28.806Z","dependency_job_id":"e9b5a30e-860e-4542-945d-fe36638b5413","html_url":"https://github.com/EmCousin/grape-jsonapi","commit_stats":{"total_commits":103,"total_committers":9,"mean_commits":"11.444444444444445","dds":"0.38834951456310685","last_synced_commit":"af289d3a5d1e3975d3007ea1e050a394bd3cd3ba"},"previous_names":["emcousin/grape_fast_jsonapi"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/EmCousin/grape-jsonapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Fgrape-jsonapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Fgrape-jsonapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Fgrape-jsonapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Fgrape-jsonapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EmCousin","download_url":"https://codeload.github.com/EmCousin/grape-jsonapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Fgrape-jsonapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278981518,"owners_count":26079640,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["fast-jsonapi","fastjsonapi","gem","grape","grape-api","jsonapi","model-parser","netflix","rails","ruby","ruby-on-rails","swagger"],"created_at":"2024-09-24T13:42:27.159Z","updated_at":"2025-10-08T17:11:36.534Z","avatar_url":"https://github.com/EmCousin.png","language":"Ruby","readme":"[![CircleCI](https://circleci.com/gh/EmCousin/grape-jsonapi/tree/master.svg?style=svg)](https://circleci.com/gh/EmCousin/grape-jsonapi/tree/master)\n\n# Grape::Jsonapi\n\nUse [jsonapi-serializer](https://github.com/jsonapi-serializer/jsonapi-serializer) with [Grape](https://github.com/ruby-grape/grape).\n\n## Installation\n\nAdd `grape-jsonapi` to your Gemfile.\n\n```ruby\ngem 'grape-jsonapi', require: \"grape_jsonapi\"\n```\n\n## Usage\n\n### Tell your API to use Grape::Formatter::Jsonapi\n\n```ruby\nclass API \u003c Grape::API\n  content_type :jsonapi, \"application/vnd.api+json\"\n  formatter :json, Grape::Formatter::Jsonapi\n  formatter :jsonapi, Grape::Formatter::Jsonapi\nend\n```\n\n### Use `render` to specify JSONAPI options\n\n```ruby\nget \"/\" do\n  user = User.find(\"123\")\n  render user, include: [:account]\nend\n```\n\n### Use a custom serializer\n\n```ruby\nget \"/\" do\n  user = User.find(\"123\")\n  render user, serializer: 'CustomUserSerializer'\nend\n```\n\nOr\n\n```ruby\nget \"/\" do\n  user = User.find(\"123\")\n  render CustomUserSerializer.new(user).serialized_json\nend\n```\n\n### Override `meta`and `links` properties\n\n`meta` and `links` properties are usually defined per resource within your serializer ([here](https://github.com/jsonapi-serializer/jsonapi-serializer#meta-per-resource) and [here](https://github.com/jsonapi-serializer/jsonapi-serializer#links-per-object))\n\nHowever, if you need to override those properties, you can pass them as options when rendering your response:\n```ruby\nuser = User.find(\"123\")\nrender user, meta: { pagination: { page: 1, total: 42 } }, links: { self: 'https://my-awesome.app.com/users/1' }\n```\n\n### Model parser for response documentation\n\nWhen using Grape with Swagger via [grape-swagger](https://github.com/ruby-grape/grape-swagger), you can generate response documentation automatically via the provided following model parser:\n\n```ruby\n# FastJsonapi serializer example\n\n# app/serializers/base_serializer.rb\nclass BaseSerializer; end\n# app/serializers/user_serializer.rb\nclass UserSerializer \u003c BaseSerializer\n  include JSONAPI::Serializer\n\n  set_type :user\n  has_many :orders\n\n  attributes :name, :email\nend\n\n# config/initializers/grape_swagger.rb\nGrapeSwagger.model_parsers.register(GrapeSwagger::Jsonapi::Parser, BaseSerializer)\n\n# Your grape API endpoint\ndesc 'Get current user' do\n  success code: 200, model: UserSerializer, message: 'The current user'\n# [...]\nend\n```\n\nNote that you **need** the `grape-swagger` gem for this to work, otherwise it will throw an error.\n\n## Credit\n\nCode adapted from [grape-jsonapi-resources](https://github.com/cdunn/grape-jsonapi-resources)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femcousin%2Fgrape-jsonapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femcousin%2Fgrape-jsonapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femcousin%2Fgrape-jsonapi/lists"}