FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: handle non-IANA HTTP status codes without crashing by adeev-mardia · Pull Request #1471 · openapi-generators/openapi-python-client · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .jinja  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _get_kwargs(
{% if endpoint.path_parameters %}
"url": "{{ endpoint.path }}".format(
{%- for parameter in endpoint.path_parameters -%}
{{parameter.python_name}}=quote(str({{parameter.python_name}}), safe=""),
{{parameter.python_name}}=\quote(str({{parameter.python_name}}), safe=\"\"),
{%- endfor -%}
),
{% else %}
Expand Down Expand Up @@ -99,8 +99,12 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res


def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[{{ return_string }}]:
try:
status_code = HTTPStatus(response.status_code)
except ValueError:
status_code = response.status_code
return Response(
status_code=HTTPStatus(response.status_code),
status_code=status_code,
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
Expand Down
2 changes: 1 addition & 1 deletion openapi_python_client/templates/types.py.jinja
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ T = TypeVar("T")
class Response(Generic[T]):
""" A response from an endpoint """

status_code: HTTPStatus
status_code: HTTPStatus | int
content: bytes
headers: MutableMapping[str, str]
parsed: T | None
Expand Down

Back | FazBrowse Home | New Git URL