openapi-filter icon indicating copy to clipboard operation
openapi-filter copied to clipboard

Feature - additional filter options: operationIds & method

Open thim81 opened this issue 3 years ago • 14 comments

  • Filter by OperationIds
  • Filter by method

As mentioned https://github.com/Mermade/openapi-filter/issues/70, I have added 2 options:

  • to filter by "method" (GET/POST/PUT/DELETE/....) which will remove all operations under any path that matches
  • to filter by "operationId" (operationId: addPet/ operationId: updatePet / ...) which will remove the specific operations under that matches the defined operationId

thim81 avatar Jan 09 '21 22:01 thim81

@MikeRalphson

I'm doing something wrong with the tests, but not sure how to correct it. If I do a local diff the input & output show the result as expected.

thim81 avatar Jan 09 '21 22:01 thim81

Question:

When combining it with the "inverse":true it removes really everything except the "paths" with the "method".

Example

"methods": ["post"],
  "inverse": true

How can I limit the "inverse" to the "path" level?

thim81 avatar Jan 09 '21 23:01 thim81

How can I limit the "inverse" to the "path" level?

The original intent of the --inverse option was to see exactly what would be filtered / omitted. Over time, for people who want a kind of reverse filtering, the --valid option was added - this may be what you need in combination.

MikeRalphson avatar Jan 10 '21 07:01 MikeRalphson

Not sure, I fully understand how I can delete the obj[key] via the state.parent?

Since in the recursion, that obj has already passed by?

thim81 avatar Jan 10 '21 09:01 thim81

state.parent always holds the parent object (i.e. the one which has obj in it) identified by state.pkey which is the "parent key". So you can delete during the recursion, or hold references and delete afterwards if need be.

MikeRalphson avatar Jan 10 '21 09:01 MikeRalphson

@MikeRalphson Let me know if you have more remarks or comments, that I can implement. I think it is good to go.

thim81 avatar Jan 23 '21 08:01 thim81

hey @thim81 @MikeRalphson , hope you are doing great, any updates on this feature, would be a great addition to the package. how can I help?

yjose avatar May 12 '21 23:05 yjose

@yjose I think that everything is ready. I cant see the change request that was asked, which seems more a Github issue on my end. I'm using this PR since Jan 2021 and I haven't ran into any issues.

thim81 avatar May 13 '21 08:05 thim81

Thanks for the prod - I will test locally and check there's nothing outstanding before merging.

MikeRalphson avatar May 13 '21 09:05 MikeRalphson

by the way, i tried to filter opertionIds using using the following config :

let options = {
  flags: ['operationId'],
  flagValues: operations, // array of strings 
  inverse: true,
  strip: true,
  valid: true,
  info: true,
}; 

and look like its working but with missed parameters for paths with global parameters like /path-example/{id}/

yjose avatar May 13 '21 17:05 yjose

and look like its working but with missed parameters for paths with global parameters like /path-example/{id}/

@yjose could you create a failing testcase to show what is currently happening and what the output should be?

MikeRalphson avatar May 14 '21 01:05 MikeRalphson

@MikeRalphson #93

yjose avatar May 15 '21 00:05 yjose

I'm very interested in this feature. I'm not clear what if anything is holding up the approval and merge now?

mattadamson avatar Sep 27 '23 09:09 mattadamson

@mattadamson Since then, I have created a separate NPM package which supports the filtering => https://www.npmjs.com/package/openapi-format

thim81 avatar Sep 27 '23 10:09 thim81