Open LGLC opened 6 years ago
I wrote a fix for this and was about to create a pull request, when I realised that it may already be fixed on the github repo. I'll check this tomorrow to confirm. If so, is there any chance you could update the version on npm?
is it fixed?
Firstly, thanks for such a useful library! One issue I am having, though, is that the generated models are always wrapping any referenced objects in arrays (despite them not being listed as arrays in the swagger spec).
As an example, here is part of my swagger spec:
An Article contains an Image (not an array of Images). An Image itself is just an object. Yet if I look within the DB, I can see that the image field has been created as an array of Objects. You can see this in the JSON output below:
It's worth noting that there are some cases where there genuinely are arrays of objects, like the
mainContent
definition in swagger.I had a little look and assumed it was the
NOT circular reference
part ofprocessRef
(that wraps the output in an array) that was causing the issue, but couldn't quite tweak it to get it working. Simply removing those brackets didn't work, nor did checking if they needed the array.What I'm having to do at the moment is loop through the returned objects and re-flatten the properties correctly before they're turned into JSON, which obviously is a hacky way of doing it! Any help to avoid this would be much appreciated.
Thanks!