Closed a-waider closed 1 year ago
So, I found the location responsible for removing empty objects: openapi-format.js#L443. When commenting out, it works as intended.
What are the reasons to remove empty objects? Can we just delete lines 440 to 444 in openapi-format.js?
@a-waider This was there to clean up empty structures as a result of filtering.
If you would filter a certain number of properties or endpoints, it could be that there were empty parent elements, and that is what this removes.
Could you explain why you want to keep the empty key: {}
? Just for my understanding of your use-case.
In my use case there is an example for a request body which contains a key with an empty map.
I have to think a bit more about this but potentially we could make the line440 more specific to skip it for request body elements
That would be awesome
Any news on this issue?
I just haven't found the time to pick this up.
hi @a-waider There is a fix ready #73 If the empty object is in a default example, it gets skipped from being deleted. Would that solve your case?
hi @a-waider
I improved the logic to delete empty objects, like you suggested and released a new version 1.13.1 of openapi-format. Let me know, if it behaves as you expect.
Thanks for you effort. The new version solves this issue :)
I've experienced that empty objects in the yaml gets stripped away. An example for a request body in openapi with an epmty object gets stripped away.
E.g.
becomes
Is this related to the parsing library used in openapi-format? Do you have any suggestions how to preserve the empty object?