sdrangel
sdrangel copied to clipboard
Swagger code gen incorrect for arrays of integer
It seems the swagger code generation for arrays of integers is incorrect.
As an example (but there are others), in VORLocalizer.yaml, we have:
columnIndexes:
type: array
items:
type: integer
When getting feature settings through the Swagger webpage, the array returned is always empty:
"columnIndexes": [],
This can be fixed by changing the generated code SWGVorLocalizerSettings.cpp from:
toJsonArray((QList<void*>*)column_indexes, obj, "columnIndexes", "");
To:
toJsonArray((QList<void*>*)column_indexes, obj, "columnIndexes", "qint32");
But this fix obviously needs to be done in the generator.
(Arrays of strings work ok - they have the last parameter set to "QString")
I notice many other examples of arrays in the yaml files actually uses arrays of structures with a single number/integer element - was that a workaround to this, perhaps? That works, but obviously a little less efficient.
Looking at the code gen, it sort of looks like this template is used to generate the code:
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache
But the code isn't exactly the same, so I'm not quite sure.
That template has:
toJsonArray((QList<void*>*){{name}}, obj, "{{baseName}}", "{{complexType}}");
Which suggests the complexType parameter isn't being set to qint32.
Looks like an upstream bug (https://github.com/swagger-api) with swagger-codegen, as I see the same problem using that.
Have added: https://github.com/swagger-api/swagger-codegen/issues/12256