Skip to content

Conversation

@pzhang65
Copy link
Contributor

@pzhang65 pzhang65 commented Aug 29, 2021

Fixes #111

Relevant changes from webargs 5.x to 8.1:

  • multiple locations are no longer supported in a single call, default location is json.
  • allow use of unknown parameters on schemas.
  • unknown is also settable by parser.*
  • ValidationError messages are namespaced under the request location.

Changes to aiohttp-apispec:

  • Bump webargs >= 8.0.1**
  • Change all locations args to to location.
  • Drop location kwargs backwards compatibility.
  • Change all decorators schemas to use string for location instead of array.
  • Add unit tests for unknown field validation.
  • Update old tests to conform to new ValidationError messages.
  • Fix test_register_route_for_relative_url().***

*Recommended TODO item to add ability to set an unknown behavior override for validation middleware. Just need to inject another argument to request body i.e., schema['unknown'] for parser to override unknown behavior defined in marshmallow schema.
**Since bumping webargs to >= 8.0.1 drops marshmallow 2 support, we should also consider bumping apispec to >=4.
***test_register_route_for_relative_url() was passing locally but failing in the pipeline. Upon closer inspection it looks like the assertion was incorrect. Adding url arg to setup should register a route so the routes_count_after_setup_apispec should not equal to routes_count before setup. Indeed after relevant fixes the test function is now passing both locally and should pass in CICD pipeline.

…ix test_register_route_for_relative_url function
@maximdanilchenko maximdanilchenko merged commit 9d0cdc7 into maximdanilchenko:master Aug 30, 2021
@lafrech
Copy link

lafrech commented Aug 30, 2021

Since bumping webargs to >= 8.0.1 drops marshmallow 2 support, we should also consider bumping apispec to >=4.

webargs / apispec maintainer, here.

When publishing a major webargs/apispec version, we generally drop support for the old one right away. But the migration is generally painless. webargs was an exception to this and I think we maintained 5.x for a little while.

Anyway, my point is go ahead and drop every non latest major version of webargs/apispec anytime. The former versions are unmaintained and it shouldn't bother anyone.

@maximdanilchenko
Copy link
Owner

@lafrech, thanks for the recommendation! I will drop all non latest versions of webargs and apispec soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Webargs 6.0+] Validation middleware does not support unknown field behavior specified with a Marshmallow 3 schema

3 participants