Open yasserzamani opened 2 years ago
The issue still exists in openapi-generator 6.2.x (java client generator with library: okhttp-gson, native, jersey)
components:
schemas:
ReturnValue:
oneOf:
- type: string
- $ref: '#/components/schemas/ReturnValueArray'
ReturnValueArray:
type: array
items:
type: string
Issue-1: missing import java.util.List
Issue-2: use List<{DATA_TYPE}>
as a class name, such as
deserialized = tree.traverse(jp.getCodec()).readValueAs(List<String>.class);
I am thinking the simple solution is to generate the model class of ReturnValueArray
.
Anyone is working on this issue?
@wing328 do you have any concern or suggestion? Many thanks
Still broken in 7.5.0
Switching to jersey3
for the library
property fixed it for me (I was using native
before). But should still be fixed I'd say, especially in the default library.
Bug Report Checklist
Description
When oneOf refs to an array type, then the generated code is not compilable.
java.util.List
isn't imported and other compile time errors emerge.openapi-generator version
6.0.1 maven plugin. I don't know if it's a regression as I've never had same situation with previous versions.
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
mvn compile
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/8765 https://github.com/OpenAPITools/openapi-generator/issues/6015 https://github.com/OpenAPITools/openapi-generator/issues/5997
Suggest a fix
The generated code semantically is fine in human POV. Likely a bit change in compiler will make it syntactically fine too.