[BUG][Python] Ranged response codes not working
Created by: Poolmann
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Ranged HTTP response codes are not recognized in deserialization of the response.
openapi-generator version
Version 6.3.0
OpenAPI declaration file content or url
With a response schema like:
paths:
/upload:
post:
tags: [upload]
operationId: postUpload
requestBody:
$ref: "#/components/requestBodies/UploadRequest"
responses:
"2XX":
$ref: "#/components/responses/UploadResponse"
"403":
$ref: "#/components/responses/UploadForbiddenError"
"413":
$ref: "#/components/responses/UploadRequestToLargeError"
"415":
$ref: "#/components/responses/UploadUnsupportedMediaError"
"429":
$ref: "#/components/responses/UploadTooManyRequestsError"
# General responses
"400":
$ref: "#/components/responses/BadRequestError"
"401":
$ref: "#/components/responses/UnauthorizedError"
"500":
$ref: "#/components/responses/InternalServerError"
"503":
$ref: "#/components/responses/ServiceUnavailableError"
Generation Details
java -jar openapi-generator-cli-6.3.0.jar generate -i openapi.yaml -g python
Steps to reproduce
- Use ranged response codes in the specification
- skip_deserialization should be
False
(also default)
Expected Result: Deserialized response body
Actual Result: <devaice_web_api_client.schemas.Unset object at 0x7fdf7fe177f0>
These are the relevant code snippets regarding the deserialization:
if skip_deserialization:
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
else:
response_for_status = _status_code_to_response.get(str(response.status))
if response_for_status:
api_response = response_for_status.deserialize(response, self.api_client.configuration)
else:
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
and
_status_code_to_response = {
'403': _response_for_403,
'413': _response_for_413,
'415': _response_for_415,
'429': _response_for_429,
'400': _response_for_400,
'401': _response_for_401,
'500': _response_for_500,
'503': _response_for_503,
'2XX': _response_for_2XX,
}
So the response code '200' is not recognized => response_for_status is None
and I don't get a deserialized response.