Open beauby opened 8 years ago
We probably need to start merging the PRs :-) I'll do some code review when I get home later tonight (6-7 hours from now)
is render jsonapi_errors: foo
really required?
I think best case 'Railsy' way of doing it would be to render jsonapi: model
and and have it auto-determine if there are errors and render the errors?
For api versioning, what are you thinkin' here? as far as i'm aware, everything is explicitly called so far. Unless we want to do a serializer lookup, like what AMS has? I'd be down with that.
Also Sidenote -- the more this gets fleshed out, the more I think AMS would just become a super thin wrapper for jsonapi-rails
and just add support for the current json and attributes adapters where teh jsonapi adapter would be straight passthrough.
Serializer lookup is already implemented in JSONAPI::Serializable::Model
, as well as API versioning.
Regarding errors, that is a possibility, but we must support custom errors as well.
Regarding AMS: yeah, that's a possibility, though I'm not sure what the value would be, as it is currently a pain to use different adapters simultaneously in AMS.
Serializer lookup is already implemented in JSONAPI::Serializable::Model, as well as API versioning.
ah ok, cool. I haven't looked at that yet.
Regarding errors, that is a possibility, but we must support custom errors as well.
Maybe jsonapi: model, error_serializer: WhateverErrorSerializer
?
Regarding AMS: yeah, that's a possibility, though I'm not sure what the value would be, as it is currently a pain to use different adapters simultaneously in AMS.
agreed -- my motivation here is to greatly simplify AMS while still moving forward with the cleanup of it. And to keep things somewhat compatible current (proper) use.
Maybe
jsonapi: model, error_serializer: WhateverErrorSerializer
?
Errors are not limited to model validation errors, so that would not work. Errors in general are objects that respect the JSONAPI::Serializable::Error
API (which is simply #as_jsonapi
at the moment).
The interesting PRs in the other projects are:
maybe the jsonapi
renderer could detect when model
(in this case) is of type `JSONAPI::Serializable::Error and just render with that?
maybe the
jsonapi
renderer could detect whenmodel
(in this case) is of type `JSONAPI::Serializable::Error and just render with that?
That is not possible because it is intended to be just an interface, not a required parent class. Plus, it seems sensible to me to knowingly respond with errors rather than with a success document.
yeah hmmm
As discussed, here's what I've been working on. cc @NullVoxPopuli
What's there so far (beauby):
ActiveRecord
models.JSONAPI::Serializable::Model
andJSONAPI::Deserializable::Resource
.render jsonapi: foo
, with (optional) automatic serializable class inference.Also, what's been done in other places for that to work:
JSONAPI::Serializable::Model
(subclass ofJSONAPI::Serializable::Resource
focused on resources that are direct representations of models), with API versioning-aware serializable inference.JSONAPI::Deserializable::Resource
DSL – less magic, more power.What I'd like to see done:
render jsonapi_errors: foo
, and automatic handling of AR validation errors and such.JSONAPI::Serializable::Model
.