[BUG] ClassCastException for any client
Created by: karussell
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example) -> this website does not work. -
What's the version of OpenAPI Generator used? 4.1.1 -
Have you search for related issues/PRs? -
What's the actual output vs expected output? See below -
[Optional] Bounty to sponsor the fix (example)
Description
I tried to generate a java client for the openapi spec:
https://docs.graphhopper.com/openapi.yaml
But also other clients fail with the same exception. So maybe there is a problem with the spec but it should not fail with a ClassCastException IMO.
But I was able to create a Java client via pasting the spec into https://editor.swagger.io and so I assume the spec is roughly ok.
OpenAPI declaration file content or url
https://docs.graphhopper.com/openapi.yaml
Command line used for generation
java -jar openapi-generator-cli-4.1.1.jar generate -i https://docs.graphhopper.com/openapi.yaml -g java -o java
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: java (client)
[main] INFO o.o.codegen.DefaultGenerator - Generator 'java' is considered stable.
[main] INFO o.o.c.languages.AbstractJavaCodegen - Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try 'export JAVA_POST_PROCESS_FILE="/usr/local/bin/clang-format -i"' (Linux/Mac)
[main] INFO o.o.c.languages.AbstractJavaCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation getRoute
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation null
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation getIsochrone
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation getMatrix
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation postMatrix
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation calculateMatrix
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation getMatrixSolution
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation postGPX
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation getGeocode
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation solveVRP
[main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation getSolution
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: VehicleProfileId. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: VehicleProfileId. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: VehicleProfileId. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: VehicleProfileId. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: VehicleProfileId. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: VehicleProfileId. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: VehicleProfileId. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: VehicleProfileId. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - Unknown `format` int64 detected for type `number`. Defaulting to `number`
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: object. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: object. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: object. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: object. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: object. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: object. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: object. To fully utilize allOf, please use $ref instead of inline schema definition
[main] WARN o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: object. To fully utilize allOf, please use $ref instead of inline schema definition
Exception in thread "main" java.lang.RuntimeException: Could not process model 'Request'.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:400)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
Caused by: java.lang.ClassCastException: io.swagger.v3.oas.models.media.ObjectSchema cannot be cast to io.swagger.v3.oas.models.media.ArraySchema
at org.openapitools.codegen.languages.AbstractJavaCodegen.toDefaultValue(AbstractJavaCodegen.java:721)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:2058)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:2271)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3706)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3654)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1918)
at org.openapitools.codegen.languages.AbstractJavaCodegen.fromModel(AbstractJavaCodegen.java:942)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1198)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:465)
... 3 more