-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returning more descriptive errors for invalid enum defaults #626
Comments
Thanks for the great analysis. Improved errors are a work in progress. |
Thanks for the response - I hadn't seen #579 when I posted this, and I realize after the fact that "make the errors better," let alone "provide an exact JSON path with every validation error," is a way bigger ask than one might think at first glance. I'm guessing the challenge is that It also doesn't seem like the original structure of the JSON document is explicitly preserved in memory anywhere by the time typify gets a hold of it: typify/typify-macro/src/lib.rs Lines 232 to 239 in da943a0
I assume this means you'd have to extend serde to run typify's validations during deserialization while the path to a given value in the document is still available. On the other hand, from what I understand JSON schemas can also be self-referential in a lot of ways, so I'd expect at least some validations to be impossible until the schema has been fully deserialized. I'd be interested in helping with a solution if you think it's a problem that would benefit from contribution, but I can definitely see why that might not be the case. This isn't blocking me from using progenitor for the purpose I had in mind though - so no worries if this is something that's just going to take time to figure out. |
When trying to generate a REST client crate from an OpenAPI spec, I ran into this error output from
progenitor
:After tracing the error to
typify
I realized the schema had some properties with invalid defaults. Here's a basic example:It was this match arm that ended up being the one for my case:
typify/typify-impl/src/defaults.rs
Lines 151 to 153 in d36f65e
This is a slightly cleaned up version of the change that gave me enough info to find the problem with my schema file:
Ideally the error message could just be a JSON path like mentioned here: #485 (comment). I assume that would require a more structural refactor, but I'd be interested in pushing errors like this in the intended direction either way.
The text was updated successfully, but these errors were encountered: