Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tcgc] add overrideClientMethod decorator #1054

Closed
4 tasks done
iscai-msft opened this issue Jun 21, 2024 · 3 comments · Fixed by #1148
Closed
4 tasks done

[tcgc] add overrideClientMethod decorator #1054

iscai-msft opened this issue Jun 21, 2024 · 3 comments · Fixed by #1148
Assignees
Labels
feature New feature or request lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@iscai-msft
Copy link
Contributor

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

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For feature request in the typespec language or core libraries file it in the TypeSpec repo
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@iscai-msft iscai-msft added feature New feature or request lib:tcgc Issues for @azure-tools/typespec-client-generator-core library labels Jun 21, 2024
@iscai-msft iscai-msft self-assigned this Jun 21, 2024
@weidongxu-microsoft
Copy link
Member

link a design discussion for options bag #831
currently the mapping of model properties could be a challenge.

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Jul 12, 2024

A few questions:

  1. Do we discard the serviceOperation design? It is kind of opposite to this design @serviceOperation(serviceOp) clientOp where here @overrideClientMethod(clientOp) serviceOp

  2. Should we recommend dev to use ref to property (Timothee kind of recommend this)? E.g.

model Params = {
  foo: MyService.myOperationModel.foo;
  bar: MyService.myOperationModel.bar;
}

@iscai-msft
Copy link
Contributor Author

iscai-msft commented Jul 16, 2024

  1. We pretty much do. We make sure that the two operations result in the same exact service operation, then just use the overridden client method.
  2. Yeah that's a good idea, this way we more clearly map things from the service to the client

github-merge-queue bot pushed a commit that referenced this issue Aug 6, 2024
fixes #1054

---------

Co-authored-by: iscai-msft <isabellavcai@gmail.com>
Co-authored-by: Srikanta <51379715+srnagar@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants