Comments (1)
So, there are two distinct things going on here.
The first is that the json-api library is trying to read your schema to automatically generate documentation, and, as you suggest, it's having trouble with arrays of embedded objects. That's definitely a bug/missing feature, and I'll keep this issue open as a reminder to add it.
But there's a deeper problem here, which is that the JSON API specification, which this library merely implements, doesn't (yet) support nesting data in the way you're trying to do. Here's the relevant paragraph from the spec:
Complex data structures involving JSON objects and arrays are allowed as attribute values. However, any object that constitutes or is contained in an attribute MUST NOT contain a
relationships
orlinks
member, as those members are reserved by this specification for future use.
In other words, having a messages
attribute that holds an array of objects is ok, but those objects can't have a relationship to other model(s), so the author
relationship to User
is impossible.
There has been much discussion about allowing relationships in object attributes, and it may well happen—but not for at least a few months. These spec things move slowly, unfortunately.
For now, therefore, I'd suggest making message
into it's own model, and having message contain a relationship to the discussion that owns it (or vice-versa). Then everything will work smoothly with this library and the specification.
from json-api.
Related Issues (20)
- Filtering not working for me HOT 7
- Patch requests problem HOT 1
- Performance: Fetching a relationship needlessly loads the whole resource HOT 1
- Filtering relationships HOT 1
- Duplicate scheme in root object.
- json-api reads from Raw URLs instead of decoded HOT 3
- Allow feature to populate embedded data HOT 2
- Fastify integration HOT 3
- Incorrect Content-type on responses HOT 5
- Provide Koa example
- Filter not working HOT 8
- andWhere query is not working HOT 11
- Issue with serverless
- Add debug environment variable on README.md HOT 1
- Suggestion for Projects
- Example in README.md has unused variable 'opts' HOT 1
- Express `req.host` deprecation warning HOT 3
- How to work around `id` and `type` field names? HOT 4
- Svelte js Express Firebase?
- Please give a workable example HOT 3
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 json-api.