apischema icon indicating copy to clipboard operation
apischema copied to clipboard

Allow alias where object field is expected

Open wyfo opened this issue 2 years ago • 0 comments

Several features of apischema requires an object field to be passed, e.g. field ordering, field validator, or object serialization.

Fields can be either:

  • an apischema ObjectField
  • a dataclass Field
  • the field name as string

But it could be convenient to also use the field alias instead. For example, if object serialization is built dynamically from aliases passed in request parameters, it would avoid having to do the reverse mapping.

On the other hand, reverse mapping would be quite easy, so it's not really an issue (things gets more complicated when it comes to serialized methods). Also, allowing field names and aliases at the same could bring some edge cases with both overlapping, but IMO this kind of thing should not happen in real life.

wyfo avatar Nov 02 '21 22:11 wyfo