Open OptimeeringBigya opened 3 months ago
Python script is failing with the following exception:
pydantic_core._pydantic_core.ValidationError: 1 validation error for post_post
1
Input should be a valid dictionary or instance of Data [type=model_type, input_value=[Data(anyof_schema_1_vali...irectionalPrediction'})], input_type=list]
For further information visit https://errors.pydantic.dev/2.7/v/model_type
Did some digging myself.
Seems like the kwargs need to be passed into the init as actual_instance
https://github.com/OpenAPITools/openapi-generator/blob/0f294a51297d788630c96a146a9a48d1dae3e3e5/modules/openapi-generator/src/main/resources/python/model_anyof.mustache#L54
like how it is done in
https://github.com/OpenAPITools/openapi-generator/blob/0f294a51297d788630c96a146a9a48d1dae3e3e5/modules/openapi-generator/src/main/resources/python/model_anyof.mustache#L52
Bug Report Checklist
Description
Attempting to post data using python client results in a error when the data structure for the data in OpenAPI spec contains combination of complex structure and anyof data type.
openapi-generator version
7.6.0
OpenAPI declaration file content or url
https://gist.github.com/OptimeeringBigya/7130bdeb5ed6cdc474ee2d3c5897c1b4
Generation Details
java -jar openapi-generator-cli.jar generate \ --input-spec ./test_openapi_json.json \ --generator-name python \ --output ./test_python_client
Steps to reproduce
data = [ { "prediction_for": "2024-06-25T09:33:46.556Z", "value": 0.1 }, { "prediction_for": "2024-06-25T09:33:46.556Z", "values": {"0.1": 0.1} }, { "prediction_for": "2024-06-25T09:33:46.556Z", "values": {"N": 0.1} } ] a = [Data.from_dict(i) for i in data] print(a[0].to_dict()) print(a[1].to_dict()) print(a[2].to_dict()) response = DefaultApi().post_post(a) print(response)