-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix multipart fields in vertx #24668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,14 +4,15 @@ | |||||||||||||||||||||||||||||
| JsonObject {{paramName}} = body != null ? body.getJsonObject() : null; | ||||||||||||||||||||||||||||||
| {{/isFile}} | ||||||||||||||||||||||||||||||
| {{#isFile}} | ||||||||||||||||||||||||||||||
| {{{dataType}}} {{paramName}} = null; | ||||||||||||||||||||||||||||||
| if (routingContext.fileUploads().isEmpty()) { | ||||||||||||||||||||||||||||||
| {{{dataType}}} {{paramName}} = routingContext.fileUploads().stream() | ||||||||||||||||||||||||||||||
| .filter(upload -> "{{baseName}}".equals(upload.name())) | ||||||||||||||||||||||||||||||
| .findFirst() | ||||||||||||||||||||||||||||||
| .orElse(null); | ||||||||||||||||||||||||||||||
| if ({{paramName}} == null) { | ||||||||||||||||||||||||||||||
| {{#required}} | ||||||||||||||||||||||||||||||
| routingContext.fail(400); | ||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||
| {{/required}} | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| {{paramName}} = routingContext.fileUploads().iterator().next(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Optional file parameters generate an empty Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||||
| {{/isFile}} | ||||||||||||||||||||||||||||||
| {{/isFormParam}} | ||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,10 +212,11 @@ private void uploadFile(RoutingContext routingContext) { | |
| RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY); | ||
|
|
||
| Long petId = requestParameters.pathParameter("petId") != null ? requestParameters.pathParameter("petId").getLong() : null; | ||
| FileUpload _file = null; | ||
| if (routingContext.fileUploads().isEmpty()) { | ||
| } else { | ||
| _file = routingContext.fileUploads().iterator().next(); | ||
| FileUpload _file = routingContext.fileUploads().stream() | ||
| .filter(upload -> "file".equals(upload.name())) | ||
| .findFirst() | ||
| .orElse(null); | ||
| if (_file == null) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The Prompt for AI agents |
||
| } | ||
|
|
||
| logger.debug("Parameter petId is {}", petId); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: This template change breaks the existing unit test for this generator.
JavaVertXWebServerCodegenTest.itShouldCheckFileUploadEmptinessstill asserts the old output stringsif (routingContext.fileUploads().isEmpty()) {,} else {, and_file = routingContext.fileUploads().iterator().next();, but the template no longer emits any of them, so the test will fail and the module build/CI will go red. Please update the test assertions (and ideally add coverage for the new field-name filter plus the 400-on-missing-required-file behavior) alongside this template change.Prompt for AI agents