jsonapi-rb / jsonapi-rails

Rails gem for fast jsonapi-compliant APIs.
http://jsonapi-rb.org
MIT License
318 stars 62 forks source link

map `:base` attribute to `'/data'` source pointer if not used as an attribute #106

Open gmkohler opened 5 years ago

gmkohler commented 5 years ago

The specification for "/data" in a JSONAPI error object's source attribute and the suggested usage of :base in ActiveModel::Error seem aligned.

Wrote this such that any actual :base attribute would override this, but not sure what sort of tests need to be added or whether it's worth adding at all.

JoeWoodward commented 4 years ago

Might make sense to make this customizable too. I use form objects and attach exceptions to an attr_accessor :exception which should also be attached to /data if this interpretation of the spec is correct.

The only thing I think might be wrong here is that nested association errors shouldn't be on base but rather on a relationship instead. However, that's not in v1 of the spec so not sure

gmkohler commented 4 years ago

@JoeWoodward can you write an example of what you mean by:

The only thing I think might be wrong here is that nested association errors shouldn't be on base but rather on a relationship instead

?