OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Release : openapi-generator-cli.jar 7.8.0
OS : Windows server
In my OAS 2.0 file / I have the following property definition
expectedBeginDate:
type: string
format: date-time
Description
Server wants ISO8601 pattern "AAAA-MM-JJTHH:MM:SSZ"
In my python script, I set the property expectedBeginDate in an instance of object model generated by client generator with a string respecting the pattern above (iso8601).
But when I call the to_json() method on the generated model
I get "TypeError: Object of type datetime is not JSON serializable".
However I use in command line of openapi-generator-cli.jar the configuration option datetimeFormat
as defined in https://openapi-generator.tech/docs/generators/python/
=> additional-properties=datetimeFormat='%Y-%m-%dT%H:%M:%SZ'".
Release : openapi-generator-cli.jar 7.8.0 OS : Windows server
In my OAS 2.0 file / I have the following property definition
Description
Server wants ISO8601 pattern "AAAA-MM-JJTHH:MM:SSZ"
In my python script, I set the property expectedBeginDate in an instance of object model generated by client generator with a string respecting the pattern above (iso8601).
But when I call the to_json() method on the generated model I get "TypeError: Object of type datetime is not JSON serializable".
However I use in command line of openapi-generator-cli.jar the configuration option datetimeFormat as defined in https://openapi-generator.tech/docs/generators/python/ => additional-properties=datetimeFormat='%Y-%m-%dT%H:%M:%SZ'".
Syntax get from issue : 18292 https://github.com/OpenAPITools/openapi-generator/issues/18292
I thought that the option datetimeformat would provide a string in JSON for expectedBeginDate property.
Is it a bug or is it by design ?
Workaround used : "expectedBeginDate": { "type": "string", "format": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },