Azure / typespec-azure

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

[Bug]: Auto-calcluated path for `StandardResourceOperations.ResourceAction` is different when having operation renaming in client.tsp #1021

Closed MaryGao closed 3 months ago

MaryGao commented 3 months ago

Describe the bug

This is case in LoadTesting(spec here) and found in JS codegen(here). The auto-calculated route is different after adding customization in client.tsp.

playground

Reproduction

playground The http path should be the same no matter we have client.tsp or not.

Checklist

markcowl commented 3 months ago

This is by design, as if you don't apply an @action decorator, the final path of the action will match the name of the operation. Although, arguably, this would be a good candidate for a linter warning

qiaozha commented 3 months ago

@markcowl I think the root cause for this issue is the keyword is has two different kind of meanings here. in the main.tsp, is is being used to define an operation, and in the client.tsp, is is being used to rename an operation. I feel like we should figure out a way to split the meaning here. Not sure we have any plan to redesign this ?

markcowl commented 3 months ago

@qiaozha It should not be the case that 'is' is being used just to rename operations. In this case, @clientName should be able to handle the issue. Generally, in the client.tsp, 'is' is used for two reasons:

In the case of POST actions, the issue is that the last segment of the operation path comes from the operation name, unless it is explicitly set using @action . If we had a linting rule that detected the change of operation path through use of 'is', then authors of client.tsp could be warned away from patterns that change the operation path.

markcowl commented 3 months ago

resolving as duplicate of https://github.com/Azure/typespec-azure/issues/297