This page documents how to customize the name of models, operations, and parameters. For an overview of the setup, please visit the setup page.
Default behaviors
By default, any language code generator will assume the TYPESPEC name is the client. For clarity, generators do not attempt to do any auto-magic rename.
NOTE: While names are not transformed, they will be adapted to what is idiomatic of the language (Python snake_case, etc.).
csharp, javascript, python, java means you target this specific language
Language target takes priority over client target.
NOTE: As model name do not get serialized as JSON, sometimes the best choice is to rename the main TYPESPEC for clarity. Talk to your emitter contact is you’re unsure
if you should rename the model in the main TYPESPEC or customize it.
You cannot at this moment rename parameters in the client.tsp file. You will need to add the @clientName decorator over the parameter directly, example:
Implementation
Order of Operations
For consistency when generating code, the order in which overrides are applied is important. Code emitters should apply overrides in the following order.
Over-the-Wire JSON Names
For determining the final name of a TypeSpec entity when sent over-the-wire in JSON:
If the @encodedName decorator exists, use this value
Use the original name in the spec
Client SDK Names
For determining the final name of a TypeSpec entity when used in a client SDK (e.g. Python):
Check if there’s a scoped @clientName decorator for your emitter
Check if there’s a @clientName decorator at all
Check the friendly name
Use the original name in the spec
Note: If the object name is from @clientName decorator, do not apply your language’s casing rules on it. If it’s not, apply your language’s heuristics (i.e. for Python, apply snake casing)