Bug Report Checklist
Code that handles empty arrays
Description
I'm using the openapi-generator-maven-plugin with default settings (uses okhttp-gson) to produce a java client from an openapi.json file.. I've noticed that oneof declarations, relying on type discrimination AND having array types, leads to problems with empty arrays. It's the
...which will lead to index-out-of-bounds exceptions on empty arrays. Through debugging I've pinned the problem to this file:
https://github.com/OpenAPITools/openapi-generator/blob/6ee94d636b7a7e06b74faf4423b175a7271d5343/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache
Looks to me like it can never work for empty arrays? And I see no other way, than sending an empty array to signal that an instance of that particular oneof variant was sent - as this is information too. IMO you shouldn't need to do special handling on the producer to make the consumer happy for this basic case.
Other than that I more than happy with your framework. I feed a 2k line openapi spec into it and it's been working great this far.
openapi-generator version
7.12.0
OpenAPI declaration file content or url
From #/component/schemas
"ComponentF_unit_PlainOrAOU_Char": {
"oneOf": [
{
"$ref": "#/components/schemas/FormF_PlainOrAOU_Char"
},
{
"items": {
"$ref": "#/components/schemas/FormF_PlainOrAOU_Char"
},
"type": "array"
}
],
"type": "object"
},
Generation Details
java + maven with default settings
Steps to reproduce
Create a oneof that that has 2 elements. On scalar type and one array of same scalar type. serialize and empty array using the array-type alternative
Related issues/PRs
couldn't find any
Suggest a fix
Either only do type checking on non empty arrays or get rid of the type checking all together.
Bug Report Checklist
Code that handles empty arrays
Description
I'm using the openapi-generator-maven-plugin with default settings (uses okhttp-gson) to produce a java client from an openapi.json file.. I've noticed that
oneofdeclarations, relying on type discrimination AND having array types, leads to problems with empty arrays. It's the...which will lead to index-out-of-bounds exceptions on empty arrays. Through debugging I've pinned the problem to this file:
https://github.com/OpenAPITools/openapi-generator/blob/6ee94d636b7a7e06b74faf4423b175a7271d5343/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache
Looks to me like it can never work for empty arrays? And I see no other way, than sending an empty array to signal that an instance of that particular oneof variant was sent - as this is information too. IMO you shouldn't need to do special handling on the producer to make the consumer happy for this basic case.
Other than that I more than happy with your framework. I feed a 2k line openapi spec into it and it's been working great this far.
openapi-generator version
7.12.0
OpenAPI declaration file content or url
From #/component/schemas
Generation Details
java + maven with default settings
Steps to reproduce
Create a oneof that that has 2 elements. On scalar type and one array of same scalar type. serialize and empty array using the array-type alternative
Related issues/PRs
couldn't find any
Suggest a fix
Either only do type checking on non empty arrays or get rid of the type checking all together.