-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Parser.pre_load
as an extension point
`Parser.pre_load` is a "do nothing" method out of the box, but lets users subclass and override with custom implementations for their needs. This resolves #234 by allowing a custom parser to strip whitespace -- or perform any other desirable action -- after location loading and before schema loading. By giving the pre_load method an interface which takes the schema and location, users can extend this in a myriad of ways. In an explicit nod towards #234, an example is provided which strips whitespace from certain locations. Furthermore, since satisfying this use case is the purpose of this PR, I've included a somewhat unusual test which copies the doc example code and ensures it does the right thing in a couple of basic scenarios. Defining this interface as a method for subclasses to override keeps the changes to `webargs` minimal (vs. supporting another hook with a decorator, like error handlers and location loaders).
- Loading branch information
Showing
4 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters