Add more tests for deserializing bytes values, and support bytes when deserializing application/x-www-form-urlencoded
I noticed that the deserializers for application/json and multipart/form-data both support bytes values, but the deserializer for application/x-www-form-urlencoded does not. So in this PR I'm adding that support. I'm also adding some tests to verify this functionality.
Note that the existing support for bytes values does not align with the documentation for the OpenAPIRequest dataclass:
@dataclass
class OpenAPIRequest:
"""
[...]
body
The request body, as string.
[...]
"""
# [...]
body: str
# [...]
I'm not sure if and how that should be changed, and what any other implications might be.
Merging this would fix an issue with pyramid_openapi3, where it is currently not possible to validate requests with application/x-www-form-urlencoded bodies. See this Github issue: https://github.com/Pylons/pyramid_openapi3/issues/167. Note that this is not the only way to fix this issue, but with what I've learned so far I think it's the best one.
Codecov Report
Merging #396 (7555547) into master (1627889) will increase coverage by
0.00%. The diff coverage is100.00%.
@@ Coverage Diff @@
## master #396 +/- ##
=======================================
Coverage 95.25% 95.25%
=======================================
Files 83 83
Lines 1874 1876 +2
Branches 280 281 +1
=======================================
+ Hits 1785 1787 +2
Misses 68 68
Partials 21 21
| Impacted Files | Coverage Δ | |
|---|---|---|
| openapi_core/deserializing/media_types/util.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 1627889...7555547. Read the comment docs.
bytes was supported because not strict type checking. With new version that shouldn't be the case with new Request protocol.
Can confirm that the new version fixes this. Thanks for your patience!