jsonapi.rb icon indicating copy to clipboard operation
jsonapi.rb copied to clipboard

Let `code` be usable in error objects response

Open curtis741 opened this issue 2 years ago • 2 comments

Expected Behavior

That I can set the code in the error response objects

Actual Behavior

I can only set these attributes:

{"status"=>nil, "source"=>nil, "title"=>nil, "detail"=>nil}

Steps to Reproduce the Problem

  1. use render jsonapi_errors: { code: "some_code" }

I think it all comes from here: https://github.com/stas/jsonapi.rb/blob/07a96dc7b8d709b1281d09168746e46115c2fd0e/lib/jsonapi/error_serializer.rb#L11

and according to the spec I should be able to do this: https://jsonapi.org/format/#error-objects

maybe it should also support meta, id and links as well when you supply something that isn't an active model to jsonapi_errors ?

curtis741 avatar Jun 21 '23 22:06 curtis741

@curtis741 sorry for the late response, please feel free to share a PR and we'll get it merged :pray:

stas avatar Jul 17 '23 09:07 stas

@stas opened: https://github.com/stas/jsonapi.rb/pull/95

curtis741 avatar Aug 24 '23 20:08 curtis741

This can be closed as https://github.com/stas/jsonapi.rb/commit/7a105a5c4951e51f410533780a40b9a2efa79c28

Faq avatar Apr 08 '24 10:04 Faq