You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run the generator with the above declaration file; it will throw an exception that looks like this:
Exception in thread "main" java.lang.RuntimeException: Could not process model 'MyModel'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:470)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:920)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:396)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
Caused by: java.lang.ClassCastException: java.util.UUID cannot be cast to java.lang.String
at org.openapitools.codegen.languages.PythonClientCodegen.toDefaultValue(PythonClientCodegen.java:643)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:1981)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3627)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3575)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1845)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1197)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:465)
... 3 more
If you remove the default and run the generator again, code generation will succeed.
Related issues/PRs
#2209 - similar exception, with a different cause.
Suggest a fix
Rather than just casting to a string, perhaps just calling p.getDefault().toString() would work.
The text was updated successfully, but these errors were encountered:
I second this. Trying to generate code for java. Models are being created but then it breaks with
Cause: class java.util.UUID cannot be cast to class java.lang.String (java.util.UUID and java.lang.String are in module java.base of loader 'bootstrap')
/edit: runs fine when I comment all the format: uuid lines
Bug Report Checklist
Description
If I define a schema that has a UUID property, and that property has a default value, the Python code generator throws a
ClassCastException
.openapi-generator version
4.0.3
OpenAPI declaration file content or url
Command line used for generation
docker run --rm -v ${PWD}:/local --env 'PYTHON_POST_PROCESS_FILE="/usr/local/bin/yapf -i"' openapitools/openapi-generator-cli:v4.0.3 generate -i /local/swagger.yml -g python -o /local/build
Steps to reproduce
Run the generator with the above declaration file; it will throw an exception that looks like this:
If you remove the default and run the generator again, code generation will succeed.
Related issues/PRs
#2209 - similar exception, with a different cause.
Suggest a fix
Rather than just casting to a string, perhaps just calling
p.getDefault().toString()
would work.The text was updated successfully, but these errors were encountered: