-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Her JSON API support #345
Comments
|
This issue should definitely be resolved before merging.
wow, just don't do this! What if I have Surprisingly, the answer lies in my issue #338. Look at how ActiveModel is implemented: virtual module is injected in a model class that stores all the attribute methods. Okay what if I have a Soooo I propose this solution:
|
It's also worth to have ability to somehow pass a But for now we could simply infer |
And I believe this all could be safely implemented without touching existing |
The idea would be to deprecate it. Her should remain flexible enough to consume any api. However, for standards we want to support, they should have a first class representation which doesn't require any custom configuration to consume.
I have a working PR in another fork. I'll create a PR so that people can look at it. It does not touch Her::Model which was one of my goals when writing this. |
4 I haven't described what to do when |
After all, API endpoint that sends |
@marshall-lee i agree with most of what you say. the top-level id and type attributes are both "api" rather than object attributes. namespacing the object attributes was done so that they could continue to add attrs as necessary and not conflict with whatever the user returns in attributes. i think that adding _type and _id methods are reasonable ways to go, but those methods will still shadow _id and _type that are passed within attributes. the user could still dig in and access them directly via attributes which would not be the norm, but i think that's fair to put that burden on the api developer. agree it is a corner case if id is passed within attributes. |
Yeah but be careful when adding Also |
But maybe... Add that But please undefine all these |
Hi All. There's been great activity with issues and PRs lately. thank you.
One of the things, I'm keen to see with Her moving forward is first class support for JSON API. It's got great momentum behind it and addresses a lot of the issues we deal with building APIs.
I propose we introduce a module such that the way you specify your model consumes and produces JSON API is a one-liner.
JSON API response follows this general format:
Underneath the hood, we introduce a parsing and serialization routine that translates to and from the JSON API format and the format Her expects.
Here are some benefits of this approach:
The main downside is that we would need to combine the top-level data namespace with the attributes namespace. If an "id" or "type" were passed in attributes different than the top level id, we'd need to figure out a way to resolve the conflict. Perhaps top-level "id" and "type" get added as "data_id" and "data_type" or something...
The text was updated successfully, but these errors were encountered: