Skip to content

fix: Add non-JSON and empty error bodies handling#85

Open
ewuerger wants to merge 3 commits into
mainfrom
bugfix-nonJSON-error-handling
Open

fix: Add non-JSON and empty error bodies handling#85
ewuerger wants to merge 3 commits into
mainfrom
bugfix-nonJSON-error-handling

Conversation

@ewuerger

@ewuerger ewuerger commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Solve #84

Explanation why fix is done with regex in build_client.py (post-generation-fix):

Summary

  • Regex correctness: confirmed - produces identical output to the manual patch
  • Path correctness: confirmed - output_path / "api" resolves to api, the directory with all 220 files
  • Why regex is the right call here: you're correct that the template approach was ruled out. The Errors.from_dict(response.json()) line is assembled across three template files (endpoint_module.py.jinja → endpoint_macros.py.jinja → model_property.py.jinja → property_macros.py.jinja). The only hook point is parse_response in endpoint_macros.py.jinja, but overriding that requires duplicating the full upstream macro which includes unrelated body-parsing logic, and would silently break on any generator update. Post-processing in build_client.py is the established pattern there (it already does regex manipulation on the OpenAPI spec before generation) and the target string response_NNN = Errors.from_dict(response.json()) is 100% generator-stable - that exact form appears nowhere else and will always be produced by model_property.py.jinja.

@ewuerger ewuerger requested a review from micha91 April 24, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant