Skip to content

friendly-name

Id
@azure-tools/typespec-azure-core/friendly-name

Ensures that @friendlyName is used as intended.

Ensures that @friendlyName is used as intended. The @friendlyName decorator should only be applied to template declarations and should reference template parameter properties in the friendly name string.

  • Area: API

@friendlyName is an unscoped way to rename a type for every emitter; it should be replaced by targeted client naming.

Using @friendlyName on a non-template type:

@friendlyName("FriendlyModel")
model TestModel {}
@friendlyName("FriendlyEnum")
enum TestEnum {
Foo,
Bar,
}

Using @friendlyName on a template without referencing template parameters:

@friendlyName("FriendlyUpdate")
op updateTemplate<T>(body: T): T;

Using @friendlyName on a template with template parameter references:

@friendlyName("{name}Page", T)
model Page<T> {
size: int32;
item: T[];
}
@friendlyName("List{name}", T)
op listTemplate<T>(): Page<T>;

Do not suppress. Use @clientName instead.