{"id":13879191,"url":"https://github.com/EmCousin/grape-jsonapi","last_synced_at":"2025-07-16T15:31:39.980Z","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-06-05T05:34:03.000Z","size":120,"stargazers_count":39,"open_issues_count":3,"forks_count":17,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-05T19:12:16.608Z","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}},"created_at":"2018-02-28T12:18:42.000Z","updated_at":"2025-05-27T21:01:45.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","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265521431,"owners_count":23781501,"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":["fast-jsonapi","fastjsonapi","gem","grape","grape-api","jsonapi","model-parser","netflix","rails","ruby","ruby-on-rails","swagger"],"created_at":"2024-08-06T08:02:12.883Z","updated_at":"2025-07-16T15:31:39.736Z","avatar_url":"https://github.com/EmCousin.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"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","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"}