⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Adds spector scenario tests for enum arrays and union-as-enum arrays with CSV delimiters, following the existing string array test pattern.

Changes

  • Enum definitions: Added Colors fixed enum and ColorsExtensibleEnum union for test data
  • Models: 8 new model definitions with @encode(ArrayEncoding.*) decorators
    • 4 for fixed enum arrays (comma, space, pipe, newline delimited)
    • 4 for extensible enum arrays (comma, space, pipe, newline delimited)
  • Operations: 8 new @scenario operations testing request/response roundtrip for each delimiter type
  • Mock APIs: 8 scenario mock implementations reusing existing helper pattern

Example

enum Colors {
  Blue: "blue",
  Red: "red",
  Green: "green",
}

model CommaDelimitedEnumArrayProperty {
  @encode(ArrayEncoding.commaDelimited)
  value: Colors[];
}

@scenario
@post
op enumCommaDelimited(@body body: CommaDelimitedEnumArrayProperty): CommaDelimitedEnumArrayProperty;
// Expected: {"value": "blue,red,green"}

All tests validate that enum arrays serialize as delimited strings (e.g., "blue,red,green") rather than JSON arrays.

Original prompt

This section details on the original issue you should resolve

<issue_title>CSV encoding for model properties Scenario tests</issue_title>
<issue_description>Add http-specs tests for array encoding, including all four encode. Add a new folder under packages/http-specs/specs/encode.</issue_description>

<agent_instructions>Add another spector test of enum array and union as enum array, according to previous test for string array.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@lirenhe Re-open this item to add the support of Enum as string

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add CSV encoding tests for model properties Add CSV encoding tests for enum and extensible enum arrays Jan 15, 2026
Copilot AI requested a review from tadelesh January 15, 2026 06:13
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/http@9390
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-specs@9390

commit: 4116642

@tadelesh tadelesh marked this pull request as ready for review January 15, 2026 06:32
@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:http-specs For issues/prs related to the @typespec/http-specs package label Jan 15, 2026
@github-actions
Copy link
Contributor

All changed packages have been documented.

  • @typespec/http-specs
Show changes

@typespec/http-specs - feature ✏️

Add array encoding test for enum and extensible enum arrays.

Copy link
Member

@XiaofeiCao XiaofeiCao left a comment

Choose a reason for hiding this comment

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

nit, should we consider edge cases, e.g. empty array("")?

Copy link
Contributor

@weidongxu-microsoft weidongxu-microsoft left a comment

Choose a reason for hiding this comment

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

I've had a simple one. #9330

But fine to use this more complete case.

@tadelesh
Copy link
Member

I've had a simple one. #9330

But fine to use this more complete case.

Sorry for not noticing your PR. Let me close your one.

@tadelesh
Copy link
Member

@timotheeguerin Could you help to reivew?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:http-specs For issues/prs related to the @typespec/http-specs package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSV encoding for model properties Scenario tests

5 participants