known-encoding
@azure-tools/typespec-azure-core/known-encodingCheck for supported encodings.
Check that @encode uses a supported encoding for Azure services.
Known supported encodings:
| Target type | Supported encodings |
|---|---|
utcDateTime / offsetDateTime | rfc3339, rfc7231, unixTimestamp |
duration | ISO8601, seconds |
bytes | base64, base64url |
Impact
Section titled “Impact”- Area: API, SDK
Non-standard formats are transmitted as the raw, unencoded wire type, which hurts API and SDK usability.
LintDiff Equivalent
Section titled “LintDiff Equivalent”This rule corresponds to the LintDiff rule ValidFormats.
❌ Incorrect
Section titled “❌ Incorrect”Unknown encoding on a model property:
model Foo { @encode("custom-rfc") myDateTime: utcDateTime;}Unknown encoding on a scalar:
@encode("custom-rfc")scalar myDateTime extends utcDateTime;✅ Correct
Section titled “✅ Correct”Known encoding on a model property:
model Foo { @encode("rfc3339") myDateTime: utcDateTime;}Known encoding on a scalar:
@encode("rfc3339")scalar myDateTime extends utcDateTime;Suppression
Section titled “Suppression”Suppress only when required to match an existing API; otherwise use a standard format, encoding, or type.