Questions tagged [jsonapi-serialize]

19 questions
3
votes
2 answers

Using JSON API Serializer to create more complicated JSON

The examples here don't go nearly far enough in explaining how to produce a more complicated structure... If I want to end up with something like: { "data": { "type": "mobile_screens", "id": "1", "attributes": { "title": "Watch" …
two7s_clash
  • 5,755
  • 1
  • 27
  • 44
2
votes
1 answer

Rails JSON API serializer with custom attributes

I am working on an RoR project with ruby-2.5.0 and rails 5. I am using the jsonapi-serializers for my API. I want to customize the attributes of the associated model. I have two models Receipt and ReceiptPartial. receipt has_many :receipt_partials.…
awsm sid
  • 595
  • 11
  • 28
1
vote
2 answers

Conditional attributes with jsonapi-serializers throwing TypeError

I am working on a Ruby on Rails project with ruby-2.6.0 and Rails 6. i am working on api part, i have used jsonapi-serializers gem in my app. I want to add conditional attribute in serializer. Controller: class OrderDetailsController <…
awsm sid
  • 595
  • 11
  • 28
1
vote
0 answers

How to Convert JsonApiSerializerSettings and JsonOutputFormatter to .Net Core 3.0

Hi Im current changing out a solution from targetting .Net Core 2.2 to .Net Core 3.0. The .Net Core2.2 soultion has the JsonApiSerializerSettings and JsonOutputFormatter setup as below. var jsonApiSerializerSettings = new…
1
vote
1 answer

How to write unit test using rspec for serializer with custom attributes

Hi i am working on a RoR project with ruby-2.5.0 and rails 5. I am using the jsonapi-serializers for my api. I have a serializer with custom attribute as follows:- class ReceiptPartialSerializer include JSONAPI::Serializer TYPE = 'receipt' …
awsm sid
  • 595
  • 11
  • 28
1
vote
1 answer

(Ember.js) How to save Sideloaded data from ajax call?

Good day! Just want to ask on how to create a JSONAPISerializer for an ajax call? From what I understand on the docs. I must first create a model before I can make a JSONAPISerializer. But I need to call a custom endpoint that is not listed as my…
JAKITOVZ
  • 41
  • 2
0
votes
2 answers

JSONAPI Complex attributes

Is this sample in a correct format based on JSON API specifications? In another word can we have in attributes an array? { "meta": { }, "links": { "self": "" }, "jsonapi": { "version": "", "meta": { } }, "data": { …
tulipe
  • 676
  • 2
  • 8
  • 22
0
votes
1 answer

JsonApi Serializer Not Found

I have run gem 'jsonapi-serializer' and bundle install. I then try to run a generator rails g serializer User username id but the command always freezes. So I created the serializer manually: # app/serializers/user_serializer.rb class…
0
votes
1 answer

Way to include multiple relationships with same id and type in jsonapi

I have this requirement of fetching data from database based on id. This record can have multiple values for same id and type since it is of type history. The versions however that we use change everytime. Sample of what I want and what I am getting…
Shruti Joshi
  • 301
  • 1
  • 4
  • 16
0
votes
1 answer

Jsonapi serializer parameters to has_many query

I would need to filter the records to include for has_many relation with the params that are passed to the serializer. The object_method_name option is invoking a method in the model, but how can I pass the params to the method? Or is there a way to…
Mika
  • 1,419
  • 18
  • 37
0
votes
1 answer

How to customize jsonapi-serializer caching namespace - Ruby on Rails

In my rails application I have categories which are classified based on location. I want to cache these categories on serializer level by using jsonapi-serializer's caching method cache_options store: Rails.cache, namespace: 'jsonapi-serializer',…
0
votes
1 answer

How to save a nested one-to-many relationship in API-only Rails?

In my Rails (api only) learning project, I have 2 models, Group and Album, that have a one-to-many relationship. When I try to save the group with the nested (already existing) albums, I get the following error, ActiveRecord::RecordNotFound…
0
votes
1 answer

How to save a nested many-to-many relationship in API-only Rails?

In my Rails (api only) learning project, I have 2 models, Group and Artist, that have a many-to-many relationship with a joining model, Role, that has additional information about the relationship. I have been able to save m2m relationships before…
0
votes
1 answer

Flutter : The getter was called on null (JSON API call)

I've a problem where I know where something went wrong but I can't figure how to solve it. I'm new to the Flutter developpement and I'm trying to create an application. For this application, I need to call an API that return data, but based on what…
Psykotik
  • 3
  • 4
0
votes
1 answer

Filter Django ResourceRelatedField's queryset

In our project we are using ResourceRelatedField for a foreign key field in one of our serializers to comply with JSON:API format. This is how it looks: types = ResourceRelatedField( queryset=Type.objects, many=True ) The…
Akbar
  • 416
  • 5
  • 20
1
2