Skip to content

invalid-encode-for-collection-format

Id
@azure-tools/typespec-client-generator-core/invalid-encode-for-collection-format

Severity: warning

This diagnostic is issued when an array parameter uses @encode with an array encoding other than ArrayEncoding.pipeDelimited or ArrayEncoding.spaceDelimited for collection format.

  • Area: Collection parameter serialization metadata. Generation continues with the fallback collection format when an unsupported array encoding is used.
  • Not affected: Non-array parameters and the declared parameter location are unchanged.
@service
namespace My.Service;
op myOp(@header @encode("tsv") header: string[]): void; // `tsv` is not a supported collection encoding

TCGC reports:

Only encode of `ArrayEncoding.pipeDelimited` and `ArrayEncoding.spaceDelimited` is supported for collection format.

Use ArrayEncoding.pipeDelimited, use ArrayEncoding.spaceDelimited, rely on the default CSV format, or use exploded query serialization.

@service
namespace My.Service;
op myOp(@header @encode(ArrayEncoding.pipeDelimited) header: string[]): void;

This diagnostic should not be suppressed. Fix the @encode usage to a supported collection-format encoding.