All Projects → trailblazer → Roar Jsonapi

trailblazer / Roar Jsonapi

Licence: mit
JSON API support for Roar.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Roar Jsonapi

Jsonapi Utils
Build JSON API-compliant APIs on Rails with no (or less) learning curve.
Stars: ✭ 191 (+377.5%)
Mutual labels:  rest, json-api
Json Api Dart
JSON:API client for Dart/Flutter
Stars: ✭ 53 (+32.5%)
Mutual labels:  rest, json-api
Reservoir
A back end for your front end: a content repository. Powered by Drupal 8, JSON API and OAuth2.
Stars: ✭ 262 (+555%)
Mutual labels:  rest, json-api
Jsonapiframework
JsonApiFramework is a fast, extensible, and portable .NET framework for the reading and writing of JSON API documents. Currently working on ApiFramework 1.0 which is a new framework that supports the many enhancements documented in the 2.0 milestone of this project while being media type agnostic but will support media types like {json:api} and GraphQL for serialization/deserialization purposes.
Stars: ✭ 85 (+112.5%)
Mutual labels:  rest, json-api
Jsonapidotnetcore
JSON:API Framework for ASP.NET Core
Stars: ✭ 465 (+1062.5%)
Mutual labels:  rest, json-api
Nextjs Graphql Sample
A simple app to demonstrate basic API functions built with REST and GraphQL
Stars: ✭ 29 (-27.5%)
Mutual labels:  rest
Oas Generator
NodeJS RESTful APIs scaffolding based OpenAPI 3.x specs using oas-tools and express.
Stars: ✭ 32 (-20%)
Mutual labels:  rest
Behapi
Behat extension for those who want to write acceptances tests for apis
Stars: ✭ 29 (-27.5%)
Mutual labels:  rest
Httpolice
Validator for HTTP
Stars: ✭ 948 (+2270%)
Mutual labels:  rest
Ktor Rest Sample
Sample REST Service written in Kotlin with Ktor Framework
Stars: ✭ 37 (-7.5%)
Mutual labels:  rest
Zeroeq
Cross-platform C++ library for fast binary and REST messaging
Stars: ✭ 35 (-12.5%)
Mutual labels:  rest
Alembic
JSONAPI 1.0 Elixir library
Stars: ✭ 31 (-22.5%)
Mutual labels:  json-api
Confluence Python Lib
A python library wrapping the Confluence REST API
Stars: ✭ 30 (-25%)
Mutual labels:  rest
Tools
C# 工具箱,提供Socket(TCP、UDP协议)、Redis、activemq、数据库访问等技术的封装实现
Stars: ✭ 34 (-15%)
Mutual labels:  rest
Versionist
A plugin for versioning Rails based RESTful APIs.
Stars: ✭ 950 (+2275%)
Mutual labels:  rest
Grocery Cms Php Restful Api
Grocery-CMS-PHP-Restful-API is an online grocery shop. The project is developed by using PHP/MySQL/Slim Restful API. The project has powerful backend cms to manage grocery shop online. it has features like add items, remove items, update price, manage orders etc. Restful API ready to embed in Application using JSON data.
Stars: ✭ 36 (-10%)
Mutual labels:  json-api
Apipie
Transform api declaration to js object for frontend. Inspired by VueRouter, koa-middleware and axios.
Stars: ✭ 29 (-27.5%)
Mutual labels:  rest
Server
Serve your Rubix ML models in production with scalable stand-alone model inference servers.
Stars: ✭ 30 (-25%)
Mutual labels:  json-api
Restful.js
A pure JS client for interacting with server-side RESTful resources. Think Restangular without Angular.
Stars: ✭ 977 (+2342.5%)
Mutual labels:  rest
Siodb
The simplicity of REST and the power of SQL combined in a database that automatized security and performance. Forget the database, develop faster and safer!
Stars: ✭ 31 (-22.5%)
Mutual labels:  rest

Roar JSON API

Resource-Oriented Architectures in Ruby.

Gitter Chat TRB Newsletter Build Status Gem Version

Roar JSON API provides support for JSON API, a specification for building APIs in JSON. It can render and parse singular and collection documents.

Resource

A minimal representation of a Resource can be defined as follows:

require 'roar/json/json_api'

class SongsRepresenter < Roar::Decorator
  include Roar::JSON::JSONAPI.resource :songs

  attributes do
    property :title
  end
end

Properties (or attributes) of the represented model are defined within an attributes block.

An id property will automatically defined when using Roar JSON API.

Relationships

To define relationships, use ::has_one or ::has_many with either an inline or a standalone representer (specified with the extend: or decorates: option).

class SongsRepresenter < Roar::Decorator
  include Roar::JSON::JSONAPI.resource :songs

  has_one :album do
    property :title
  end

  has_many :musicians, extend: MusicianRepresenter
end

Meta information

Meta information can be included into rendered singular and collection documents in two ways.

You can define meta information on your collection object and then let Roar compile it.

class SongsRepresenter < Roar::Decorator
  include Roar::JSON::JSONAPI.resource :songs

  meta toplevel: true do
    property :page
    property :total
  end
end

Your collection object must expose the respective methods.

collection.page  #=> 1
collection.total #=> 12

This will render the {"meta": {"page": 1, "total": 12}} hash into the JSON API document.

Alternatively, you can provide meta information as a hash when rendering. Any values also defined on your object will be overriden.

collection.to_json(meta: {page: params["page"], total: collection.size})

Both methods work for singular documents too.

class SongsRepresenter < Roar::Decorator
  include Roar::JSON::JSONAPI.resource :songs

  meta do
    property :label
    property :format
  end
end
song.to_json(meta: { label: 'EMI' })

If you need more functionality (and parsing), please let us know.

Usage

As JSON API per definition can represent singular models and collections you have two entry points.

SongsRepresenter.prepare(Song.find(1)).to_json
SongsRepresenter.prepare(Song.new).from_json("..")

Singular models can use the representer module directly.

SongsRepresenter.for_collection.prepare([Song.find(1), Song.find(2)]).to_json
SongsRepresenter.for_collection.prepare([Song.new, Song.new]).from_json("..")

Parsing currently works great with singular documents - for collections, we are still working out how to encode the application semantics. Feel free to help.

Support

Questions? Need help? Free 1st Level Support on irc.freenode.org#roar ! We also have a mailing list, yiha!

License

Roar is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].