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
{{ message }}
Repository navigation
[BUG][Java][okhttp-gson] Cannot serialize oneOf array of strings #25541
Have you provided a full/minimal spec to reproduce the issue?
Have you validated the input using an OpenAPI validator?
Have you tested with the latest master to confirm the issue still exists?
Have you searched for related issues/PRs?
What's the actual output vs expected output?
Description
The Java okhttp-gson client throws IllegalStateException: Not a JSON Primitive: ["alpha","beta"] when serializing a oneOf value containing an array of strings. The expected result is the JSON array ["alpha","beta"].
openapi-generator version
Reproduced on master 57edb417ea3fb15de7bc523a133c9cc016acab19 (7.28.0-SNAPSHOT).
The deserialization succeeds but serialization throws IllegalStateException: Not a JSON Primitive. A separate pre-existing limitation causes empty arrays to be rejected by setActualInstance; the reproduction above uses a nonempty array.
Related issues/PRs
#25539 also concerns Java Gson oneOf generation, but this issue reproduces on master without that PR.
Suggest a fix
In the generated Gson adapter, write array-valued primitive schemas as JsonArray instead of converting them to JsonPrimitive.
Activity