Open mvanassche opened 1 year ago
can you please try the latest master? we recently merged a PR to better handle oneOf in java
client generator.
@wing328 currently using latest version 7.0.1 in Java 11 and I get un-usable code when there is oneOf
in the spec.
For instance something like this schema
Parent:
type: object
properties:
content:
nullable: true
oneOf:
- type: string
- type: array
items:
$ref: "#/components/schemas/MyObject"
minItems: 1
MyObject:
oneOf:
- $ref: "#/components/schemas/Object1"
- $ref: "#/components/schemas/Object2"
x-oaiExpandable: true
Object1:
type: object
properties:
...
Object2:
type: object
properties:
...
Will generate this invalid Java code
public List<MyObject> getList<MyObject>() throws ClassCastException {
return (List<MyObject>)super.getActualInstance();
}
Description
The generator generates unusable java code for complex expressions. For example, take a oneOf that is either a string or some complex object. The result is a an interface, which does not allow to read/write all possible values.
openapi-generator version
6.6.0
OpenAPI declaration file content or url
Suggest a fix
Shouldn't it fallback on an Object or Object Map instead of generating something incorrect?