flask-smorest icon indicating copy to clipboard operation
flask-smorest copied to clipboard

Rework ETag: remove "ETag computed with API response data using another schema", allow decorating MethodView

Open lafrech opened this issue 3 years ago • 1 comments

This is an attempt to simplify the ETag feature.

The "compute ETag with API response data using another schema" case is a leftover from the past and I don't think it is relevant. Removing it reduces API surface, allows to simplify the code and makes the feature more understandable by the user.

Also, this change makes _generate_etag easier to override for users not happy with its implementation (see #393).

Finally, allow etag decorated to be applied to a whole MethodView at once (introducing _decorate_view_func_or_method_view that may be useful for #280 and #311).

There are still things I would like to improve in the ETag feature (like the fact that it is still not completely decoupled from the response decorator), but this iteration should be an improvement by itself.

lafrech avatar Aug 16 '22 22:08 lafrech

Codecov Report

Merging #394 (f396177) into master (e0a6bd8) will decrease coverage by 0.00%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
- Coverage   99.87%   99.87%   -0.01%     
==========================================
  Files          13       13              
  Lines         817      813       -4     
  Branches      178      176       -2     
==========================================
- Hits          816      812       -4     
  Partials        1        1              
Impacted Files Coverage Δ
flask_smorest/blueprint.py 100.00% <100.00%> (ø)
flask_smorest/etag.py 100.00% <100.00%> (ø)
flask_smorest/response.py 100.00% <100.00%> (ø)
flask_smorest/utils.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Aug 16 '22 22:08 codecov[bot]