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] ClassCastException: class java.util.Date cannot be cast to class java.lang.String #6694

Closed
5 of 6 tasks
orenyomtov opened this issue Jun 17, 2020 · 3 comments
Closed
5 of 6 tasks

Comments

@orenyomtov
Copy link

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? 4.3.1
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

The following property generates an error when trying to generate a python client

"properties": {
                    "dueDate": {
                        "format": "date",
                        "default": "2016-01-30",
                        "type": "string"
                    }
                }
Exception in thread "main" java.lang.RuntimeException: Could not process model 'mySchema'.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:1005)
	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: class java.util.Date cannot be cast to class java.lang.String (java.util.Date and java.lang.String are in module java.base of loader 'bootstrap')
	at org.openapitools.codegen.languages.PythonClientCodegen.toExampleValueRecursive(PythonClientCodegen.java:724)
	at org.openapitools.codegen.languages.PythonClientCodegen.toExampleValue(PythonClientCodegen.java:703)
	at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:2846)
	at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:4534)
	at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:4482)
	at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:2378)
	at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1289)
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:491)
	... 4 more
openapi-generator version

4.3.1

OpenAPI declaration file content or url
{
    "openapi": "3.0.0",
    "info": {
        "version": "1.0.0",
        "title": "Issue Reproduction",
        "license": {
            "name": "MIT"
        }
    },
    "paths": {},
    "components": {
        "schemas": {
            "mySchema": {
                "type": "object",
                "properties": {
                    "dueDate": {
                        "format": "date",
                        "default": "2016-01-30",
                        "type": "string"
                    }
                }
            }
        }
    }
}
Command line used for generation

openapi-generator generate -g python -o /tmp/error/ -i ./error.json

Steps to reproduce

Save the above json file as error.json, and run the command line

Related issues/PRs

#1312
#2907

Suggest a fix

🤷🏻‍♂️

@auto-labeler
Copy link

auto-labeler bot commented Jun 17, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@wing328
Copy link
Member

wing328 commented Jun 17, 2020

I think the issue has been resolved in the latest master. Can you please give it a try?

@orenyomtov
Copy link
Author

Thanks, yes it had been solved!

Works great on the :latest docker image.

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

No branches or pull requests

2 participants