Remora / Remora.Rest

Reusable tooling for interacting with JSON-driven REST APIs
GNU Lesser General Public License v3.0
7 stars 10 forks source link

Object-aware OneOfConverter #8

Closed carlst99 closed 2 years ago

carlst99 commented 2 years ago

The current OneOfConverter fails to process JSON object tokens. It attempts to deserialize every union member type, and if a type succeeds this is considered to be the correct value. Because member types are deserializing without error in some cases, despite not matching the shape of the provided JSON, the converter is returning an incorrect value.

This PR attempts to resolve this using the following logic:

It's not a particularly efficient mechanism. As far as I can tell the limitations on the Utf8JsonReader prevent peeking forward to look at the shape, which is why I've chosen this route. Very open to suggestions.

carlst99 commented 2 years ago

Scratch that - this is showing errors in live testing. Closing till I resolve