Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
8 stars 29 forks source link

[tcgc] add `overrideClientMethod` decorator #1054

Open iscai-msft opened 2 weeks ago

iscai-msft commented 2 weeks ago

Clear and concise description of the problem

We want the ability in client.tsp to override a generated client method. When we switch to ... always meaning spread, we will also need the ability to generate options bags for languages that prefer options bags. Adding a decorator like overrideClientMethod will allow authors to clearly state their preferred signature for specific language(s). This will also allow patched customizations without having to craft an entire client to modify one operation

// main.tsp
namespace MyService;

model Params = {
  foo: string;
  bar: string;
}

op myOperation(...Params): void;

// client.tsp
namespace MyCustomizations;

op myOperationCustomization(@bodyRoot params: Params): void;

@@overrideClientMethod(MyService.myOperation, MyCustomizations.myOperationCustomization);

Checklist

weidongxu-microsoft commented 2 weeks ago

link a design discussion for options bag https://github.com/Azure/typespec-azure/issues/831 currently the mapping of model properties could be a challenge.