Comments (11)
From @franzliedke on December 16, 2015 13:45
In addition, when no link is defined for a relationship, the :relationships
key will still contain an element called :links
, which is set to nil
- it simply shouldn't exist. I was trying to fix this issue, when I encountered the behavior that I reported above.
from roar-jsonapi.
From @apotonick on December 17, 2015 0:2
I am seriously thinking about roar-jsonapi
as a separate gem, because I personally do not want to support this convoluted format. I have worked on it for several months now and I still don't understand all it's implicit conditions, which is not appreciated and which is definitely not a good sign for a simple, easy-to-understand media format.
from roar-jsonapi.
From @apotonick on December 17, 2015 0:8
Links in has_one
will be rendered in both "sections" (I don't even know the name for all their 523145 different fragment types). We either have to provide an option to say "this link is only meant for relationships
or for the included
thing".
Or two different property methods to indicate whether you're declaring a included
or a relationship
fragment.
As for the nil
problem, can you please add a test?
from roar-jsonapi.
From @dvogel on December 17, 2015 2:23
I'm dealing with a very similar ambiguity. I need to be able to declare a relationship from resource A to B without the JSONAPI body for resource type A from including the represented form of resource B in the serialized relationships object. I want the much simpler:
{
"data": {
"relationships": {
"Bs": {
"links": {
"related": "scheme://host/As/.../Bs"
}
}
}
"type": "A",
"attributes": { ... },
}
}
Changing Document#render_relationships
to omit items if they lack type
and/or id
achieves my goal for the output. However, I would like to avoid having the underlying accessor method called at all because in some cases the accessor is expensive to call (fetches remote data).
from roar-jsonapi.
From @apotonick on December 17, 2015 2:46
@dvogel This is all easily solvable by maintaining two different representer implementation for the two different fragments. Internally, this is how it's implemented already, so we just have to come up with a sensitive API/DSL to tell Roar that.
The main problem is that I don't use JSON API and I have no insight on what is needed and how this ridiculous media format is supposed to work.
from roar-jsonapi.
From @franzliedke on December 18, 2015 13:12
@apotonick Submitted my test and fix in #178.
from roar-jsonapi.
From @apotonick on December 18, 2015 22:34
So this fixes the nil
link, but we still need to sort out how to say "in has_one
, this goes into the included
, this goes into the relationships
part", right?
from roar-jsonapi.
From @franzliedke on December 18, 2015 23:19
Indeed. If you don't come up with anything by then, I'll make a suggestion after the holidays. Cheers and merry christmas! :)
from roar-jsonapi.
From @apotonick on December 18, 2015 23:49
"No pressure, Nick!" 😬
from roar-jsonapi.
Reference: Reference: http://jsonapi.org/format/#document-resource-object-relationships
from roar-jsonapi.
@franzliedke not sure if this issue is still relevant for you, but if it is, I'd appreciate feedback on this fix.
from roar-jsonapi.
Related Issues (20)
- [JSON-API] Nested polymorphic representation HOT 5
- JSON-API support for :extends/:decorator with has_one
- JSON API dasherize property names HOT 4
- References represented inside of link block using JSONAPI implementation HOT 4
- JSON-API representer does not work with Roar::Client HOT 1
- Properties convert as camelize(:lower) HOT 6
- Representers: `defaults` block is lost in nested declarations HOT 3
- Collection representation HOT 8
- Update Operation with Roar JSONAPI representer forces contract to open up id HOT 1
- double included fields HOT 4
- Compound Documents not rendered per JSONAPI standard? HOT 2
- Performance issue when decorator files are loaded multiple times HOT 4
- Collections `to_json(included: 'xxx')` doesn't output included records HOT 9
- Representer attributes with null values are excluded from resource document
- Should be able to return relationship links without including the related representer
- How to set the type of included items? HOT 5
- Using JSONAPI HOT 4
- [JSON-API] Rendering an empty relationship HOT 3
- [JSON-API] Recursive has_many :children (include tree) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roar-jsonapi.