[BUG] [Python] Support timezone in datetime
Created by: jirikuncar
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
The parser fails on date time with timezone information.
openapi-generator version
master
OpenAPI declaration file content or url
type: string
example: '2020-02-02T02:02:02.00000Z'
format: date-time
# or
type: string
example: '2020-02-02T02:02:02.00000+02:00'
format: date-time
Command line used for generation
STDERR:
Exception in thread "main" java.lang.RuntimeException: Could not process model 'XXX_time'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:496)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1015)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:431)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
Caused by: java.lang.ClassCastException: java.time.OffsetDateTime cannot be cast to java.util.Date
at org.openapitools.codegen.languages.PythonClientExperimentalCodegen.toDefaultValue(PythonClientExperimentalCodegen.java:238)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:2898)
at org.openapitools.codegen.languages.PythonClientExperimentalCodegen.fromProperty(PythonClientExperimentalCodegen.java:431)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:4601)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:4549)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:2402)
at org.openapitools.codegen.languages.PythonClientExperimentalCodegen.fromModel(PythonClientExperimentalCodegen.java:802)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1299)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:491)
... 4 more
Steps to reproduce
Related issues/PRs
Suggest a fix
Parse timezone from given string and use UTC as default.