Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filtering unused components - not working #107

Open
connorsadler opened this issue Apr 19, 2024 · 5 comments
Open

filtering unused components - not working #107

connorsadler opened this issue Apr 19, 2024 · 5 comments
Assignees
Labels
awaiting feedback bug Something isn't working

Comments

@connorsadler
Copy link

Hi,

I am trying to filter a yaml openapi spec, to remove a path and remove unused schema components.
The path filtering works fine, but the unused component removal does not work - unless I deliberately add an unused component to the original file (I did this by accident while experimenting)

Please see attached zip file for sample files and README.md with steps to reproduce issue
I will also copy in README.md below

There is always the possibility that I am doing something wrong - apologies if that is the case here.

Thanks,

Connor

Mac OS
openapi-format version: tried with 1.14.0 and 1.17.0 - same results

PROBLEM: The 'remove unused components' doesn't work - it leaves some items in there that it shouldn't

Steps to show problem:

  1. edit spec: pet-sample-openapi-spec.yaml
    observe it has 2 paths, each path references a response schema object which uses a second schema object
  2. filter the spec by running: ./dev-produce-filtered-spec.sh
    this uses "dev-produce-filtered-spec_customFilter.yaml" which only includes one of the paths (WORKS) but should removed unused "schemas" (DOESNT WORK)
  3. edit result: pet-sample-openapi-spec_filtered.yaml
    observe it includes only one path (correct), but all the schema objects are included - some of which are unused so should have been removed
  4. edit spec 2: pet-sample-openapi-spec-2.yaml
    observe it is the same as the first spec, but it has an unused component in schemas: ThisTypeIsNeverReferencedAnywhere
  5. filter the spec 2 by running: ./dev-produce-filtered-spec-2.sh
    Note: In the output it says it's removed some unused components
  6. edit result: pet-sample-openapi-spec_filtered-2.yaml
    observe the filtering has now worked - one path and all unused components have been removed

Archive.zip

@thim81
Copy link
Owner

thim81 commented Apr 25, 2024

hi @connorsadler

Thanks for providing the detailed reproduction steps.

When I find some time, I'll try to reproduce the behavior based on your archive.zip and steps.

I'll share update once we have them.

@thim81 thim81 self-assigned this Apr 25, 2024
@thim81 thim81 added the bug Something isn't working label Apr 25, 2024
@connorsadler
Copy link
Author

connorsadler commented Apr 25, 2024

Thanks
We can work around it for the moment by just including a dummy unused item in the original spec, which we are in control of

@thim81
Copy link
Owner

thim81 commented Jun 16, 2024

hi @connorsadler

Thanks to your clear reproduction steps and archive with your openapi files & config, I did some rework on the unused component tracking and removal logic.
This improved unused component handling is included in the openapi-format v1.20.0 release.

You can see the result of your provided example in the openapi-format playground

or use your npx openapi-format pet-sample-openapi-spec.yaml -o pet-sample-openapi-spec_filtered.yaml --no-sort --filterFile dev-produce-filtered-spec_customFilter.yaml --verbose

(if you want to open your local config in the online playground, just add --playground npx openapi-format pet-sample-openapi-spec.yaml -o pet-sample-openapi-spec_filtered.yaml --no-sort --filterFile dev-produce-filtered-spec_customFilter.yaml --verbose --playground)

@thim81
Copy link
Owner

thim81 commented Jun 16, 2024

After validation, feel free to provide your feedback.
If the issue is resolved, you can close this item.

@thim81
Copy link
Owner

thim81 commented Jun 28, 2024

hi @connorsadler

Did you have some time to try out the latest version? To see if your issue is resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants