fix: make anonymous security alternatives optional - #3959
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR adds type-level handling for anonymous security alternatives in OAS security params, and updates a fixture and test to exercise the unauthenticated security path. ChangesAnonymous Security Type Resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/fets/src/client/types.tsOops! Something went wrong! :( ESLint: 10.6.0 TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///.eslintrc.json?mtime=1783029430903" needs an import attribute of "type: json" 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 |
| const data = await res.json(); | ||
| console.info(`User ${data.id}: ${data.name}`); | ||
|
|
||
| await client['/me'].get(); |
There was a problem hiding this comment.
Is it possible to create a seperate isolated file as a reproduction instead of modifying the existing ones?
There was a problem hiding this comment.
Pull request overview
This PR updates the TypeScript client type generation so that OpenAPI operations with an explicit anonymous security alternative (security: [{} , ...]) no longer require auth parameters, while also extending the existing API key fixture to cover this case.
Changes:
- Add detection for empty (anonymous) security requirement objects in
securityarrays and make the derived auth params optional for those operations. - Extend the API key header OpenAPI fixture to include an anonymous security alternative.
- Add a client call in the API key type test to validate that
/mecan be invoked without auth params when anonymous access is allowed.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/fets/src/client/types.ts | Adds HasAnonymousSecurityAlternative and wraps derived security params in DeepPartial when an empty security requirement is present. |
| packages/fets/tests/client/fixtures/example-apiKey-header-oas.ts | Updates fixture security to include {} as an anonymous alternative. |
| packages/fets/tests/client/apiKey-test.ts | Adds a call to /me without params to ensure optional-security typing is accepted. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Validation