openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

feat: Add two generation config flags to raise exceptions

Open robertschweizer opened this issue 2 years ago • 1 comments

raise_on_error_status raises a httpx.HTTPStatusError on all error response codes without decoding. This can later be improved to add an exception that includes the decoded content, or to even raise different exception types for each response code (see https://github.com/openapi-generators/openapi-python-client/pull/736#issuecomment-1493038758).

raise_on_unexpected_status is identical to the existing Client.raise_on_unexpected_status runtime setting, but leads to better return type annotations.

Closes https://github.com/openapi-generators/openapi-python-client/issues/491

This is a rework of https://github.com/openapi-generators/openapi-python-client/pull/736, with the main intention of reducing the generated sync and asyncio functions' return type annotations to documented successful responses.

Includes the commits from #742, which should be merged first.

robertschweizer avatar Apr 01 '23 16:04 robertschweizer

Codecov Report

Attention: Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.

Project coverage is 99.89%. Comparing base (4e0912f) to head (4e213e6). Report is 230 commits behind head on main.

Files with missing lines Patch % Lines
openapi_python_client/parser/openapi.py 92.30% 1 Missing :warning:
openapi_python_client/parser/responses.py 85.71% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##              main     #744      +/-   ##
===========================================
- Coverage   100.00%   99.89%   -0.11%     
===========================================
  Files           49       49              
  Lines         1978     1993      +15     
===========================================
+ Hits          1978     1991      +13     
- Misses           0        2       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 01 '23 17:04 codecov[bot]