http-client-java, support File in multipart and request body#9602
Conversation
|
All changed packages have been documented.
|
commit: |
There was a problem hiding this comment.
Pull request overview
This PR extends File type support in the http-client-java emitter to cover multipart and request body scenarios. Previously, PR #9530 only supported File in response body for ARM cases. This PR adds the missing support for File in request bodies and refines the handling of File properties (filename and contentType) in multipart scenarios.
Changes:
- Extended code-model-builder.ts to detect and process File types in request bodies (similar to existing response body handling)
- Modified external-schemas.ts to improve handling of constant vs non-constant filename and contentType properties with better default value logic
- Removed ClientInitializationTests.java test file (unrelated to File support)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/http-client-java/emitter/src/code-model-builder.ts | Added File detection logic for request bodies, renamed variables for clarity (responseIsFile → responseBodyIsFile, requestBodyIsFile), and widened processBinarySchema signature from SdkBuiltInType to SdkType |
| packages/http-client-java/emitter/src/external-schemas.ts | Refactored filename and contentType property handling to better support constant types with default values, addressing TypeSpec.Http.File<"image/png"> scenarios |
| packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/clientgenerator/core/clientinitialization/ClientInitializationTests.java | Deleted test file containing client initialization tests unrelated to File support |
| .chronus/changes/http-client-java_support-file-2026-1-6-12-16-2.md | Added changeset documenting the feature addition |
Comments suppressed due to low confidence (1)
packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/clientgenerator/core/clientinitialization/ClientInitializationTests.java:1
- The deletion of ClientInitializationTests.java appears to be unrelated to the purpose of this PR, which is to support File in multipart and request body. This test file contained tests for various client initialization scenarios (header parameters, path parameters, mixed parameters, etc.) that have nothing to do with File type support.
This deletion seems accidental or perhaps part of a code generation cleanup that should be handled separately. If this deletion is intentional, it should be explained in the PR description. Otherwise, this file should be restored.
|
You can try these changes here
|
fix #9509
For request body / response body of non-multipart op, they are treated as
bytesof unknown mediaType, generated asBinaryData.For multipart, they are treated as usually, in
HttpPart<>of File, generated as##FileDetails.The difference is that
now can be written as
(the only difference is that former defined a name of
FileSpecificContentType, so Java will use this directly; while latter theFilekind of be a template name, and Java cannot directly use it as it could conflict with another e.g.File<"application/text">)PR #9530 only supported the case we see in ARM, on File in response body
tested on tsp from #9513 (http-specs is not released)