turner-townsend / flask-pydantic-spec

An Flask OpenAPI library using Pydantic
Apache License 2.0
98 stars 17 forks source link

Fix exception being thrown when JSON header is present but body is empty #51

Closed TheForgottened closed 1 year ago

TheForgottened commented 1 year ago

There's a small edge case where, if the "Content-Type: application/json" header is present and the body is empty (e.g. some GET request with leftover headers), request_validation will throw an exception.

I believe this is not expected behavior as this does not happen in other clients and libraries AFAIK.

Along with the changes I added some tests to check this edge case. I believe they are in the right place, but to be honest I had a hard time understanding how the tests were organized.

cgearing commented 1 year ago

Looks good to me! I'll get the merged and released. Thanks for fixing it!