get-operation-name
@azure-tools/typespec-client-generator-core/get-operation-nameGET SDK method names should use ‘Get’ or ‘List’ as the verb prefix.
GET operations generate SDK methods whose names should clearly communicate whether they retrieve one
resource or list several resources. Use get or list in TypeSpec so the generated SDK method name
starts with Get or List.
Changing a method name after publishing an SDK can be a breaking change.
Impact
Section titled “Impact”- Area: SDK generation. A GET operation without
GetorListis less discoverable and does not clearly communicate whether it returns one resource or a collection. - Compatibility: Renaming a generated method after an SDK has shipped can break existing client code.
Examples
Section titled “Examples”Incorrect
Section titled “Incorrect”@route("/widgets/{name}")@getop fetchWidget(@path name: string): Widget;Correct
Section titled “Correct”@route("/widgets/{name}")@getop getWidget(@path name: string): Widget;List operations may start with list.
@route("/widgets")@getop listWidgets(): Widget[];Suppression
Section titled “Suppression”Suppress this warning only when the SDK method has already shipped and renaming it would be a breaking change. Document the compatibility reason in the suppression:
#suppress "@azure-tools/typespec-client-generator-core/get-operation-name" "Preserve the shipped SDK method name."@route("/widgets/{name}")@getop fetchWidget(@path name: string): Widget;LintDiff Equivalent
Section titled “LintDiff Equivalent”This rule corresponds to the Azure OpenAPI Validator
GetInOperationName (R1005).