OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
In Python SDK while converting response to dictionary, there is inconsistency in format of attribute names in dictionary. For the properties in response whose value is dictionary and derived from allof schema, the attributes name in value dictionary is not in snake case as defined in attribute maps, instead they are presented as they are received in response.
Generate Python SDK from the specified spec file and call any endpoint as shown below and try converting the response to dictionary using to_dict() as shown below in example.
from openapi_client.api import default_api
from openapi_client import api_client
import openapi_client
configuration = openapi_client.Configuration(
host = "http://127.0.0.1:3000"
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
try:
# returns electric car data with nested properties
api_response = api_instance.get_electric_car()
print(api_response.to_dict())
print(api_response.make.to_dict())
except openapi_client.ApiException as e:
print("Exception when calling DefaultApi->get_electric_car: %s\n" % e)
Actual Output of the above program is as shown below
In output the make property is derived from allof schema. hence the attributes name in value dictionary must be manufacturer_name instead of 'ManufacturerName' and similarly 'model_name' instead of 'ModelName'
Bug Report Checklist
Description
In Python SDK while converting response to dictionary, there is inconsistency in format of attribute names in dictionary. For the properties in response whose value is dictionary and derived from allof schema, the attributes name in value dictionary is not in snake case as defined in attribute maps, instead they are presented as they are received in response.
openapi-generator version
6.1.0
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Generate Python SDK from the specified spec file and call any endpoint as shown below and try converting the response to dictionary using to_dict() as shown below in example.
Actual Output of the above program is as shown below In output the make property is derived from allof schema. hence the attributes name in value dictionary must be
manufacturer_name
instead of 'ManufacturerName' and similarly 'model_name' instead of 'ModelName'Expected Output