Azure / typespec-azure

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

[Bug]: [ARM][SDK] armRenameListByOperation decorator prevent client.tsp re-arrange the operation groups #1052

Open weidongxu-microsoft opened 2 weeks ago

weidongxu-microsoft commented 2 weeks ago

Describe the bug

SDK emitter (and TCGC) takes interface (interface with @client/@operationGroup in client.tsp takes precedence) to group the client and operation groups.

@armRenameListByOperation decorator on ArmResourceListByParent operation template would rename the operation to pattern listBy<parent-resource-name>. This present SDK putting 2 or more ArmResourceListByParent operation (different resource, but same parent resource) to a single operation groups. See https://gist.github.com/weidongxu-microsoft/fa420c35cf0611a62a8d155771dd3425#known-approach-to-group-operations

For brownfield service, SDK would need to keep the operation group structure, to avoid breaking changes.

One solution would be to remove the @armRenameListByOperation decorator from ArmResourceListByParent operation template. But this leaves one question: what can we do to guide (particularly greenfield) service dev on operation name. E.g. it would be welcome that the operation name being consistent for new services, e.g. listByResourceGroup or listByTenant.

If we remove the decorator, breakdown could be

  1. rename all existing operation to the expected name of @armRenameListByOperation (so that operation name would be same, regardless of the existence of @armRenameListByOperation)
  2. remove @armRenameListByOperation from ArmResourceListByParent operation template
  3. [optional] find another way to guide service on the List operation name

Reproduction

playground

Checklist

weidongxu-microsoft commented 1 week ago

@allenjzhang

Let me know if we follow this breakdown. And if I can help you to do 1st item on the renames on existing operations.