Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Copy link
Copy Markdown
Contributor

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.itShouldCheckFileUploadEmptiness still asserts the old output strings if (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
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/JavaVertXWebServer/formParams.mustache, line 11:

<comment>This template change breaks the existing unit test for this generator. `JavaVertXWebServerCodegenTest.itShouldCheckFileUploadEmptiness` still asserts the old output strings `if (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.</comment>

<file context>
@@ -4,14 +4,15 @@
+            .filter(upload -> "{{baseName}}".equals(upload.name()))
+            .findFirst()
+            .orElse(null);
+        if ({{paramName}} == null) {
 {{#required}}
             routingContext.fail(400);
</file context>

{{#required}}
routingContext.fail(400);
return;
{{/required}}
} else {
{{paramName}} = routingContext.fileUploads().iterator().next();
}
Comment on lines +11 to 16

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Optional file parameters generate an empty if block; wrap the entire null check in {{#required}} so optional uploads emit no dead branch.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/JavaVertXWebServer/formParams.mustache, line 11:

<comment>Optional file parameters generate an empty `if` block; wrap the entire null check in `{{#required}}` so optional uploads emit no dead branch.</comment>

<file context>
@@ -4,14 +4,15 @@
+            .filter(upload -> "{{baseName}}".equals(upload.name()))
+            .findFirst()
+            .orElse(null);
+        if ({{paramName}} == null) {
 {{#required}}
             routingContext.fail(400);
</file context>
Suggested change
if ({{paramName}} == null) {
{{#required}}
routingContext.fail(400);
return;
{{/required}}
} else {
{{paramName}} = routingContext.fileUploads().iterator().next();
}
{{#required}}
if ({{paramName}} == null) {
routingContext.fail(400);
return;
}
{{/required}}

{{/isFile}}
{{/isFormParam}}
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
<jackson-version>3.1.5</jackson-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,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) {
}

logger.debug("Parameter petId is {}", petId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The if (_file == null) { } block is empty dead code: when the multipart file field is optional (as in the petstore spec), the generated handler does nothing on a missing file and proceeds to call api.uploadFile(petId, null). Wrap the null-check in the template's {{#required}} section so it is only emitted with the fail(400); return; body, avoiding a misleading no-op for optional uploads.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/server/petstore/java-vertx-web/src/main/java/org/openapitools/vertxweb/server/api/PetApiHandler.java, line 219:

<comment>The `if (_file == null) { }` block is empty dead code: when the multipart `file` field is optional (as in the petstore spec), the generated handler does nothing on a missing file and proceeds to call `api.uploadFile(petId, null)`. Wrap the null-check in the template's `{{#required}}` section so it is only emitted with the `fail(400); return;` body, avoiding a misleading no-op for optional uploads.</comment>

<file context>
@@ -212,10 +212,11 @@ private void uploadFile(RoutingContext routingContext) {
+            .filter(upload -> "file".equals(upload.name()))
+            .findFirst()
+            .orElse(null);
+        if (_file == null) {
         }
 
</file context>

}

logger.debug("Parameter petId is {}", petId);
Expand Down
Loading