[Pulp-dev] serializers in pulp 3 can't use write_only fields

Dennis Kliban dkliban at redhat.com
Fri Apr 24 15:22:52 UTC 2020

Today during open floor we concluded that write_only fields cannot be used
in serializers because any automated handling of them during OpenAPI schema
generation will cause mutations to the schema which will result in
backwards incompatible changes to our bindings users.

This change should only affect the Content serializers that have a 'file'
and 'repository' write_only fields that can be used for uploading content
into a repository in a single request. Two solutions were proposed:

1) Use a single serializer for GET and POST and leave 'file' and
'repository' null for GET requests. This solution is the simplest for
plugin writers because they don't have to do anything extra. However, it
does cause users to wonder why those fields are present and null on GET

2) Require plugin writers to provide 2 serializers for Content - one for
GET and another for POST. This is more work for plugin writers, but will
make it clear to users what fields are expected in each case.

Even though I initially proposed 1, I am in favor of adopting 2. What does
everyone else think?

We will need to provide validation at startup that will check serializers
for presence of write_only fields. The application should fail to start if
any are present. This way plugin writers will know not to use the fields.
We will also need to provide plugin writer docs that clearly state the
guidelines around write_only fields and suggestions for getting by without
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pulp-dev/attachments/20200424/8534db4b/attachment.htm>

More information about the Pulp-dev mailing list