feat: support RegExp patterns in exclude.paths#326
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Summary
This PR introduces support for Regular Expressions in the
exclude.pathsconfiguration. Previously, the plugin only supported exact string matches, making it difficult to exclude large sets of routes or dynamic path segments.🛠️ The Problem
When managing large APIs, users often need to exclude entire modules, versions, or internal tools (e.g., all
/v1or/internalroutes) from the OpenAPI documentation.Using the current implementation:
✨ The Solution
I have updated the
toOpenAPISchemalogic to handle both strings andRegExpobjects within theexclude.pathsarray.RegExpinstances.path is RegExp) to ensure explicit narrowing and type safety when testing patterns..test(route.path).📝 Technical Changes
src/openapi.ts:ignorePatternswith explicitRegExp[]typing..filter()call to correctly narrow types.pattern.test(route.path)logic inside the route mapping loop.📖 Example Usage
Now you can easily exclude all routes starting with a specific prefix: