Skip to content

Instantly share code, notes, and snippets.

@weidongxu-microsoft
Last active August 29, 2024 09:08
Show Gist options
  • Save weidongxu-microsoft/bf9c543dfcb387de6a661045b5e52b07 to your computer and use it in GitHub Desktop.
Save weidongxu-microsoft/bf9c543dfcb387de6a661045b5e52b07 to your computer and use it in GitHub Desktop.
Follow-up about grouping operations

Follow up on https://gist.github.com/weidongxu-microsoft/fa420c35cf0611a62a8d155771dd3425

With @armRenameListByOperation solved, we can put multiple List operation into same Interface.

Group operations in "route.tsp"

TypeSpec dev advises against this approach.

Group operations in "client.tsp"

By @client and @operationGroup to re-define the client hierarchy

Currently there is an issue on @singleton resource that blocks this approach.

Solution could be (according to Mark)

  • Enhance the utility of @armProviderNamespace so that it can be applied to namespace in "cient.tsp".
  • Add a decorator with similar functionality in TCGC.

Issue aside, there is major disadvantage of re-defining the client hierarchy in "client.tsp".

  • "client.tsp" could be large. For example, in this client.tsp for vmware, it took around 150 lines.
  • Service need to modify "client.tsp", for every new Interface added.

By existing @operationId decorator in typespec-openai

I take most dev does not want to use it.

By some new decorator in TCGC (without re-define the client hierarchy)

Candidate be:

  • @operationGroupName(target: Interface, name: str, scope: str) (we may extend the target to Operation, if we really need this kind of granularity) to override the operation group name for an Interface.
    TCGC would need to take it into account, when handling clients and operation groups.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment