[BUG] [Java] oneOf inception provides wrong output in toJson
Description
to json functions gives the wrong output
openapi-generator version
7.5.0 -> no library defined
OpenAPI declaration file content or url
The following Yaml
pt:
type: object
additionalProperties:
nullable: true
oneOf:
- $ref: "#/components/schemas/mv"
- $ref: "#/components/schemas/pi"
- type: array
items:
oneOf:
- $ref: "#/components/schemas/mv"
- $ref: "#/components/schemas/pi"
mv:
oneOf:
- $ref: "#/components/schemas/sv"
- type: array
items:
$ref: "#/components/schemas/sv"
sv:
oneOf:
- type: number
format: double
- type: string
pi:
type: object
properties:
value:
$ref: "#/components/schemas/mv"
additionalProperties:
$ref: "#/components/schemas/pt"
With the following Java
Pi pi = new Pi().value(new Mv(new Sv(1d)));
pi.putAdditionalProperty("key", new Pi().value(new Mv(new Sv(0d))));
pi.toJson();
log.debug("{}", pi.toJson());
gives:
{"value":{"instance":1.0,"isNullable":false,"schemaType":"oneOf"},"key":{"value":{"instance":0.0,"isNullable":false,"schemaType":"oneOf"}}}
Where i would expect
{"value": 1.0,"key":{"value": 0.0}}
please give it a try with the latest master as we recently merged a fix
snapshot version can be found in project's readme
Same output on 7.6.0-SNAPSHOT :(
Many scenarios with oneOf and Arrays work, but this specific scenario fails for me. But i managed to make a smaller example. It happens already with a oneOf in a oneOf
myModel:
type: object
properties:
value:
oneOf:
- oneOf:
- type: number
format: double
- type: number
format: float
- type: string
log.debug("{}", new MyModel().value(new MyModelValue(new MyModelValueOneOf(10d)).toJson()));
looks like such use case is not yet supported at the moment.
would you have time to contribute a PR to support this use case? I can show you some good starting points.
That would be fun to give a try.