Questions tagged [jsonapi-resources]

JSONAPI-Resources is a Ruby library to write clients and servers for the JSONAPI standard.

JSONAPI-Resources is a Ruby library to write clients and servers for the JSON API standard.

JSONAPI may be regarded as a set of best practices for writing JSON-based APIs, or as an actual standard. JR's github page serves as its home page and the author's blog contains some introductory postings.

111 questions
2
votes
0 answers

JSON API Resources relationship attributes

I have two models related : class Item < ActiveRecord::Base belongs_to :carousel end And class Carousel < ActiveRecord::Base has_many :items end I trying to open API to carousels using the JSON API Resources gem, i need to show carousel…
2
votes
1 answer

Disable pagination for relationships

Given 2 resources: jsonapi_resources :companies jsonapi_resources :users User has_many Companies default_paginator = :paged /companies request is paginated and that's what I want. But I also want to disable it for relationship request…
Oleg Antonyan
  • 2,943
  • 3
  • 28
  • 44
2
votes
0 answers

Setting up a simple signup/signin with Doorkeeper and JSONAPI

Short story I'm having a difficult time to add Doorkeeper to my working JSONAPI project. Since I'm new to it, I think one of the biggest problems is the understanding of the framework. Basically I need any further requests to contain an AccessToken…
2
votes
1 answer

JSONAPI Resources gem not finding resource after adding namespace

I tried to namespace my resources and controllers, but now when I try to run my server it keeps getting this error: JSONAPI: Could not find resource 'categories'. (Class CategoryResource not…
2
votes
2 answers

Namespacing JSONAPI resource and controller

I'm trying to add a namespace to my 'Category' controller and resource. So the first thing I did was to move the categories_controller.rb to app/controllers/api/v1/categories_controller and the category_resource.rb to app/resources/api/v1/ And then…
Victor Ferreira
  • 6,151
  • 13
  • 64
  • 120
2
votes
2 answers

Using devise_token_auth with jsonapi-resources

I am trying to use devise_token_auth with jsonapi-resources. I have it set up where I can create users and sign in, but I cannot figure out how to access a controller that has needs to authenticate a user first. Here is my controller that I am…
Caleb Sayre
  • 401
  • 1
  • 4
  • 12
2
votes
3 answers

How to rename property/attribute of resource with jsonapi-resources ruby gem

I am building json api with rails using jsonapi-resources gem. The library is really great, it does a lot of job. However some column names in our DB is not really meaninful to be showed in API. So, my question: is possible to rename…
Sergey Potapov
  • 3,819
  • 3
  • 27
  • 46
1
vote
1 answer

Flutter handle future response

i want to store token value and navigate home page using go router after login. i dont know how to handle json data like display or (retrieve)name and role.. i am newbie for programming. Help me.thanks in advance.i tried futurebuilder examples it…
1
vote
1 answer

JSONAPI: is it correct to have different types in data[]?

is it correct to have different types in data array ? didn't found answer in specification, but looks wrong. { "data": [ { "type": "type1", "id": "id1" }, { "type": "type2", "id": "id2" } ] }
1
vote
0 answers

JSONAPi::Resource limiting models that can be requested in include

I am using the Ruby gem JSONAPI::Resources, the model has quite a few related objects, and I don't want to expose all of them to be queried though the include option in URL. localhost:3000/api/v1/posts?include=author but since there are are comments…
Babar
  • 1,202
  • 1
  • 12
  • 21
1
vote
0 answers

Parsing array from JSON response body with JSONAPI::Resource in Rails

So I got two Rails 6 applications: Backend (API only) with gem 'jsonapi-resources', '~> 0.9' with gem 'jsonb_accessor', '~> 1.0' Frontend with gem 'json_api_client', '~> 1.18' In the Backend part I setup a Model (Car) which has a jsonb field…
Severin
  • 8,508
  • 14
  • 68
  • 117
1
vote
1 answer

error with polymorphism and jsonapi-resources

I'm trying to setup a polymorphic association using the jsonapi-resources gem in Rails 5. I have a User model that has a polymorphic association called profile, which can be of type Inspector or Buyer. Here are the truncated models: class User <…
jdixon04
  • 1,435
  • 16
  • 28
1
vote
1 answer

How can I filter created_at by current year with JSONAPI::Resources?

I'm developing an Rails REST API using JSONAPI::Resources. And some resources, by default, must send only the records created in the current year, but it should also be possible for the client application to override this behavior in order to get…
ardmont
  • 105
  • 8
1
vote
2 answers

Laravel API Resource doesn't work in Controller Method

My Post Model has the following format: { "id": 1, "title": "Post Title", "type: "sample" } Here is my controller method: public function show($id) { $post = App\Post::find($id); $transformedPost = new PostResource($post); …
Scarecrow
  • 66
  • 6