openapi-format
openapi-format copied to clipboard
inverseFlags/inverseFlagValues do not keep referenced schemas
Version 1.25.0 Hello, I am recreating #152 as it turns out it is not an issue with multiple files, but even within 1 file. I was able to simplify the schema down to the bare minimum.
I've uploaded my examples to a git repo: https://github.com/tomasbreffitt/openapi-format-examples/tree/main
In each directory, inverseFlags and inverseFlagValues, I ran the following commands, output is included in my repo.
openapi-format oas.yaml -o output/filtered.yaml -f filter.yaml
openapi-format oas.yaml -o output/unfiltered.yaml
In my repo, you can see that in both cases, the filtered version does not keep the components.
As in my previous issue, I used both x-public: true in the inverseFlags and x-visibility: true in the inverseFlagValues commands.
I pasted both oas.yaml files to https://editor-next.swagger.io/ to test validity. I also ran them through rdme's validator as a sanity check and they passed.
As before, I am happy to assist in anyway, despite my lacking JS skills and I really appreciate the work on this tool, regardless, it still brings lots of value to me.
hih @tomasbreffitt
Thanks for taking the time to create the reproduce cases. I'll use that verify which logic gets triggered and what could be the cause of the reported behaviour.
I'll keep you posted when I have found the time to run some experiments.
hi @tomasbreffitt
Great that you shared your examples, I'll use to debug the reported case. It looks that the inverseFlag methods are being very ruthless when it comes to filtering out.
I'll have to find a way to make it keep referenced components.
hi @tomasbreffitt
I just released openapi-format v1.26.0 which includes the changes to makes the inverseFlag & inverseFlagValues less aggressive.
The inverse filtering keeps only the path operations, tags, x-tagGroups that match the filter rule. This was a very aggressive option to keep only the items that are needed, but now it will keep the components. The components can best be filtered out, by using the inverse filters in combination with the "unusedComponents" filter option.
BEFORE:
AFTER
BEFORE
AFTER
@tomasbreffitt
You can validate your playground, which now should behave as you expect:
If it works as expected, feel free to close this issue. If not report back, so we can continue our investigation.
@thim81 awesome! This seems to work perfectly. It does not strip unused schemas by default, but the unusedComponents filter works perfectly for that