advance transform attribute to access full field metadata#176
Conversation
|
📖 Documentation Preview: https://reflectapi-docs-preview-pr-176.partly.workers.dev Updated automatically from commit 617ee79 |
| /// In Rust this is `reflectapi::Option<String>` (populated by middleware), | ||
| /// but clients see it as a required `Option<String>` (nullable, not omittable). |
There was a problem hiding this comment.
Subtle difference based on reflectapi::Option vs std::Option. As a developer I'd typically expect make_required to do the same regardless of what Option variant it's on - would be a bit of a footgun imo.
There was a problem hiding this comment.
making std option required means removing Undefined and None variants for the non-nullable field.
making reflectapi required means removing Undefined variant, as None is expected possible null value.
the difference is on purpose as the semantics of both types required.
however, the client can provide their own transform functions.
There was a problem hiding this comment.
If I use a function called make_required on something named Option I would expect the generated client to disallow all None-alike values (None, null, etc).
There was a problem hiding this comment.
I think we need to rename something here to make this clearer
There was a problem hiding this comment.
Do you know that from reflectapi (and our API standard) required is not equal to not-nullable? These are two distinct things. It is possible to have non-required but nullable and required but nullable and 2 other combos. So the transform function does exactly that: it removes the declaration for the field to be required, which is for non nullable field means no None of the standard Option and for nullable field it means no Undefined of the reflectapi Option.
There was a problem hiding this comment.
we can add make_nonnullable, and super set of both make_required_and_nonnullable
There was a problem hiding this comment.
I would be happy with this outcome, will mark as approved.
|
@JosiahBull what change are you requesting to make? |
…lable functions, and clarify documentation
No description provided.