feat: add support for @clientOption("includeRootSlash") in C# emitter#9934
feat: add support for @clientOption("includeRootSlash") in C# emitter#9934
Conversation
Add support for @clientoption("includeRootSlash") in the http-client-csharp emitter. When set to false, strips the leading '/' from operation paths. Supports client-level, sub-client-level, and operation-level configuration, with child elements able to override parent settings. Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
packages/http-client-csharp/emitter/src/lib/operation-converter.ts
Outdated
Show resolved
Hide resolved
packages/http-client-csharp/emitter/src/lib/operation-converter.ts
Outdated
Show resolved
Hide resolved
| client?: SdkClientType, | ||
| ): boolean { | ||
| // First check the method/operation level | ||
| const methodOption = getClientOptions(method, "includeRootSlash"); |
There was a problem hiding this comment.
@copilot lets create a new internal type ClientOptions that will have the const strings / config of the supported options by the emitter.
There was a problem hiding this comment.
Done in a0aab22. Created emitter/src/type/client-options.ts with a ClientOptions const object that centralizes the supported option name strings (includeRootSlash, collectionHeaderPrefix). Updated all getClientOptions() call sites to use these constants.
| it("should allow operation to override client includeRootSlash option", async () => { | ||
| const program = await typeSpecCompile( | ||
| ` | ||
| #suppress "@azure-tools/typespec-client-generator-core/client-option" "test" |
There was a problem hiding this comment.
@copilot lets add a new test that has multiple subclients and each subclient has multiple operations each with different clientOption values
There was a problem hiding this comment.
Added in a0aab22. New test "should handle multiple sub-clients with different includeRootSlash values per operation" covers three sub-clients (BlobClient, ContainerClient, DefaultClient) each with multiple operations using different clientOption values, verifying client-level inheritance and per-operation overrides.
- Remove duplicate SdkClientType alias from operation-converter.ts (use SdkClientType<SdkHttpOperation> directly) - Make slash removal more explicit: check first character instead of regex - Create ClientOptions type with const strings for supported option names - Add comprehensive test with multiple sub-clients and mixed per-operation values Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
commit: |
|
@copilot run |
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
includeRootSlashclient option support to C# emitterSdkClientType<SdkHttpOperation>parameter tofromSdkServiceMethodand related functionsresolveIncludeRootSlashhelper function that checks operation first, then walks up client hierarchy/fromoperation.pathwhenincludeRootSlashisfalse(explicit first-char check)client-converter.tstooperation-converter.tsClientOptionsinternal type with const strings for supported option namesincludeRootSlashoption (interface with option strips slash)Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.