Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Python] Support timezone in datetime #6433

Closed
3 of 6 tasks
jirikuncar opened this issue May 26, 2020 · 0 comments · Fixed by #6458
Closed
3 of 6 tasks

[BUG] [Python] Support timezone in datetime #6433

jirikuncar opened this issue May 26, 2020 · 0 comments · Fixed by #6458

Comments

@jirikuncar
Copy link
Contributor

jirikuncar commented May 26, 2020

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

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java#L215-L219

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants