Cornices / cornice

Build Web Services with Pyramid.
https://cornice.readthedocs.io
Other
384 stars 149 forks source link

Schemas can't be classes since 4.0.0 #523

Closed abompard closed 4 years ago

abompard commented 4 years ago

After commit 40ed37a2f4 and the release of 4.0, all schema arguments need to be instances (because of the isinstance() call), while Cornice accepted classes before that. I don't think the "classes" behavior has been deprecated, but I may be wrong. I did this kind of change on all schema arguments and it stopped crashing:

@@ -186,7 +186,7 @@ def query_comments(request):
     )

-@comments.post(schema=schemas.SaveCommentSchema,
+@comments.post(schema=schemas.SaveCommentSchema(),
                renderer='json',
                error_handler=services.errors.json_handler,
                validators=(

It's not a big fix but it took some time chasing it down. A DeprecationWarning when schemas are classes instead of instances would have been appreciated.

leplatrem commented 4 years ago

You're right!

Will see if we can release 4.0.1 with a quick fix