Skip to content

Support array encoding for string-based enum types#3686

Merged
JialinHuang803 merged 6 commits intoAzure:mainfrom
JialinHuang803:encode-enum-string
Jan 20, 2026
Merged

Support array encoding for string-based enum types#3686
JialinHuang803 merged 6 commits intoAzure:mainfrom
JialinHuang803:encode-enum-string

Conversation

@JialinHuang803
Copy link
Copy Markdown
Member

Support array encoding for string-based enum types.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for array encoding (CSV, pipe-delimited, space-delimited, newline-delimited) for string-based enum types in the TypeSpec TypeScript emitter. Previously, only plain string arrays supported collection format encoding.

Changes:

  • Added isStringEncodableArrayValueType() helper function to validate array value types that can use collection format encoding
  • Updated validation logic to accept both string types and string-based enum types for array encoding
  • Enhanced deserialization logic to properly cast enum arrays with fixed members to the correct type
  • Added comprehensive test coverage for various array encoding formats with enum and union types

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/typespec-ts/src/modular/helpers/operationHelpers.ts Implements support for string-based enum array encoding by adding type checking helper and updating deserialization logic
packages/typespec-ts/test/modularUnit/scenarios/models/serialization/modelPropertyArrayEncoding.md Adds test cases for enum and union array encoding scenarios

Comment thread packages/typespec-ts/src/modular/helpers/operationHelpers.ts
@JialinHuang803 JialinHuang803 enabled auto-merge (squash) January 20, 2026 02:46
@JialinHuang803 JialinHuang803 merged commit b0ef0d4 into Azure:main Jan 20, 2026
16 checks passed
@JialinHuang803 JialinHuang803 deleted the encode-enum-string branch January 21, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[http-client-ts] CSV encoding for model properties Implementation

3 participants