-
Notifications
You must be signed in to change notification settings - Fork 47
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
Enable the DAB feature to show create-only serializer #775
Enable the DAB feature to show create-only serializer #775
Conversation
This fixes AAP-21919 thank you! However I noticed a new issue. The response after sending
|
Isn't that what you needed? Example of another "..Create" serializer:
And if I patch the DAB code to include the "id" field, it will show in "required", which was the thing this was trying to avoid. This does break the ability to "follow" the item after creation. AWX gives the full serialization of the item, and a "Location" header. I don't know what solution eda-server has for this problem, or if they have a solution (for a AwxToken for example). The full serialization is incompatible with a create serializer that excludes read-only fields. |
Not like this. I think it needs more? Here's an excerpt from how
So I guess we need three schemas? I'm sorry I really can't comment on the actual implementation of EDA API, you'll have to consult @Dostonbek1 or anyone else from @ansible/eda-maintainers |
@AlanCoding I think we can merge this as a stepping stone and take the discussion about the serializers upstream? What do you think? |
The approach we have for EDA is that we manually define two different serializers for both request and response on all POST endpoints, this helps us be more explicit on what the expected fields are. The following is an example for Project create endpoint:
|
That's not possible to put in DAB (RBAC generally is a stand-alone app and doesn't have drf-spectacular, and neither does AWX). I can try to look into apply the decorator to the role definition viewset inside of eda-server. I worry this borderlines on monkey patching, not sure yet. |
I looked at the implementation in And this is a hard sell for DAB. It needs both The best solution I could come up in DAB with would be to set a flag on Otherwise you could re-implement the URL and view and add a bunch of stuff onto it. This would be completely eda-server specific work. I'm somewhat near my limit to contribute here. |
20d125f
to
8c6a746
Compare
c624517
to
cc7cca3
Compare
I looked at this some more last night, some final notes so that someone else may be able to do the work. I considered both:
My conclusion was that both of these steps are necessary to complete the ask here, and that they are probably viable. The decorator seems to set properties on the view method. Assuming this is all it does (an assumption), no real monkey patching should be necessary. Just import the concrete viewset (and serializers) and apply the decoration. The custom view parent is necessary so that not just the schema is correct but the behavior is too, like with the response serializer. It might make sense to split the related permission logic out of |
8c6a746
to
5d4c600
Compare
Move to a new PR, since the methods changed so dramatically. |
…tency" (#249) Reverts #233 Because of requirements beyond the anticipated, this solution has become non-viable to do in DAB to solve the full problem. The plan is articulated in ansible/eda-server#775, which is that `ANSIBLE_BASE_CUSTOM_VIEW_PARENT` will be used to make an eda-server-standard base, which will copy this code, and combine with other existing patterns in the code base. EDIT: that plan is not implemented in ansible/eda-server#801
Link upstream ansible/django-ansible-base#233
Because we're on DAB devel, I can't update the pyproject.toml just yet. After upstream merges, we can update that and have it take effect.