-
Notifications
You must be signed in to change notification settings - Fork 152
reworking colander schema validation [WIP] #330
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
Conversation
|
BTW, don't bother looking at the diff's for the two files as they're pretty drastic changes and it's probably easier to just read the whole file... |
With this change, `default` values are effectively ignored in schemas. The schema would only have to take into account the `deserialize()` process.
|
As per the discussion on #329, I've updated this PR to not call colander's |
|
I'd like to hear back from someone with the ability to merge this PR before continuing work on it... I don't want to spend more time on it if it won't be used. |
cornice/schemas.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When looking at this: https://travis-ci.org/mozilla-services/cornice/jobs/76151945#L525 recursivity seems infinite!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. it seems I didn't properly test simple_cstruct_serialize(). It's because strings are iterable. I'll patch this.
|
This is perfect. I'm currently working on #285 swagger integration and it would make the whole process of generating a consistent swagger schema much easier. Ony one schema for ever The current validation process is too complicated a simple |
|
This would make it possible to use https://github.com/stefanofontanelli/ColanderAlchemy ;) |
|
Hey guys... I'm not really working on the project where I used cornice any more and other responsibilities have come up that make it even more unlikely that I'll be able to finish this. Hopefully someone else can pickup where I left off. |
|
See how we resolved this https://github.com/Cornices/cornice/blob/master/docs/source/upgrading.rst#colander-validation |
|
Nicely solved :) |
Okay, due to all the issues and comments surrounding colander validation I started working on a replacement. Basically a lot of things were being done in Cornice when they could have easily been left to Colander (like iterating over child elements). The schema.py file is now 62 lines where the old one was 180. The 4 main components (querystring, headers, body, and path) are grouped into one structure and passed through a single schema for validation tests. Each of those 4 components, if validated, are moved to
request.validated. Any errors are put inrequest.errors.This is obviously a huge change from the previous method, so I wanted to get some input before I complete all aspects of this PR (please ignore the failing tests for the moment).
I modified a few existing tests to kind of demonstrate how the system works on validating the body but obviously more are needed to test validating the other 3 types.
This deals with the following issues: #310, #211, #190, #327, #193, #249
Perhaps we could support #173 by calling unflatten in the validator.