unioslo / harborapi

Python async client for the Harbor REST API v2.0.
https://unioslo.github.io/harborapi/
MIT License
27 stars 5 forks source link

Exclude unset fields when serializing #12

Closed pederhan closed 1 year ago

pederhan commented 1 year ago

When an endpoint method takes a model where optional fields are not set, the method should avoid including the field altogether in the JSON request body. There might be a semantic difference between excluding a field and including it, but having its value be null. In order to not make assumptions about this difference, this pull request makes it so unset fields are excluded when sending requests.

Until all harborapi's endpoint methods have been thoroughly tested with a live Harbor instance, all this is just conjecture, but for now it seems like a reasonable assumption, hence proceeding with this change.

Tests

Most POST/PUT tests did not expect that fields could be omitted, and they have been changed accordingly.