Closed mamatsunami closed 9 months ago
Thanks @mamatsunami for your contribution, much appreciated.
@thim81 Just realizing there is other case where it should be nice to prevent the removal of empty objects. I've seen you didn't yet create a release from my commit.
I was thinking to rework my current --keepEmptySchema
option to make it generic. I think it should be more flexible to rename it --keepEmptyObjects
. --keepEmptyObjects
would skip the removal of all empty object, but you could also pass an array of property to only prevent the removal of empty object in some cases, for instance --keepEmptyObjects=examples,schema
.
Can you wait I submit another PR before publishing a new version ?
That would be a more generic approach, so looking forward for you PR.
Could you also check that the new --keepEmptyObjects
is also supported through the --configFile
option?
Since it offers more options that just a simple boolean, so it would be handy to define this in the JSON config file that can be passed along.
@thim81 here it is ! https://github.com/thim81/openapi-format/pull/85 (I changed a bit my approach)
Context
When filtering a OpenAPI spec, openapi-format automatically remove empty objects. I had some issues with the openapi-generator because it doesn't handle empty request body.
I wanted to format a OpenAPI spec generated by Symfony API Platform which had some empty schema response object like this :
It was converting them to this :
Which causes a
java.lang.RuntimeException: Request body cannot be null
with openapi-generator when I try to generate an API client from the filtered spec file.Solution
I added a
--keepEmptySchema
parameter which disable the removal of empty schema object as a workaround.