-
-
Notifications
You must be signed in to change notification settings - Fork 779
WIP: redo validation by content type #760
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
Changes from 1 commit
53b74f6
452db0d
bfa477b
a95e987
062de8b
5a028ee
2494326
fd89862
171cbb3
0023799
bfbb519
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |||||
| from ..exceptions import ExtraParameterProblem, BadRequestProblem, UnsupportedMediaTypeProblem | ||||||
| from ..http_facts import FORM_CONTENT_TYPES | ||||||
| from ..json_schema import Draft4RequestValidator, Draft4ResponseValidator | ||||||
| from ..serialization.deserializers import DEFAULT_DESERIALIZERS | ||||||
| from ..content_types import KNOWN_CONTENT_TYPES | ||||||
| from ..types import TypeValidationError, coerce_type | ||||||
| from ..utils import all_json, boolean, is_json_mimetype, is_null, is_nullable | ||||||
|
|
||||||
|
|
@@ -56,7 +56,7 @@ def __init__(self, schema, consumes, api, is_null_value_valid=False, validator=N | |||||
| de(self.validator, | ||||||
| self.schema, | ||||||
| self.strict_validation, | ||||||
| self.is_null_value_valid) for de in DEFAULT_DESERIALIZERS | ||||||
| self.is_null_value_valid) for de in KNOWN_CONTENT_TYPES | ||||||
|
||||||
| self.is_null_value_valid) for de in KNOWN_CONTENT_TYPES | |
| self.is_null_value_valid) for de in ContentHandler.__subclasses__() |
that way all you have to do to register a new one is subclass ContentHandler and make sure to import your ContentHandler subclass before initializing Connexion (or more accurately before whatever point it is that creates the RequestBodyValidator).
Actually, I think I would turn this into a classmethod on ContentHandler so that it can look for grandchildren not just children classes as described here: https://stackoverflow.com/a/3862957
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.
Oh. I see register_content_handler below for registering additional content types. I would still like to see a way to replace default content handlers.
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.
TIL!
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.
Couldn't we just do
logging.getLogger(__name__)here (and everywhere else)? That's what I do in my other projects and it prevents pointless work when refactoring.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.
yeah, I think I was planning to stick to repo convention for now, and then doing a single PR to fix them all. Happy to do it incrementally though.