sdk-generator
sdk-generator copied to clipboard
Ensure AdditionalHeaders used in all .NET client requests
Summary
- forward options.AdditionalHeaders when ReadLatestAuthorizationModel calls ReadAuthorizationModels
- propagate AdditionalHeaders to recursive Write calls in non-transaction mode
- test that chunked Write and ReadLatestAuthorizationModel preserve caller headers
Testing
make test-client-dotnet(fails: docker: not found)
https://chatgpt.com/codex/tasks/task_e_689fa592cf3c8322b9199b3278cdc560
Summary by CodeRabbit
-
New Features
- .NET client now supports per-request custom HTTP headers across all operations (read, write, list, expand, check, batch check). Headers propagate through nested operations and parallelized writes, enabling consistent context (e.g., correlation IDs) per call. Backward compatibility and cancellation token behavior are preserved.
-
Documentation
- Added examples showing how to supply AdditionalHeaders in request options.
-
Tests
- Expanded test coverage to verify header forwarding across key operations, including latest authorization model retrieval and write/check paths.
Walkthrough
Adds per-request header support to the .NET client templates by introducing AdditionalHeaders across request option models, updating API method signatures to accept headers, propagating them through Client -> API -> ApiClient -> HTTP layers, and extending tests and README examples to verify and demonstrate header forwarding.
Changes
| Cohort / File(s) | Summary |
|---|---|
Client header propagationconfig/clients/dotnet/template/Client/Client.mustache |
Forwards options?.AdditionalHeaders to all underlying API calls; ensures nested write operations carry headers; minor local refactors (storeId caching). |
Request options interfaceconfig/clients/dotnet/template/Client/Model/ClientRequestOptions.mustache |
Adds AdditionalHeaders to the ClientRequestOptions interface. |
Option models (read/write/check/list/expand/changes/assertions)config/clients/dotnet/template/Client/Model/ClientBatchCheckOptions.mustache, .../ClientCheckOptions.mustache, .../ClientCreateStoreOptions.mustache, .../ClientExpandOptions.mustache, .../ClientListObjectsOptions.mustache, .../ClientListRelationsOptions.mustache, .../ClientListStoresOptions.mustache, .../ClientListUsersOptions.mustache, .../ClientReadAssertionsOptions.mustache, .../ClientReadAuthorizaionModelOptions.mustache, .../ClientReadAuthorizaionModelsOptions.mustache, .../ClientReadChangesOptions.mustache, .../ClientReadOptions.mustache, .../ClientWriteAssertionsOptions.mustache, .../ClientWriteOptions.mustache |
Adds public AdditionalHeaders: Dictionary<string,string>? to concrete option classes; adds System.Collections.Generic usings. |
API client transportconfig/clients/dotnet/template/Client_ApiClient.mustache |
SendRequestAsync overloads gain IDictionary<string,string>? headers parameter; headers merged into outgoing request. |
Generated API methodsconfig/clients/dotnet/template/api.mustache |
All operation methods accept IDictionary<string,string>? additionalHeaders (before CancellationToken) and pass them to ApiClient.SendRequestAsync; adds System.Collections.Generic using. |
Testsconfig/clients/dotnet/template/OpenFgaClientTests.mustache |
Extends tests to assert header forwarding; adds ReadLatestAuthorizationModelHeadersTest; uses System.Linq for assertions. |
README exampleconfig/clients/dotnet/template/README_calling_api.mustache |
Demonstrates setting AdditionalHeaders on ClientCheckOptions. |
Sequence Diagram(s)
sequenceDiagram
participant Caller
participant Client
participant API
participant ApiClient
participant HttpClient
Caller->>Client: Call Operation(options with AdditionalHeaders)
Client->>API: Operation(..., additionalHeaders, ct)
API->>ApiClient: SendRequestAsync(builder, additionalHeaders, "operationId", ct)
ApiClient->>HttpClient: HTTP request with merged headers
HttpClient-->>ApiClient: Response
ApiClient-->>API: Result
API-->>Client: Result
Client-->>Caller: Result
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Suggested reviewers
- evansims
[!TIP]
🔌 Remote MCP (Model Context Protocol) integration is now available!
Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.
✨ Finishing Touches
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
codex/update-api-methods-to-accept-options-class
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.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.