Skip to content

no-format

Id
@azure-tools/typespec-azure-core/no-format

Azure services should not use the @format decorator.

Using the @format decorator is disallowed. While in OpenAPI format: was used to both represent a known string format and a more precise type, in TypeSpec @format is only meant to represent a known pattern for a string. This means that using @format would result in a string type with some validation.

  • Area: API, SDK

@format may specify an invalid or non-standard format.

FormatType
int32int32
uriurl
urlurl
uuidAzure.Core.uuid
eTagAzure.Core.eTag
arm-idAzure.Core.armResourceIdentifier
ipv4Azure.Core.ipV4Address
ipv6Azure.Core.ipV6Address
ipv6Azure.Core.azureLocation
model Pet {
@format("uuid")
id: string;
}
model Pet {
id: Azure.Core.uuid;
}

Suppression is acceptable when a valid format is used. Prefer standard types (which apply the correct wire format automatically), or @encode when a non-standard format such as base64url is required.