Open tom300z opened 1 month ago
I am unable to access response headers that share the same name.
7.7.0
Irrelevant as the issue lies in the python client itself.
I was able to work around this by overriding the templates locally and adding the following 2 lines.
diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index c7d4a6d700f..dc9c9057cf9 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -335,6 +335,7 @@ class ApiClient: status_code = response_data.status, data = return_data, headers = response_data.getheaders(), + full_headers = tuple(response_data.getheaders().items()), raw_data = response_data.data ) diff --git a/modules/openapi-generator/src/main/resources/python/api_response.mustache b/modules/openapi-generator/src/main/resources/python/api_response.mustache index 9bc7c11f6b9..136a745cb69 100644 --- a/modules/openapi-generator/src/main/resources/python/api_response.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_response.mustache @@ -13,6 +13,7 @@ class ApiResponse(BaseModel, Generic[T]): status_code: StrictInt = Field(description="HTTP status code") headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + full_headers: tuple[tuple[str, str], ...] = Field(None, description="Full HTTP headers") data: T = Field(description="Deserialized data given the data type") raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
@tom300z what about running tuple(api_response.headers.items()) using the existing headers field? would that meet your requirement?
tuple(api_response.headers.items())
headers
Yes, that should work too
Bug Report Checklist
Description
I am unable to access response headers that share the same name.
openapi-generator version
7.7.0
OpenAPI declaration file content or url
Irrelevant as the issue lies in the python client itself.
Steps to reproduce
Suggest a fix
I was able to work around this by overriding the templates locally and adding the following 2 lines.