Closed zachdaniel closed 3 years ago
@zachdaniel I'm thinking of picking this up? can you tell me from where to start?
Sure! A recent addition to ash
was the ability to say what attributes and relationships will be accepted by an action. https://hexdocs.pm/ash/Ash.Resource.Dsl.Create.html?#create/2
For example, if you had this in a resource:
actions do
create :hire do
accept [:first_name, :last_name]
end
end
You're saying that the only attributes that can be changed are first_name
and last_name
. This also applies to relationship changes.
To support this, you'll want to update the json_schema, which is used for api validation.
Here https://github.com/ash-project/ash_json_api/blob/master/lib/ash_json_api/json_schema/json_schema.ex#L554 you can find where we say what attributes are allowed for a given action. We want to make sure to only include attributes in that list (as well as the required list) if they are in the accept
list on the action (which is the first argument here: https://github.com/ash-project/ash_json_api/blob/master/lib/ash_json_api/json_schema/json_schema.ex#L537. If the accept list is nil
, then it should keep its current behavior.
We need to make the same change for relationships, here: https://github.com/ash-project/ash_json_api/blob/master/lib/ash_json_api/json_schema/json_schema.ex#L559
This same thing needs to be done on the patch
function below the one I just linked you to.
Also, you'll want to find a good place to test this. The tests aren't in great shape at the moment, so let me know if you can't find a good place to add tests and I'll help you out.
@zachdaniel Sure, let me go through this once then.
@zachdaniel Need some help with test cases. Is there some place where I can reach out to you (gitter/slack anything)?
Sure! The discord is the best place, but slack works too: https://www.ash-elixir.org/community
Closed by #40
We should look at the new
accept
option for create/update actions, and only expose those fields in the json schema for that route.