fix: [OpenAPI] Pin file upload parameter to File type#1160
fix: [OpenAPI] Pin file upload parameter to File type#1160
File type#1160Conversation
File type
There was a problem hiding this comment.
Here is a viable alternate proposal due to the existence of <typeMappings>File=byte[]<typeMappings>
Current: We pin upload type and allows typeMappings to choose download type
Alternate: We pin download type to byte[] and allow typeMappings to override upload type
I don't see a particular winner. So, any ideas are welcomes
There was a problem hiding this comment.
Why not simply keep upload parameter and download return type as File?
From earlier discussions, we want to avoid placing the expectation on user to handle downloaded files properly.
Related Comment
Nevermind. Pinning return type to |
| ### 🔧 Compatibility Notes | ||
|
|
||
| - | ||
| - [OpenAPI] In Apache HttpClient generator, file upload parameters are now pinned to type `java.io.File`, unmodifiable with `<typeMappings>` in generator configuration. |
There was a problem hiding this comment.
(Major/Question)
Are you saying this will no longer have an effect?
(openapi-api-apache-sample/pom.xml)
<typeMappings>File=byte[]</typeMappings>Sounds like a regression to me.
There was a problem hiding this comment.
Setting <typeMappings> is effective for download operations to change return type from File to byte[]. But not in upload operation.
The default behaviour has always been (is still) File type on method parameter and return type. In prompt registry, we overrid this behaviour using <typeMappings> . So, for our regular user, nothing changes. Still, advanced users are affected.
If that is not acceptable, we will have to go with introducing a new feature flag.
Context
On file uploads, the remote service may expect (here Prompt Registry)
Content-Dispositionheader to contain thefilename. At the moment, setting<typeMappings>File=byte[]<typeMappings>can replace all occurrence ofFiletype withbyte[].This means on upload operations, we end up losing filename information, critical for correct successful response.
Feature scope:
Filein upload operation<typeMappings>File=byte[]<typeMappings>override. Now only influence return type on download operations.This is a breaking change.
Definition of Done
Error handling created / updated & covered by the tests aboveDocumentation updated