ynab-api icon indicating copy to clipboard operation
ynab-api copied to clipboard

Nullability issues

Open dmlerner opened this issue 4 years ago • 1 comments

The official swagger spec has various fields mark as required: False but nullable: False. Or something like that. Anyway, it seems to be working if I just mark everything nullable. (Where by everything, I mean a few types, across ~200 places, but probably there is more to do.) But, this will cause client side validation to not catch certain errors.

Required means "must be present on request." Nullable means "may be null on request". So, you can be any combination of nullable (or not) with required (or not).

TODO: mark as nulalble only the fields that are not marked required, or something else more sensible than "everything is nullable!"

This fix is on the "nullfix" branch, which can be installed with:

pip install git+https://github.com/dmlerner/ynab-api.git@nullfix

dmlerner avatar Nov 07 '21 18:11 dmlerner

I emailed with official YNAB support, who had some very helpful info:

We use the OpenAPI 2.0 spec format which only defines "required" and not "nullable". Our spec generally uses "required" to indicate a non-null value rather than the presence of a field in the response. Some language generators have issues with the "required" field and if we make tweaks to make one language work, we have issues with another. We hope to upgrade to OpenAPI 3.0 format to resolve these issues in the future. Until then, Brady, one of our developers, recommends some tweaks to the Python code generator (code mods or manually tweaking the spec before feeding it to the generator).

Some discussion from awhile back can be found on this public repo: https://github.com/ynab/ynab-sdk-js/pull/90.

dmlerner avatar Dec 11 '21 05:12 dmlerner