Skip to content

Conversation

@weidongxu-microsoft
Copy link
Contributor

@weidongxu-microsoft weidongxu-microsoft commented Dec 16, 2025

fix #9027

see https://github.com/microsoft/typespec/pull/9218/files#diff-e8b978e5080675f7527d4beb363a9dde604493dbff1db49116ea56c94b2339e1 on difference on generated code.

Currently only supports element as String. (the convert from a subtype to String need some refactor in existing code)

release PR is Azure/autorest.java#3242

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Dec 16, 2025
@github-actions
Copy link
Contributor

No changes needing a change description found.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Dec 16, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copy link
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 PR adds support for delimited array encoding (CSV and other formats) on properties in the http-client-java emitter. The implementation allows TypeSpec models to specify how arrays of strings should be serialized as delimited strings in JSON (comma, space, pipe, or newline-delimited) instead of as JSON arrays. The changes span the code generator, model templates, and include both Azure and clientcore test implementations.

Key Changes

  • Introduces ArrayEncoding enum to define delimiter strategies for array serialization
  • Extends ClientModelProperty to include array encoding metadata
  • Updates serialization/deserialization templates to handle delimited string encoding
  • Adds validation to ensure only string element types are supported for array encoding

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/http-client-java/package.json Updates TypeSpec compiler and various dev dependencies to newer versions
packages/http-client-java/package-lock.json Lockfile updates corresponding to package.json changes
packages/http-client-java/generator/http-client-generator-test/src/test/java/encode/array/EncodeArrayTests.java New test suite for array encoding with comma, space, pipe, and newline delimiters
packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/clientgenerator/core/clientlocation/ClientLocationClientTests.java Test file removed (appears to be replaced by generated tests)
packages/http-client-java/generator/http-client-generator-test/src/main/java/encode/array/models/*.java Generated model classes implementing delimiter-based serialization for different array encoding types
packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java Updates toJson/fromJson generation to handle array encoding with delimiter-based string serialization
packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientModelProperty.java Adds arrayEncoding field to track delimiter configuration
packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ArrayEncoding.java New enum defining delimiter types and their escape sequences
packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ModelPropertyMapper.java Maps array encoding metadata from TypeSpec model to Java property
packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/extension/model/codemodel/Property.java Adds arrayEncoding field to Property model
packages/http-client-java/generator/http-client-generator-clientcore-test/src/**/*.java Clientcore test implementations mirroring the Azure test structure
packages/http-client-java/emitter/src/lib.ts Adds diagnostic for unsupported non-string array encoding elements
packages/http-client-java/emitter/src/common/client.ts Defines EncodedProperty interface for array encoding metadata
packages/http-client-java/emitter/src/code-model-builder.ts Validates string element type requirement and maps array encoding to code model
Files not reviewed (1)
  • packages/http-client-java/package-lock.json: Language not supported

@weidongxu-microsoft weidongxu-microsoft changed the title http-client-java, support csv on property http-client-java, support array encoded as CSV on property Dec 16, 2025
@weidongxu-microsoft weidongxu-microsoft marked this pull request as ready for review December 16, 2025 06:40
Copy link
Member

@haolingdong-msft haolingdong-msft left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. Add a nit. Thanks!

@weidongxu-microsoft weidongxu-microsoft force-pushed the http-client-java_support-csv-on-property branch from bdc3cbd to fd843b1 Compare December 17, 2025 03:24
@weidongxu-microsoft weidongxu-microsoft added this pull request to the merge queue Dec 18, 2025
Merged via the queue into microsoft:main with commit 9f01672 Dec 18, 2025
26 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the http-client-java_support-csv-on-property branch December 18, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants