-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Feature: Filtering of endpoints and tags #132
Feature: Filtering of endpoints and tags #132
Conversation
Codecov Report
@@ Coverage Diff @@
## main #132 +/- ##
==========================================
+ Coverage 98.29% 98.44% +0.15%
==========================================
Files 32 34 +2
Lines 997 1094 +97
==========================================
+ Hits 980 1077 +97
Misses 6 6
Partials 11 11
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
return new RefitGenerator(settings, document); | ||
} | ||
|
||
private static void ProcessTagFilters(OpenApiDocument document, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this approach. It seems so much more simple to just trim the OpenAPI document down instead of checking every single endpoint upon generation
The changes here looks good to me. Shall we merge this in @kirides? Or do you have pending changes? |
I would still have to check if the source generator works and maybe clean up the filtering mechanisms. Also need to take a look at poco generation, maybe there's room for improvement (remove unneeded schema from document after filtering it) |
Thanks for thinking about that @kirides
It might be dangerous to tamper with the contracts. We need to make sure that the contract types that we skip generating are not referenced by other contract types |
@christianhelle after evaluating my consideration about trimming contracts, i came to the conclusion that there is no way to get it right, due to the spec allowing for additional schema and things like "any object" as result or parameters. if the code looks good for you, and the checks are green we can merge it :) |
This PR demonstrates how #131 could be implemented
It add
--match-path
and--tag
CLI options, which allow the user to filter endpoints based on existing Tags and/or if the Path matches an regular expression.It's not as fine grained as for supporting HTTP methods. I.e. you can't filter for
^/greet
and only allowGET
andPUT
or something like that.A call might look like this:
refitter.exe swagger.json --tag Greeting --tag OpenApi --match-path '^/api/'
It works by modifying the OpenApiDocument and removing the Paths/Methods that don't match any of the Tags or patterns, thus further steps in code generation only see the filtered document.