Skip to content

feat(http-client-java): support DurationKnownEncoding.milliseconds#9926

Merged
weidongxu-microsoft merged 6 commits intomainfrom
copilot/support-duration-known-encoding
Mar 6, 2026
Merged

feat(http-client-java): support DurationKnownEncoding.milliseconds#9926
weidongxu-microsoft merged 6 commits intomainfrom
copilot/support-duration-known-encoding

Conversation

Copy link
Contributor

Copilot AI commented Mar 5, 2026

  • TypeScript: Add milliseconds-integer and milliseconds-number to DurationSchema format type in time.ts
  • TypeScript: Update DURATION_KNOWN_ENCODING and getDurationFormat in type-utils.ts to handle milliseconds encoding
  • Java: Add MILLISECONDS_INTEGER and MILLISECONDS_NUMBER to DurationSchema.Format enum
  • Java: Add DURATION_MILLISECONDS_LONG and DURATION_MILLISECONDS_DOUBLE to ClassType
  • Java: Add DURATION_MILLISECONDS_LONG and DURATION_MILLISECONDS_DOUBLE to PrimitiveType
  • Java: Update PrimitiveMapper to map new formats to new types
  • Java: Update WireTypeClientTypeConverter with milliseconds conversion logic
  • Java: Update ClassType.getClientType() and PrimitiveType.getClientType() for new types
  • Java: Update ModelTestCaseUtil to handle new types
  • Java: Update ProxyMethodMapper and ClientCoreProxyMethodMapper RETURN_VALUE_WIRE_TYPE_OPTIONS
  • Regenerate test files using Generate.ps1
  • Update test files EncodeDurationTests.java to cover milliseconds scenarios; only disable floatMilliseconds/float64Milliseconds/floatMillisecondsLargerUnit for query/header (they produce 35625.0 instead of 35625)
  • Build and unit tests passing
  • Add changeset
Original prompt

This section details on the original issue you should resolve

<issue_title>http-client-java, support DurationKnownEncoding.milliseconds</issue_title>
<issue_description>### Clear and concise description of the problem

In packages/http-client-java

Support DurationKnownEncoding.milliseconds

Test scenario is at https://github.com/microsoft/typespec/blob/main/packages/http-specs/specs/encode/duration/main.tsp#L240-L251

Check existing Java code of DURATION_LONG and DURATION_DOUBLE. On Java, we can call it DURATION_MILLISECONDS_LONG and DURATION_MILLISECONDS_DOUBLE

Typescript code would be around DURATION_KNOWN_ENCODING and related code.

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
@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 Mar 5, 2026
Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for DurationKnownEncoding.milliseconds feat(http-client-java): support DurationKnownEncoding.milliseconds Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

All changed packages have been documented.

  • @typespec/http-client-java
Show changes

@typespec/http-client-java - feature ✏️

Support DurationKnownEncoding.milliseconds in http-client-java. Duration properties encoded as milliseconds now use Duration as the client type, with proper conversion to/from integer or float milliseconds on the wire.

@weidongxu-microsoft
Copy link
Contributor

@copilot

Please disable the test reported in https://dev.azure.com/azure-sdk/public/_build/results?buildId=5964964&view=logs&jobId=05bf61c7-7c78-55dc-7397-674208d00256&j=05bf61c7-7c78-55dc-7397-674208d00256&t=ca5cf95d-5e85-54b0-70fc-4a51fd77b80e

I think the cause is e2e on the test part. We don't need to change test code. But we need to disable the test, before it get fixed.

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 5, 2026

@copilot

Please disable the test reported in https://dev.azure.com/azure-sdk/public/_build/results?buildId=5964964&view=logs&jobId=05bf61c7-7c78-55dc-7397-674208d00256&j=05bf61c7-7c78-55dc-7397-67...

Done in commit 7b5dbf9. The milliseconds test calls in both http-client-generator-test and http-client-generator-clientcore-test EncodeDurationTests.java are now commented out with a TODO: enable once supported in the test server note.

@weidongxu-microsoft
Copy link
Contributor

@copilot

I mean, only disable the lines that reported in the log

[ERROR]   EncodeDurationTests.testHeader:81 » HttpResponse Status code 400, "{"message":"Expected 35625 but got 35625.0","expected":"35625","actual":"35625.0"}"
[ERROR]   EncodeDurationTests.testQuery:54 » HttpResponse Status code 400, "{"message":"Expected query param input=35625 but got 35625.0","expected":"35625","actual":"35625.0"}"

… 35625.0 instead of 35625

Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 5, 2026

@copilot

I mean, only disable the lines that reported in the log
...

Done in commit d717b5d. Only floatMilliseconds, floatMillisecondsLargerUnit, and float64Milliseconds are disabled for query and header (they produce 35625.0 instead of 35625). All int32-based milliseconds tests and all property tests are re-enabled.

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@weidongxu-microsoft
Copy link
Contributor

weidongxu-microsoft commented Mar 6, 2026

bug on e2e test #9944
PR #9945

@weidongxu-microsoft weidongxu-microsoft added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit 6f07d5b Mar 6, 2026
31 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the copilot/support-duration-known-encoding branch March 6, 2026 06:50
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, support DurationKnownEncoding.milliseconds

4 participants