[jaxrs-spec] Bind an array of binary form properties to a list - #24452
[jaxrs-spec] Bind an array of binary form properties to a list#24452Ignacio-Vidal wants to merge 1 commit into
Conversation
A `type: array` of `format: binary` form properties was collapsed onto the scalar file type, so a multi-file upload was generated with the same signature as a single-file one and only one file could ever be bound. The array dimension is now preserved and such a parameter is generated as `List<InputStream>`. A single binary property is still bound to a scalar `InputStream`, so existing specs are unaffected.
fecffd9 to
8e6ee81
Compare
|
Converting this to a draft — I verified the generated signature against a real runtime and it does not work.
So this change would turn a silent data-loss bug (only one file bound) into a hard deployment failure, which is worse. My earlier verification only checked that the generated code compiles — it does — and never checked that it deploys. That was not sufficient for an annotation-driven injection contract. Worth noting the other JAX-RS generators avoid this by using Options I can see:
I'd lean towards option 2. Happy to follow whichever direction maintainers prefer — flagging now so nobody spends review time on the current diff. |
|
Closing in favour of #24455. As above, The equivalent client-side fix for java/microprofile remains open as #24453, where |
A
type: arrayofformat: binaryform properties was collapsed onto the scalar file type, so a multi-file upload was generated with the same signature as a single-file one — only the array dimension was silently dropped, and only one file could ever be bound.Given:
Before (identical to the single-file signature):
After — default library:
After —
quarkuslibrary:The array dimension is now preserved.
isArraywas already populated on file parameters — this mirrors whatJavaJaxRS/libraries/jersey3already does withList<FormDataBodyPart>— so noDefaultCodegenchange was needed.The
quarkuslibrary additionally moves fromInputStreamto the RESTEasy Reactive multipart types via a new library-scopedformParams.mustache. Per the Quarkus REST guide, the supported multipart types areFileUpload,Path,File,byte[]andBuffer;InputStreamis not among them, and multiple files sharing one part name requireList<FileUpload>. The other libraries (thorntail, helidon, openliberty, kumuluzee, default) keep plainjava.io/java.utiltypes so nothing outside Quarkus gains a dependency.The
org.jboss.resteasy.reactiveimports are emitted only for API files that actually declare a file form parameter, via a newhasFileFormParamsflag — verified against petstore, where onlyPetApigets them andStoreApi/UserApistay unchanged.Note this changes the generated signature for existing
quarkususers with a single-file upload:InputStream _fileInputStreambecomesFileUpload _file. That is the type Quarkus actually supports, but it is a breaking change for code implementing the generated interfaces.Testing
JavaJAXRSSpecServerCodegenTest(array-as-list for the default library,List<FileUpload>for quarkus, and an import-gating regression test); reuses the existing3_0/form-multipart-binary-array.yamlfixture.JavaJAXRSSpecServerCodegenTestand 1084 acrossorg.openapitools.codegen.java.**pass.samples/server/petstore/jaxrs-spec-quarkus-mutinysample compiles against Quarkus (mvn compile), and a live Quarkus app built from these templates bound 3 files posted under one part name.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Summary by cubic
Fixes multi-file form uploads in
jaxrs-specby preserving array dimensions forformat: binary. Arrays of files now bind to@FormParam List<InputStream>instead of collapsing to a singleInputStream.@FormParam("...") List<InputStream> ...InputStream.InputStream; existing signatures are unchanged.quarkus.Written for commit 8e6ee81. Summary will update on new commits.